Select to view content in your preferred language

How to resolve crash on start when using ArcGISRuntime.setClientId(<clientID>)

5918
9
Jump to solution
06-29-2016 08:12 AM
ArturRybak
Deactivated User

votefavorite

I have problem with app crashing on start while invoking ArcGISRuntime.setClientId(getString(R.string.ArcGISClientId));

it causes exception:

    java.lang.UnsatisfiedLinkError: No implementation found for boolean com.esri.core.runtime.LicenseImpl.nativeIsClientIdValid(java.lang.String) (tried Java_com_esri_core_runtime_LicenseImpl_nativeIsClientIdValid and Java_com_esri_core_runtime_LicenseImpl_nativeIsClientIdValid__Ljava_lang_String_2) at com.esri.core.runtime.LicenseImpl.nativeIsClientIdValid(Native Method) at com.esri.core.runtime.LicenseImpl.b(SourceFile:103) at com.esri.android.runtime.ArcGISRuntime$License.b(SourceFile:133) at com.esri.android.runtime.ArcGISRuntime$License.a(SourceFile:72) at com.esri.android.runtime.ArcGISRuntime.setClientId(SourceFile:51) at com.ihs.connect.App.configureArcGIS(App.java:89) at com.ihs.connect.App.onCreate(App.java:82) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1036) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6316) at android.app.ActivityThread.access$1800(ActivityThread.java:221) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1860) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7224) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

Affected devices are running Android 6.0 / 6.0.1. But it doesn't occur on all devices. Some of them are:

  • SM-G920F (Samsung Galaxy S6)
  • SC-02H (Samsung Galaxy S7 Edge)
  • SM-N920C (samsung Galaxy Note 5)
  • ASUS_Z010D (ASUS ZenFone Max)
  • Nexus 5X (LG Nexus 5X)
  • LG-H815 (LG G4)
  • E5823 (Sony Xperia Z5 Compact)
  • SAMSUNG-SM-G935A (Samsung Galaxy S7 Edge)
  • SM-N9208 (Samsung Galaxy Note5 Duos)
  • SGP771 (Sony Xperia Tablet Z4)
  • 0PJA2 (HTC One M9)

I have tried running it with and without ProGuard, but still no effect. Any ideas?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
ShellyGill1
Esri Contributor

08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.neseapl.test-1/base.apk"],nativeLibraryDirectories=[/data/app/com.neseapl.test-1/lib/arm64, /data/app/com.neseapl.test-1/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libruntimecore_java.so" 

 

Not quite sure how to fix this issue, seems to be not able to find the native libraries.

Yes, I agree that this is most likely what's happening. I can see in the path above that arm64 paths are involved, and also there was a comment above that things work OK, until another dependency is added. Given those two points, it's very possible you're running in to the problem where once Android has loaded a 64-bit native library, it no longer loads 32-bit libraries.

StackOverflow contains this question and answer which might help explain things: How to use 32-bit native libaries on 64-bit Android device - Stack Overflow . This blog post might also be useful: https://corbt.com/posts/2015/09/18/mixing-32-and-64bit-dependencies-in-android.html . The ArcGIS Runtime SDK provides 32-bit armeabi-v7a library, which would normally be loaded when running on 64 bit, as its forwardly compatible, which would explain why you're finding things OK until you add more dependencies. 

View solution in original post

9 Replies
AlexanderNohe1
Honored Contributor

Hello Artur Rybak​,

I am going to test this on my Nexus 5X and let you know the results.  I am assuming that you are using 10.2.8?

Thanks,

Alexander

0 Kudos
AlexanderNohe1
Honored Contributor

I have gone ahead and tested this on Android 6.0.1 on an LG Nexus 5x and was not able to reproduce the results that you are seeing.  Below is the code that I used in my sample.

public class MainActivity extends AppCompatActivity {

  MapView mapView;

