java.lang.NoSuchFieldError:PUBLIC_ONLY在使用已签名版本的android中的Box api时

时间:2014-11-28 07:57:56

标签: java android eclipse boxapiv2

我开发了包含Dropbox,Google驱动器和Box云服务的Android应用程序。我测试了它,一切正常。之后我签了它,我意识到调试apk大小是8.5MB而签名的apk大小是7MB。我测试了完整的应用程序,其中一切正常,除了Box云功能。我得到以下异常

        11-28 12:51:14.129: E/AndroidRuntime(2702): FATAL EXCEPTION: main
    11-28 12:51:14.129: E/AndroidRuntime(2702): Process: com.idealtech.mycoud, PID: 2702
    11-28 12:51:14.129: E/AndroidRuntime(2702): java.lang.NoSuchFieldError: PUBLIC_ONLY
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at java.lang.Class.getDeclaredAnnotation(Native Method)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at java.lang.Class.getAnnotation(Class.java:290)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at com.b.a.c.f.ae.<clinit>(Unknown Source)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at com.b.a.c.z.<clinit>(Unknown Source)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at com.box.boxjavalibv2.jsonparsing.BoxJSONParser.<init>(Unknown Source)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at com.box.boxjavalibv2.BoxClient.a(Unknown Source)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at com.box.boxjavalibv2.BoxClient.<init>(Unknown Source)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at com.box.boxjavalibv2.BoxClient.<init>(Unknown Source)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at com.box.boxandroidlibv2.BoxAndroidClient.<init>(Unknown Source)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at com.box.boxandroidlibv2.activities.OAuthActivity.a(Unknown Source)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at com.box.boxandroidlibv2.activities.OAuthActivity.a(Unknown Source)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at com.box.boxandroidlibv2.activities.OAuthActivity.onCreate(Unknown Source)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at android.app.Activity.performCreate(Activity.java:5248)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at android.app.ActivityThread.access$800(ActivityThread.java:139)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at android.os.Handler.dispatchMessage(Handler.java:102)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at android.os.Looper.loop(Looper.java:136)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at android.app.ActivityThread.main(ActivityThread.java:5086)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at java.lang.reflect.Method.invokeNative(Native Method)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at java.lang.reflect.Method.invoke(Method.java:515)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
    11-28 12:51:14.129: E/AndroidRuntime(2702):     at dalvik.system.NativeStart.main(Native Method)

它没有获得它在debug中找到的库。我该怎么做才能解决这个问题? 请帮我。由于这个问题我无法发布我的应用程序。 提前谢谢。

1 个答案:

答案 0 :(得分:16)

由于jackson库在使用proguard进行编译时我得到了这个问题,我通过在proguard文件中添加以下行来修复它。

-keepnames class com.fasterxml.jackson.** { 
*; 
}
-keepnames interface com.fasterxml.jackson.** { 
    *; 
}