因此,我们已经到了 Android 游戏开发的最后阶段,是时候对 Proguard 进行一些混淆了。
我们的游戏使用 Greystripe 广告,编译调试版本时一切正常,针对 API 7。
但是在编译发布版本时(在过程中添加了 Proguard),有很多警告:
Warning: com.greystripe.sdk.DeviceInfo: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.DeviceInfo: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.DeviceInfo: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.DeviceInfo: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.DeviceInfo: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.DeviceInfo: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.DeviceInfo: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.DeviceInfo: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.DeviceInfo: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.DeviceInfo: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.DeviceInfo: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.DeviceInfo: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.DeviceInfo: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.GSFullscreenActivity: can't find referenced class android.hardware.Camera$CameraInfo
Warning: com.greystripe.sdk.GSFullscreenActivity: can't find referenced class android.hardware.Camera$CameraInfo
Warning: com.greystripe.sdk.GSFullscreenActivity: can't find referenced method 'void getCameraInfo(int,android.hardware.Camera$CameraInfo)' in class android.hardware.Camera
Warning: com.greystripe.sdk.GSFullscreenActivity: can't find referenced method 'int getNumberOfCameras()' in class android.hardware.Camera
Warning: com.greystripe.sdk.GSFullscreenActivity: can't find referenced method 'android.hardware.Camera open(int)' in class android.hardware.Camera
Warning: com.greystripe.sdk.GSFullscreenActivity: can't find referenced method 'void setDisplayOrientation(int)' in class android.hardware.Camera
Warning: com.greystripe.sdk.GSFullscreenActivity: can't find referenced class android.hardware.Camera$CameraInfo
Warning: com.greystripe.sdk.GSFullscreenActivity: can't find referenced method 'void setLayerType(int,android.graphics.Paint)' in class com.greystripe.sdk.aa
Warning: com.greystripe.sdk.a: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.a: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.ah: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.aj: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.aj: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.aj: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.as: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.as: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.as: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.as: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.as: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.at: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.at: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.bd: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.be: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.be: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.be: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.be: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.be: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.be: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.bh: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.bh: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.bl: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.bl: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.bl: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.bl: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.bl: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.m: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.m: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.m: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.m: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.m: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.m: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.m: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.m: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.m: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.s: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.s: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.w: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.w: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.w: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.w: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.w: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.w: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.w: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.w: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.w: can't find referenced class android.webkit.JavascriptInterface
Warning: com.greystripe.sdk.w: can't find referenced class android.webkit.JavascriptInterface
Warning: there were 64 unresolved references to classes or interfaces.
You may need to specify additional library jars (using '-libraryjars').
Warning: there were 5 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile them and try again.
Alternatively, you may have to specify the option
'-dontskipnonpubliclibraryclassmembers'.
所以很明显我开始尝试很多不同的变化-keep class
等等-keep public class
,但没有任何效果。然后我开始大量使用谷歌搜索,发现大量论坛帖子中人们都有同样的问题,我尝试了人们回复的所有建议。还是没有变化。
然后我查看了android.jar,发现android.webkit.JavascriptInterface
在API 17之前没有引入,然后它当然是有道理的。因为我的目标是 API 7,所以自然没有android.webkit.JavascriptInterface
可用的。
但我不想仅仅因为广告而定位 API 17,而且我很确定我也不应该这样做。
从逻辑上讲,我认为我应该能够做到-dontwarn
,但这样做会导致应用程序在加载时崩溃。
我当然确保我放了-libraryjars /path/to/libs/greystripe-android-sdk-2.3.0.jar
而且/path/to/android.jar
有人对此有任何线索吗?如何混淆我的应用程序,同时不理会 graystripe-sdk jar?