Mobclix 和 Proguard

发布于 2024-11-29 06:44:05 字数 3979 浏览 1 评论 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>;
}

我还应该做些什么吗?感谢一百万

I'm trying to use Proguard to obfuscate my code. I use Mobclix for advertisements, and when I build my APK it's spitting out an error:

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

Now, I have put the Mobclix recommended bits from their documentation into my 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>;
}

Anything else I should be doing? Thanks a million

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

缺⑴份安定 2024-12-06 06:44:05

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

看起来 Entity 类已经在 Android SDK 7 中引入了,所以我假设您正在针对较旧的 SDK 进行构建。再次假设尽管缺少这个类,您的代码仍能正常运行,您可以让 ProGuard 接受有些不一致的输入,并

-dontwarn android.content.Entity*

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

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

The messages explain that some Mobclix classes (like com.mobclix.android.sdk.MobclixContactsCursorEntityIterator) depend on Android runtime classes (like android.content.Entity) that are not present in your input jars or library jars. In general, that could be a sign of serious problems: if that part of the code is ever executed, it will fail with NoClassDefFoundError (even without obfuscation).

It looks like the Entity class has been introduced in Android SDK 7, so I presume that you are building against an older SDK. Again assuming that your code runs fine in spite of this missing class, you can let ProGuard accept the somewhat inconsistent input with

-dontwarn android.content.Entity*

Note that -keep options don't come into play here. ProGuard performs the consistency checks before considering any -keep options.

Also see ProGuard manual > Troubleshooting > Warning: can't find referenced class

我喜欢麦丽素 2024-12-06 06:44:05

也许更改

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

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

Maybe change

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

to

-keep public class com.mobclix.android.sdk.**
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文