Android项目:导出问题启动已取消! Proguard返回错误代码1.请参阅控制台

时间:2013-04-05 13:08:31

标签: android export warnings apk proguard

我在project.prperties

中的下面一行未注释
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

工作进展并且工作正常。

但是当我添加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.** {*;}

2 个答案:

答案 0 :(得分:17)

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

-dontwarn com.google.android.gms.*
-ignorewarnings 

答案 1 :(得分:1)

虽然我不想关闭警告,但我需要使用-dontwarn这样:

-dontwarn com.google.android.gms.**