9

我在 project.prperties 中取消了以下行的注释

proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

工作progard,它工作正常。

但是当我添加 android-support-v4.jar 库时,导出签名的应用程序项目时出错

Launch canceled!
 Proguard returned with error code 1. See console
 Note: there were 316 duplicate class definitions.
 Warning: com.google.android.gms.common.images.ImageManager$a: can't find superclass or interface android.content.ComponentCallbacks2
 Warning: com.google.android.gms.maps.MapFragment: can't find superclass or interface android.app.Fragment
 Warning: com.google.android.gms.common.GooglePlayServicesUtil: can't find referenced field 'int smallestScreenWidthDp' in class android.content.res.Configuration
 Warning: com.google.android.gms.common.images.ImageManager: can't find referenced method 'void registerComponentCallbacks(android.content.ComponentCallbacks)' in class android.content.Context
 Warning: com.google.android.gms.common.images.ImageManager$a: can't find referenced class android.content.ComponentCallbacks2
 Warning: com.google.android.gms.maps.MapFragment: can't find referenced class android.app.Fragment
 Warning: com.google.android.gms.maps.MapFragment: can't find referenced class android.app.Fragment
 Warning: com.google.android.gms.maps.MapFragment: can't find referenced class android.app.Fragment
 Warning: com.google.android.gms.maps.MapFragment: can't find referenced class android.app.Fragment
 Warning: com.google.android.gms.maps.MapFragment: can't find referenced class android.app.Fragment
 Warning: com.google.android.gms.maps.MapFragment: can't find referenced class android.app.Fragment
 Warning: com.google.android.gms.maps.MapFragment: can't find referenced class android.app.Fragment
 Warning: com.google.android.gms.maps.MapFragment: can't find referenced class android.app.Fragment
 Warning: com.google.android.gms.maps.MapFragment: can't find referenced class android.app.Fragment
 Warning: com.google.android.gms.maps.MapFragment: can't find referenced class android.app.Fragment
 Warning: com.google.android.gms.maps.MapFragment: can't find referenced class android.app.Fragment
 Warning: com.google.android.gms.maps.MapFragment: can't find referenced class android.app.Fragment
 Warning: com.google.android.gms.maps.MapFragment$a: can't find referenced class android.app.Fragment
 Warning: com.google.android.gms.maps.MapFragment$a: can't find referenced class android.app.Fragment
 Warning: com.google.android.gms.maps.MapFragment$b: can't find referenced class android.app.Fragment
 Warning: com.google.android.gms.maps.MapFragment$b: can't find referenced class android.app.Fragment
 Warning: com.google.android.gms.maps.MapFragment$b: can't find referenced class android.app.Fragment
 Warning: com.google.android.gms.maps.MapFragment$b: can't find referenced class android.app.Fragment
   You should check if you need to specify additional program jars.
 Warning: there were 21 unresolved references to classes or interfaces.
      You may need to specify additional library jars (using '-libraryjars').
 Warning: there were 2 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'.
 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)

我尝试将以下行添加到 proguard-project.txt 但它不起作用

-dontwarn android.support.**
-dontwarn com.google.ads.**
-libraryjars libs/android-support-v4.jar
-keep public class * extends com.phonegap.api.Plugin 
-keep public class org.apache.cordova.DroidGap 
-keep public class org.apache.cordova.** 
-dontwarn android.webkit.*
-dontwarn org.apache.**
-dontwarn  android.support.v7.widget.**
-keep class android.support.v7.widget.** { *; }
-dontwarn com.google.ads.** -keep class com.google.ads.** {*;}
-keep class com.google.android.gms.analytics.**
-keep class com.google.analytics.tracking.**
-dontwarn com.google.android.gms.analytics.**
-dontwarn com.google.analytics.tracking.**
-keep class com.google.ads.**  { *; }
-dontwarn com.google.ads.**
-keep public class com.admob.android.ads.** {*;}
4

2 回答 2

17

我自己找到了答案。在 proguard-project.txt 文件中添加以下 2 行解决了该问题。

-dontwarn com.google.android.gms.*
-ignorewarnings 
于 2013-04-10T07:20:33.783 回答
1

虽然我不喜欢关闭警告,但我需要以这种方式使用 -dontwarn:

-dontwarn com.google.android.gms.**
于 2014-02-03T14:29:52.530 回答