0

我正在尝试使用 Proguard 来混淆我的代码。我将 Mobclix 用于广告,当我构建我的 APK 时,它吐出一个错误:

org.eclipse.core.runtime.CoreException: Proguard returned with error code 1. See console
    at com.android.ide.eclipse.adt.internal.project.ExportHelper.exportReleaseApk(ExportHelper.java:228)
    at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.doExport(ExportWizard.java:290)
    at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.access$0(ExportWizard.java:229)
    at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard$1.run(ExportWizard.java:214)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: Proguard Error 1 
Output: 
Warning: com.mobclix.android.sdk.MobclixContactsCursorEntityIterator: can't find referenced class android.content.Entity 
Warning: com.mobclix.android.sdk.MobclixContactsCursorEntityIterator: can't find referenced class android.content.Entity 
Warning: com.mobclix.android.sdk.MobclixContactsSdk5$EntityIteratorImpl: can't find referenced class android.content.Entity 
Warning: com.mobclix.android.sdk.MobclixContactsSdk5$EntityIteratorImpl: can't find referenced class android.content.Entity 
Warning: com.mobclix.android.sdk.MobclixContactsSdk5$EntityIteratorImpl: can't find referenced class android.content.Entity 
Warning: com.mobclix.android.sdk.MobclixContactsSdk5$EntityIteratorImpl: can't find referenced class android.content.Entity 
Warning: com.mobclix.android.sdk.MobclixContactsSdk5$EntityIteratorImpl: can't find referenced class android.content.Entity 
Warning: com.mobclix.android.sdk.MobclixContactsEntityIterator: can't find referenced class android.content.Entity 
Warning: com.mobclix.android.sdk.MobclixContactsSdk5: can't find referenced class android.content.Entity 
Warning: com.mobclix.android.sdk.MobclixContactsSdk5: can't find referenced class android.content.Entity 
Warning: com.mobclix.android.sdk.MobclixContactsSdk5: can't find referenced class android.content.Entity 
Warning: com.mobclix.android.sdk.MobclixContactsSdk5: can't find referenced class android.content.Entity$NamedContentValues 
Warning: com.mobclix.android.sdk.MobclixContactsSdk5: can't find referenced class android.content.Entity$NamedContentValues 
Warning: com.mobclix.android.sdk.MobclixContactsSdk5: can't find referenced class android.content.Entity 
Warning: com.mobclix.android.sdk.MobclixContactsSdk5: can't find referenced class android.content.Entity 
Warning: com.mobclix.android.sdk.MobclixContactsSdk5: can't find referenced class android.content.Entity$NamedContentValues 
Warning: com.mobclix.android.sdk.MobclixContactsSdk5: can't find referenced class android.content.Entity 
      You should check if you need to specify additional program jars. 
Warning: there were 17 unresolved references to classes or interfaces. 
         You may need to specify additional library jars (using '-libraryjars'), 
         or perhaps the '-dontskipnonpubliclibraryclasses' option. 
java.io.IOException: Please correct the above warnings first. 
    at proguard.Initializer.execute(Initializer.java:308) 
    at proguard.ProGuard.initialize(ProGuard.java:210) 
    at proguard.ProGuard.execute(ProGuard.java:85) 
    at proguard.ProGuard.main(ProGuard.java:499)
    at com.android.ide.eclipse.adt.internal.build.BuildHelper.runProguard(BuildHelper.java:527)
    at com.android.ide.eclipse.adt.internal.project.ExportHelper.exportReleaseApk(ExportHelper.java:187)
    ... 4 more

现在,我已将 Mobclix 推荐的文档从他们的文档中放入我的 proguard.cfg 中:

-keep public class com.mobclix.android.sdk.*
-keep class com.mobclix.android.sdk.MobclixJavascriptInterface

-keepclassmembers class com.mobclix.android.sdk.MobclixJavascriptInterface
{
    public void *(...);
    <methods>;
}

-keepclassmembernames class
com.mobclix.android.sdk.MobclixJavascriptInterface {
    public void *(...);
    <methods>;
}

还有什么我应该做的吗?太感谢了

4

2 回答 2

0

也许改变

-keep public class com.mobclix.android.sdk.*

-keep public class com.mobclix.android.sdk.**
于 2011-08-09T22:32:26.710 回答
0

这些消息解释了某些 Mobclix 类(如com.mobclix.android.sdk.MobclixContactsCursorEntityIterator)依赖android.content.Entity于您的输入 jar 或库 jar 中不存在的 Android 运行时类(如 )。一般来说,这可能是严重问题的征兆:如果这部分代码曾经被执行过,它将失败并出现 NoClassDefFoundError(即使没有混淆)。

看起来 Entity 类已在 Android SDK 7 中引入,因此我假设您正在针对较旧的 SDK 进行构建。再次假设您的代码运行良好,尽管缺少这个类,您可以让 ProGuard 接受有点不一致的输入

-dontwarn android.content.Entity*

请注意,-keep 选项在这里不起作用。ProGuard 在考虑任何 -keep 选项之前执行一致性检查。

另请参阅ProGuard 手册> 故障排除 > 警告:找不到引用的类

于 2011-08-15T19:16:56.180 回答