  @Override protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);

   LicenseResult licR = ArcGISRuntime.setClientId(getString(R.string.ArcGISClientId));
   Log.e("NOHE",licR.toString());


   setContentView(R.layout.activity_main);

   Toast.makeText(getApplicationContext(), "points added to MapView First", Toast.LENGTH_LONG).show();
  }
}
TS5
by
Deactivated User

Hope you don't mind me bumping and replying to this thread as I am facing the same issue.

When I am compiling a project with just arcgis and no other dependencies, it seems to run fine. However when I added more dependencies, this issue starts to pop up. I started a new empty project and am able to replicate the issue.

The Gradle file I tried is as follow, which contain more of the commonly used libraries. It will also be a multi dex app because of this.

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.android.support:design:24.0.0'
    compile 'com.android.support:recyclerview-v7:24.0.+'
    compile 'com.android.support:gridlayout-v7:24.0.+'
    compile 'com.squareup.okhttp3:okhttp:3.0.1'
    compile 'com.squareup.retrofit2:retrofit:2.0.2'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
    compile 'com.squareup.retrofit2:converter-gson:2.0.2'
    compile 'com.google.android.gms:play-services-gcm:9.2.0'
    compile 'com.google.android.gms:play-services-location:9.2.0'
    compile 'com.google.android.gms:play-services-analytics:9.2.0'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.karumi:dexter:2.2.2'
    compile 'com.github.clans:fab:1.6.4'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'uk.co.chrisjenx:calligraphy:2.1.0'
    compile 'com.daimajia.swipelayout:library:1.2.0@aar'
    compile 'io.github.luizgrp.sectionedrecyclerviewadapter:sectionedrecyclerviewadapter:1.0.4'
    compile 'com.esri.arcgis.android:arcgis-android:10.2.8-1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.0.2'
    compile 'io.realm:android-adapters:1.0.1'
    compile 'com.github.thorbenprimke:realm-recyclerview:0.9.22'
    debugCompile 'com.facebook.stetho:stetho-okhttp3:1.3.1'
    debugCompile 'com.facebook.stetho:stetho:1.3.1'
}

The Application file, which the app crashes on,

public class MyApplication extends MultiDexApplication {

    @Override
    public void onCreate() {
        super.onCreate();

        ArcGISRuntime.setClientId(getString(R.string.ArcGISClientId));
    }
}

The full stack trace,

08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: java.lang.reflect.InvocationTargetException
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at java.lang.reflect.Method.invoke(Native Method)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at com.esri.core.internal.util.f.b(SourceFile:67)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at com.esri.core.internal.util.f.a(SourceFile:21)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at com.esri.core.internal.util.f$1.initialize(SourceFile:38)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at com.esri.android.runtime.ArcGISRuntime$License.<clinit>(SourceFile:77)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at com.esri.android.runtime.ArcGISRuntime.setClientId(SourceFile:51)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at com.neseapl.test.MyApplication.onCreate(MyApplication.java:14)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1036)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6321)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at android.app.ActivityThread.access$1800(ActivityThread.java:222)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1861)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at android.os.Looper.loop(Looper.java:158)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at android.app.ActivityThread.main(ActivityThread.java:7229)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at java.lang.reflect.Method.invoke(Native Method)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.neseapl.test-1/base.apk"],nativeLibraryDirectories=[/data/app/com.neseapl.test-1/lib/arm64, /data/app/com.neseapl.test-1/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libruntimecore_java.so"
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at java.lang.Runtime.loadLibrary(Runtime.java:367)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at java.lang.System.loadLibrary(System.java:1076)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at com.esri.core.internal.RuntimeHelper.a(SourceFile:85)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: at com.esri.core.internal.RuntimeHelper.initialize(SourceFile:47)
08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: ... 17 more
08-15 11:18:08.781 8719-8719/com.neseapl.test E/art: No implementation found for boolean com.esri.core.runtime.LicenseImpl.nativeIsClientIdValid(java.lang.String) (tried Java_com_esri_core_runtime_LicenseImpl_nativeIsClientIdValid and Java_com_esri_core_runtime_LicenseImpl_nativeIsClientIdValid__Ljava_lang_String_2)
08-15 11:18:08.781 8719-8719/com.neseapl.test D/AndroidRuntime: Shutting down VM
08-15 11:18:08.781 8719-8719/com.neseapl.test E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.neseapl.test, PID: 8719
java.lang.UnsatisfiedLinkError: No implementation found for boolean com.esri.core.runtime.LicenseImpl.nativeIsClientIdValid(java.lang.String) (tried Java_com_esri_core_runtime_LicenseImpl_nativeIsClientIdValid and Java_com_esri_core_runtime_LicenseImpl_nativeIsClientIdValid__Ljava_lang_String_2)
at com.esri.core.runtime.LicenseImpl.nativeIsClientIdValid(Native Method)
at com.esri.core.runtime.LicenseImpl.b(SourceFile:103)
at com.esri.android.runtime.ArcGISRuntime$License.b(SourceFile:133)
at com.esri.android.runtime.ArcGISRuntime$License.a(SourceFile:72)
at com.esri.android.runtime.ArcGISRuntime.setClientId(SourceFile:51)
at com.neseapl.test.MyApplication.onCreate(MyApplication.java:14)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1036)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6321)
at android.app.ActivityThread.access$1800(ActivityThread.java:222)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1861)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

