【问题标题】:Configuring ProGuard for android-eclipse project with multiple jars为具有多个 jar 的 android-eclipse 项目配置 ProGuard
【发布时间】:2014-01-10 21:58:17
【问题描述】:

我想在我的 android 应用程序中使用 ProGuard,但我遇到了一些问题。当我通过 android 工具(在 eclipse 中)构建未签名的 apk 时,出现以下错误:

Warning: com.millennialmedia.android.NVASpeechKit$7: can't find referenced class com.nuance.nmdp.speechkit.Recognizer
[...] //more warnings of the same type as above
You should check if you need to specify additional program jars.
Warning: there were 170 unresolved references to classes or interfaces.
You may need to specify additional library jars (using '-libraryjars').
java.io.IOException: Please correct the above warnings first.
at proguard.Initializer.execute(Initializer.java:321)
at proguard.ProGuard.initialize(ProGuard.java:211)
at proguard.ProGuard.execute(ProGuard.java:86)
at proguard.ProGuard.main(ProGuard.java:492)

我在我的应用程序中使用了 5 个 jar 文件,它们都位于 libs 文件夹中并被添加到构建路径中(因此它们可能再次出现在“引用库”和“Android 私有库”中)。另外,我在 libs/armeabi 中放了一个 so-library...

My proguard - file look pretty normal, yet:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontpreverify
-dontskipnonpubliclibraryclasses
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-assumenosideeffects class android.util.Log {
    public static *** d(...);
    public static *** e(...);
}

我应该怎么做才能修复这个错误?

问候

PS:我知道 proguard 可以删除/更改一些重要的东西(比如类文件,..)。那么,我会在启动我的应用程序时立即通过异常注意到此类“错误”,还是我必须检查每个细节并在运行时导航到我的应用程序的任何部分以确保它按应有的方式运行?

编辑: 我正在使用以下罐子:

alljoyn.jar(在链接到 alljoyn-sdk 的资源中还有一个路径变量)

peergroupmanager.jar

android-support-v4.jar

MMSDK.jar

GoogleAdMobAdsSdk-6.4.1.jar

【问题讨论】:

  • 您能否确认您正在使用 Android SDK proguard 配置?如 project.properties 文件中所述> proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt: proguard-project.txt。根据过去的经验,您可能必须为某些 3rd 方库添加一些自定义排除项,您能列出它们吗?
  • 那在我的 project.properties proguard.config=C:/Android SDK/tools/proguard/proguard-android.txt:proguard-project.txt 因为库我编辑了问题

标签: java android jar proguard


【解决方案1】:

来自http://docs.millennialmedia.com/android-SDK/AndroidFAQ.html

我在我的 Android 应用程序中使用 ProGuard,我应该怎么做才能确保我的 Millennial 广告仍然有效?

为确保您在使用 ProGuard 时仍能收到广告,请将以下 sn-p 添加到您的 proguard.cfg 文件中。

-keepclassmembers class com.millennialmedia.android.* { 
public *; 
} 
-keep class com.millennialmedia.android.**

当使用 ProGuard 而不是 SpeechKit 时,将以下行添加到他们的 proguard-project.txt:

-dontwarn com.millennialmedia.android.NVASpeechKit*

【讨论】:

  • 请提出另一个问题。
猜你喜欢
  • 1970-01-01
  • 2015-08-11
  • 2021-12-29
  • 1970-01-01
  • 2010-11-26
  • 2012-07-02
  • 1970-01-01
  • 1970-01-01
  • 2010-11-24
相关资源
最近更新 更多