Didn't find class "com.esri.arcgisruntime.ArcGISRuntimeEnvironment"

2094
7
09-11-2019 02:47 PM
AhmedSaeed
New Contributor

When I try to run with android studio, it's working fine on device. But when I try to build apk and install it manually, I am getting this exception. Same thing is happening from play store.

I am using android SDK 100.6.0

java.lang.ClassNotFoundException: Didn't find class "com.esri.arcgisruntime.ArcGISRuntimeEnvironment" on path: DexPathList[[zip file "/data/app/sa.test.oads-2M9eFuy0a9K3TZv1Q6hIPw==/base.apk"],nativeLibraryDirectories=[/data/app/sa.test.oads-2M9eFuy0a9K3TZv1Q6hIPw==/lib/arm64, /data/app/sa.test.oads-2M9eFuy0a9K3TZv1Q6hIPw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
2019-09-11 23:43:44.682 4741-4741/? A/.test.oads: thread.cc:2148] at void sa.test.oads.activities.TestApp.onCreate() (:-1)
2019-09-11 23:43:44.834 4741-4741/? A/.test.oads: runtime.cc:565] native: #10 pc 000000000019012c /data/app/sa.test.oads-2M9eFuy0a9K3TZv1Q6hIPw==/lib/arm64/libruntimecore_java.so (offset 190000) (???)
2019-09-11 23:43:44.834 4741-4741/? A/.test.oads: runtime.cc:565] native: #11 pc 000000000019052c /data/app/sa.test.oads-2M9eFuy0a9K3TZv1Q6hIPw==/lib/arm64/libruntimecore_java.so (offset 190000) (JNI_OnLoad+384)
2019-09-11 23:43:44.834 4741-4741/? A/.test.oads: runtime.cc:565] at sa.test.oads.activities.TestApp.onCreate(:-1)
2019-09-11 23:43:44.837 4741-4741/? A/.test.oads: runtime.cc:565] native: #27 pc 000000000017e38e /data/app/sa.test.oads-2M9eFuy0a9K3TZv1Q6hIPw==/oat/arm64/base.vdex (c.b.a.a.g+14)
2019-09-11 23:43:44.837 4741-4741/? A/.test.oads: runtime.cc:565] native: #33 pc 00000000001848e0 /data/app/sa.test.oads-2M9eFuy0a9K3TZv1Q6hIPw==/oat/arm64/base.vdex (com.esri.arcgisruntime.internal.jni.CoreArcGISRuntimeEnvironment.<clinit>)
2019-09-11 23:43:44.838 4741-4741/? A/.test.oads: runtime.cc:565] native: #55 pc 0000000000282ce4 /data/app/sa.test.oads-2M9eFuy0a9K3TZv1Q6hIPw==/oat/arm64/base.vdex (sa.test.oads.activities.TestApp.onCreate+16)
2019-09-11 23:43:44.838 4741-4741/? A/.test.oads: runtime.cc:565] at sa.test.oads.activities.TestApp.onCreate(:-1)
2019-09-11 23:43:44.838 4741-4741/? A/.test.oads: runtime.cc:573]

7 Replies
GuntherHeppner
Esri Contributor

Hi Ahmed,

Can you provide some more information please.

- How do you reference the ArcGIS Runtime SDK dependency in your gradle build script? Can you share that code snippet?
- Does this `ClassNotFoundException` only happen on one or more specific devices or on any device? It looks like you are using a 64 bit ARM device. Could you also try a 32 bit ARM device?

Thanks, Gunther

0 Kudos
AhmedSaeed
New Contributor

Mistakenly I have added following two lines

minifyEnabled true
shrinkResources true

now I make these values false and it's working fine.
0 Kudos
GuntherHeppner
Esri Contributor

Hi Ahmed,

Thanks for reporting back. The ArcGIS Runtime SDK dependency is already obfuscated so in your build script you should prevent it from being obfuscated twice. Completely disabling obfuscation for your project can achieve that but you might still want to obfuscate your own code. If you are using Proguard, you can exclude the ArcGIS Runtime SDK dependency from obfuscation by adding the following line in your proguard rules file:

 

-keep public class com.esri.arcgisruntime.* { *; }

 

Gunther

0 Kudos
ShylendraMadda1
New Contributor II

I tried as you suggested but still am getting the same error message.

JNI DETECTED ERROR IN APPLICATION: JNI FindClass called with pending exception java.lang.ClassNotFoundException: Didn't find class "com.esri.arcgisruntime.ArcGISRuntimeEnvironment" on path: DexPathList

0 Kudos
ShylendraMadda1
New Contributor II

I enabled R8 in my application along with 

release {
minifyEnabled true
shrinkResources true
zipAlignEnabled true
}

I have tried to add the following things to keep these at run time. But still am facing the same issue.

-keep class com.esri.** { *; }
-keep interface com.esri.** { *; }
-keep class org.codehaus.jackson.** { *; }
-dontwarn org.codehaus.jackson.map.ext.**
-dontwarn jcifs.http.**

Reference: com.esri.arcgis.android:arcgis-android:10.2.6-2 with proguard - Stack Overflow 

Error message when I run the app:

JNI DETECTED ERROR IN APPLICATION: JNI FindClass called with pending exception java.lang.ClassNotFoundException: Didn't find class "com.esri.arcgisruntime.ArcGISRuntimeEnvironment" on path: DexPathList

Can you please help me on this.

0 Kudos
ShylendraMadda1
New Contributor II

Any solution for this so far?

0 Kudos
Erick_1
Esri Contributor

Shylendra MaddaAhmed Saeed

We found that by adding this line to your proguard-rules.pro file, R8 stops obfuscating the SDK:

-keep class com.esri.arcgisruntime.** { *; }

Please give it a try and report back if it works for your use case.

We will add this to our SDK in feature releases for R8 to pick it up automatically so the user doesn't have to add it.   

0 Kudos