1

我正在我的 Android 应用程序 Wallpaper Saver 中实现 Dropbox Sync API。当我从 Eclipse 以调试模式运行它时它可以工作,但是当我导出它并通过 proguard 运行它时,它会抛出以下异常:

08-25 23:09:52.833: E/AndroidRuntime(32148): FATAL EXCEPTION: main
08-25 23:09:52.833: E/AndroidRuntime(32148): java.lang.ExceptionInInitializerError
08-25 23:09:52.833: E/AndroidRuntime(32148):    at com.dropbox.sync.android.a.a(Unknown Source)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at com.dropbox.sync.android.a.<init>(Unknown Source)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at com.dropbox.sync.android.ad.a(Unknown Source)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at com.dropbox.sync.android.ad.a(Unknown Source)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at dk.alroe.apps.WallpaperSaver.ADropboxConnector.a(Unknown Source)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at dk.alroe.apps.WallpaperSaver.ADropboxConnector.onCreate(Unknown Source)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at android.app.Activity.performCreate(Activity.java:5104)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2261)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2357)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at android.app.ActivityThread.access$600(ActivityThread.java:153)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at android.os.Handler.dispatchMessage(Handler.java:99)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at android.os.Looper.loop(Looper.java:137)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at android.app.ActivityThread.main(ActivityThread.java:5226)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at java.lang.reflect.Method.invokeNative(Native Method)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at java.lang.reflect.Method.invoke(Method.java:511)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at dalvik.system.NativeStart.main(Native Method)
08-25 23:09:52.833: E/AndroidRuntime(32148): Caused by: java.lang.ExceptionInInitializerError
08-25 23:09:52.833: E/AndroidRuntime(32148):    at com.dropbox.sync.android.NativeLib.<init>(Unknown Source)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at com.dropbox.sync.android.NativeLib.<clinit>(Unknown Source)
08-25 23:09:52.833: E/AndroidRuntime(32148):    ... 20 more
08-25 23:09:52.833: E/AndroidRuntime(32148): Caused by: java.lang.NoSuchMethodError: no method with name='<init>' signature='(Lcom/dropbox/sync/android/NativeEnv;)V' in class Lcom/dropbox/sync/android/NativeHttp;
08-25 23:09:52.833: E/AndroidRuntime(32148):    at com.dropbox.sync.android.NativeHttp.nativeClassInit(Native Method)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at com.dropbox.sync.android.NativeHttp.nativeClassInit(Native Method)
08-25 23:09:52.833: E/AndroidRuntime(32148):    at com.dropbox.sync.android.NativeHttp.<clinit>(Unknown Source)

据我了解,Proguard 删除了太多。如何阻止 Proguard 吃 Dropbox jar 中的方法?

4

1 回答 1

4

在我的 proguard 文件中添加以下行解决了问题

    -keep class com.dropbox.** {*;}

感谢 A--C 为我指明了正确的方向!

于 2013-08-27T06:35:28.430 回答