Phonegap 2.4 Android Proguard config

妖精的绣舞 提交于 2019-12-05 23:59:27

问题


I've upgraded a build from Phonegap (Cordova) 2.0 to 2.4 and everything was working fine in dev until I actually came to testing the final release apk. What I'm finding, after a lot of time wasted, is that for some reason now when I run the build my proguard config is breaking the phonegap build in some way that means that when it runs the deviceready is never called. There seem to be no errors when building, nor running and nothing as far as I can see but I'm guessing something is silently failing in the cordova js as i'm not getting compile / log errors on the device.

As I say this is ONLY when having ran the Proguard obfs in the build process. If i turn off Proguard it all works fine. I reverted all my code back to 2.0 to be sure and that is all fine so somewhere along the way there has been a stuble change that is seemingly not documented / or nobody has hit just yet (2.4 only came out a few weeks ago - at time of writing 26th feb 2013).

My Proguard config contains the following for phonegap (as well as some other standard config)

-keep public class * extends com.phonegap.api.Plugin
-keep public class * extends org.apache.cordova.api.Plugin
-keep public class org.apache.cordova.DroidGap
-keep public class org.apache.cordova.**
-keep public class org.apache.**
-dontwarn android.webkit.*
-dontwarn org.apache.**

and decompiling the dex doesn't seem to throw any light - everything looks ok at a glance...

Anyone have any ideas???


回答1:


Try replacing the Cordova "keep" settings in your proguard-project.txt with the following line, which should maintain all Cordova classes, fields, and methods, both public and private (and thus reenable deviceready):

-keep class org.apache.cordova.** { *; }

Then you just need to include your class(es) (presumably extending CordovaPlugin, not just Plugin) e.g.

pre-v3:

-keep public class * extends org.apache.cordova.api.CordovaPlugin

v3+:

-keep public class * extends org.apache.cordova.CordovaPlugin



回答2:


Phonegap Plugins are being excluded from the final APK I guess. Cordova.js probably doesn't even exist to give errors.



来源:https://stackoverflow.com/questions/15087491/phonegap-2-4-android-proguard-config

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!