Not quite sure how to fix this issue, seems to be not able to find the native libraries. Any help or advice would be graetly appreciated.

Edit. This is tested on Samsung Galaxy Note5(SM-N920i) 6.0.1

Thanks!

0 Kudos
AlexanderNohe1
Honored Contributor

Are you only able to reproduce on this device or are you able to reproduce on an emulator as well?

Thanks

0 Kudos
AlexanderNohe1
Honored Contributor

I can reproduce with a Nexus 5x on Android M.  Cannot reproduce on an emulator.

I will continue to research this issue.

0 Kudos
AlexanderNohe1
Honored Contributor

Hello T S

I found that including the following line is generating the crash on my end:

compile 'io.realm:android-adapters:1.0.1'


This error seems to be propagated from Realm.
0 Kudos
TS5
by
Deactivated User

Thanks for the tip on the error.

I removed the above dependency, but it appears the main plugin of realm is also causing this issue.

After researching and reading up, it seems to be an issue with Android not being able to load 32-bit and 64-bit native libraries concurrently, which is mentioned in the FAQ of Realm.

To help other users which might face the problem, a similar user had the same problem with other native libraries with Realm which you can read up on SO(android - Using JavaCV and Realm together causes "java.lang.UnsatisfiedLinkError" - Stack Overflow)

Thanks for your help.

AlexanderNohe1
Honored Contributor

I checked the FAQ of Realm very briefly and could not find the section on loading 32 bit and 64 bit native libraries.  Could you please specify the heading under which this lies?

0 Kudos
ShellyGill1
Esri Contributor

08-15 11:18:08.781 8719-8719/com.neseapl.test W/System.err: Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.neseapl.test-1/base.apk"],nativeLibraryDirectories=[/data/app/com.neseapl.test-1/lib/arm64, /data/app/com.neseapl.test-1/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libruntimecore_java.so" 

 

Not quite sure how to fix this issue, seems to be not able to find the native libraries.

Yes, I agree that this is most likely what's happening. I can see in the path above that arm64 paths are involved, and also there was a comment above that things work OK, until another dependency is added. Given those two points, it's very possible you're running in to the problem where once Android has loaded a 64-bit native library, it no longer loads 32-bit libraries.

StackOverflow contains this question and answer which might help explain things: How to use 32-bit native libaries on 64-bit Android device - Stack Overflow . This blog post might also be useful: https://corbt.com/posts/2015/09/18/mixing-32-and-64bit-dependencies-in-android.html . The ArcGIS Runtime SDK provides 32-bit armeabi-v7a library, which would normally be loaded when running on 64 bit, as its forwardly compatible, which would explain why you're finding things OK until you add more dependencies.