的UnsatisfiedLinkError(com.esri.core.runtime.LicenseImpl.nativeIsClientIdValid) [英] UnsatisfiedLinkError (com.esri.core.runtime.LicenseImpl.nativeIsClientIdValid)

查看:1082
本文介绍了的UnsatisfiedLinkError(com.esri.core.runtime.LicenseImpl.nativeIsClientIdValid)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

发生在设备上运行的应用程序错误:

Error occurred in running app in 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.a.b.b(Unknown Source)

相关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:

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:

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的:

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

我使用:Android的工作室1.0.2和ArcGIS SDK 10.2.5

I use: Android Studio 1.0.2 and ArcGIS SDK 10.2.5

有是,如果应用程序是由Android Studio中运行没有问题。发生错误,如果在APK生成的应用程序,安装在设备中,然后运行。

There is no problem if the app is run by Android Studio. Error occurred if the app is generated in APK, install in a device, and then run.

请问有什么解决办法吗?

Is there any solution?

非常感谢你!

<一个href=\"http://stackoverflow.com/questions/25155837/unsatisfiedlinkerror-arcgis-10-2-3-android-arcgisruntime-setclientid\">Similar 答案的问题是行不通的。

Similar question The answer does not work.

推荐答案

您的问题是使用ProGuard。当您部署在发布模式应用中的ProGuard踢和minifies所有的方法/类/变量/等这句话的意思是,如果一个方法曾被称为 DoSomething的(),它会被重命名为类似 A()。这是一件好事,因为当这一切发生在所有code,它使你的code更小,更快。

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

这可能与NDK的工作出了问题,因为本机库与Java方法的通信方式是通过反射,这需要命名的一致性(方法是通过文本名称找到。如果名称的变化,该方法无法找到)。

This can be a problem with working with the NDK, because the way a native library communicates with Java methods is via reflection, which requires naming consistency (methods are found by textual name. If the name changes, the method cannot be found).

您可以通过编辑您的ProGuard文件以排除某些类别的解决这个问题。

You can overcome this issue by editing your ProGuard file to exclude certain classes.

例如,你的情况,我想补充下面一行在你的ProGuard文件:

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

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

其实,你可以让这条规则更加具体,只排除问题的方法:

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

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

ProGuard的是pretty强大,当谈到决定其中code的部分缩小的或没有,所以我建议的就可以读了。

有可能,有哪些需要从ProGuard的以类似的方式排除其他类,因此,如果您继续添加此修复程序后,得到类似的错误,只需添加更多的ProGuard的规则,这取决于哪些方法/类不被找到。

It is possible that there are other classes which need to be excluded from ProGuard in a similar way, so if you continue getting similar errors after adding this fix, simply add more ProGuard rules, depending on which methods / classes are not being found.

编辑:

根据你得到新的错误,似乎ProGuard的重构注释,这可能很可能是你的新的错误的原因。添加下面的标记来排除注释:

According to the new error you're getting, it seems proguard is refactoring annotations and this may likely be the cause of your new error. Add the following flag to exclude annotations:

-keepattributes *Annotation*

编辑2:

根据这个博客有关迁移项目在ESRI的网站 Android的工作室,他们似乎还没有找到办法克服的ProGuard问题本身,因为他们建议设置 enableMinify 。这可能意味着要么是ESRI的包根本不缩小工作在这个时候,或者说,他们在搞清楚如何解决这个问题还没有投资时间。

According to this blog about migrating projects to Android studio in the Esri website, it seems that they have not yet found a way to overcome ProGuard issues themselves, as they recommend to set enableMinify to false. This could mean either that the Esri package simply does not working with minification at this time, or that they are haven't invested time in figuring out how to solve the issue.

这篇关于的UnsatisfiedLinkError(com.esri.core.runtime.LicenseImpl.nativeIsClientIdValid)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