UnsatisfiedLinkError (com.esri.core.runtime.LicenseImpl.nativeIsClientIdValid)

Error starting application on device:

java.lang.UnsatisfiedLinkError: Native method not found: com.esri.core.runtime.LicenseImpl.nativeIsClientIdValid:(Ljava/lang/String;)Z at com.esri.core.runtime.LicenseImpl.nativeIsClientIdValid(Native Method) at com.esri.core.runtime.LicenseImpl.a(Unknown Source) at com.esri.android.abb(Unknown Source) 

Associated Code:

 import com.esri.android.runtime.ArcGISRuntime; public class MainActivity extends FragmentActivity implements NavigationDrawerFragment.NavigationDrawerCallbacks { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ArcGISRuntime.setClientId("xxxxxxxxxxxxxxxx"); ...... 

build.gradle:

 apply plugin: 'com.android.application' android { compileSdkVersion 19 buildToolsVersion "21.1.2" defaultConfig { applicationId "xxx.xxxx.xxxxx" minSdkVersion 17 targetSdkVersion 19 versionCode 1 versionName "1.0" renderscriptTargetApi 19 renderscriptSupportModeEnabled true } packagingOptions { exclude 'META-INF/DEPENDENCIES' exclude 'META-INF/LGPL2.1' exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' } buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' applicationVariants.all { variant -> variant.outputs.each { output -> output.outputFile = new File(output.outputFile.parent, "xxxx-release.apk") } } } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:support-v4:21.0.3' compile 'com.google.android.gms:play-services:6.5.87' } 

ProGuard-Rules.txt:

 -keep class android.view.** { *; } -keep class com.esri.** { *; } -keep class javax.servlet.** { *; } -keep class jcifs.http.** { *; } -keep class org.apache.http.** { *; } -keep class org.joda.time.** { *; } -keep class org.w3c.dom.bootstrap.** { *; } -keep class org.xmlpull.v1.** { *; } -dontwarn javax.servlet.** -dontwarn jcifs.http.** -dontwarn org.apache.http.** -dontwarn org.joda.time.** -dontwarn org.w3c.dom.bootstrap.** -dontwarn org.xmlpull.v1.** 

Logcat:

 03-04 18:06:19.213 13255-13255/xxx.xxxx.xxxxx D/dalvikvm﹕ GC_FOR_ALLOC freed 360K, 17% free 35228K/42136K, paused 17ms, total 17ms 03-04 18:06:19.283 13255-13255/xxx.xxxx.xxxxx D/dalvikvm﹕ GC_FOR_ALLOC freed 368K, 16% free 35516K/42136K, paused 14ms, total 14ms 03-04 18:06:19.343 13255-13753/xxx.xxxx.xxxxx D/dalvikvm﹕ GC_FOR_ALLOC freed 408K, 15% free 35859K/42136K, paused 14ms, total 14ms 03-04 18:06:19.353 13255-13753/xxx.xxxx.xxxxx W/dalvikvm﹕ Failed processing annotation value 03-04 18:06:19.353 13255-13753/xxx.xxxx.xxxxx W/dalvikvm﹕ Exception Ljava/lang/NoSuchFieldError; thrown while initializing Lorg/b/a/d/e/z; 03-04 18:06:19.353 13255-13753/xxx.xxxx.xxxxx W/dalvikvm﹕ Exception Ljava/lang/NoSuchFieldError; thrown while initializing Lorg/b/a/d/an; 03-04 18:06:19.353 13255-13753/xxx.xxxx.xxxxx W/dalvikvm﹕ Exception Ljava/lang/NoSuchFieldError; thrown while initializing Lcom/esri/core/internal/util/d; 03-04 18:06:19.353 13255-13754/xxx.xxxx.xxxxx I/dalvikvm﹕ Rejecting re-init on previously-failed class Lcom/esri/core/internal/util/d; v=0x0 03-04 18:06:19.423 13255-13255/xxx.xxxx.xxxxx D/dalvikvm﹕ GC_FOR_ALLOC freed 776K, 15% free 35950K/42136K, paused 14ms, total 14ms 03-04 18:06:19.443 13255-13756/xxx.xxxx.xxxxx I/dalvikvm﹕ Rejecting re-init on previously-failed class Lcom/esri/core/internal/util/d; v=0x0 03-04 18:06:19.453 13255-13755/xxx.xxxx.xxxxx I/dalvikvm﹕ Rejecting re-init on previously-failed class Lcom/esri/core/internal/util/d; v=0x0 

I use: Android Studio 1.0.2 and ArcGIS SDK 10.2.5

No problem if the application starts Android Studio. An error occurred while creating the application in the APK, installing on the device and then launching it.

Is there any solution?

Many thanks!

Similar question. The answer does not work.

+7
android unsatisfiedlinkerror arcgis
source share
4 answers

Your problem with ProGuard. When you deploy the application in release mode, ProGuard starts and reduces all your methods / classes / variables / etc. This means that if once the method was called " doSomething() ", it will be renamed to something like " a() ". This is good because when it happens throughout your code, it makes your code smaller and faster.

This may be a problem with working with the NDK, because the way the native library communicates with Java methods is a reflection that requires naming convention (methods found by text name. If the name changes, the method cannot be found).

You can solve this problem by editing the ProGuard file to exclude certain classes.

For example, in your case, I would add the following line to the ProGuard file:

 -keep class com.esri.core.runtime.LicenseImpl { *; } 

Actually, you can make this rule even more specific in order to exclude only the problematic method:

 -keep class com.esri.core.runtime.LicenseImpl { public void nativeIsClientIdValid(...); } 

ProGuard is quite effective when it comes to which parts of the code have been minified or not, so I suggest reading on it.

Perhaps there are other classes that should be excluded from ProGuard in the same way, so if you continue to get similar errors after adding this fix, just add more ProGuard rules, depending on which methods / classes are not found.

Edit:

According to the new error you are getting, it seems that proguard is a refactoring of annotations, and this may be the reason for your new error. Add a check box to exclude annotations:

 -keepattributes *Annotation* 

Edit 2:

According to this blog post about porting projects to Android studio on the Esri website , it looks like they have not yet found a way to overcome ProGuard on their own, as they recommend setting enableMinify to false . This may mean that the Esri package simply does not work to minimize at this time or that they did not spend time figuring out how to solve the problem.

+2
source share

Add this to your proguard file. This will not confuse your library.

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

worked for me.

+1
source share

I had the same problem and resolved as described in this link to Esri GeoNet .

Based on what EsriStaff wrote:

Yes, I agree that this is most likely what is happening. I see on the path above that the arm64 paths are involved, and there was also a comment above that everything works fine until another dependency is added. Given these two points, it is very possible that you ran into a problem when Android once loaded a 64-bit native library, it no longer loads 32-bit libraries. [...] ArcGIS Runtime SDK SDK provides the 32-bit armeabi-v7a library, which usually loads on a 64-bit basis, as it is compatible with the transition, which explains why you find things until you add more dependencies.

Since the SO> question related in EsriGeoNet offers a solution to add this to the app.gradle file:

 android { .... defaultConfig { .... ndk { abiFilters "armeabi", "armeabi-v7a", "x86", "mips" } } } 

At this point, when starting the gradle assembly, an NDK obsolescence error should be displayed, which you can solve by adding it to your gradle.properties (Global properties) file:

 android.useDeprecatedNdk = true 

I tested on Samsung S6 with Android 6.0.1 and worked fine.

In addition to this, I found out that the problem was already in the ArcGis Android SDK v10.2.3, and that updating to the latest v10.2.8.1 does not fix the problem.

Next week our employees are scheduled to meet with the Esri Italian office, and I will ask for details about this error, and if / when it will be fixed.

Hope this helps you and everyone who has this problem.

0
source share

All Articles