为具有多个jar的android-eclipse项目配置ProGuard

时间:2014-01-10 21:58:17

标签: java android jar proguard nativelibrary

我想将ProGuard用于我的Android应用程序,但我遇到了一些麻烦。当我通过android工具(在eclipse中)构建一个unsigned 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文件夹中并添加到构建路径中(因此它们可以再次出现在'Referenced Libraries'以及'Android Private Libraries'中)。另外,我在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可以删除/更改一些重要的东西(比如class-files,..)。那么,在启动我的应用程序时,我是否会立即注意到例外的“错误”,或者我是否必须检查每个细节并在运行时导航到我的应用程序的任何部分以确保它按预期运行?

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

alljoyn.jar(在alljoyn-sdk的链接资源中也存在路径变量)

peergroupmanager.jar

机器人支撑-v4.jar

MMSDK.jar

GoogleAdMobAdsSdk-6.4.1.jar

1 个答案:

答案 0 :(得分:2)

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

我在Android应用程序中使用ProGuard,我该怎么做才能确保我的千禧一代广告仍在使用?

要确保在使用ProGuard时仍然收到广告,请将以下代码段添加到proguard.cfg文件中。

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

使用ProGuard而非SpeechKit时,请在proguard-project.txt中添加以下行:

-dontwarn com.millennialmedia.android.NVASpeechKit*