2012-10-26 38 views
3

签名的应用程序给出错误!使用外部Admob jar的Proguard运行时错误

我的应用程序使用外部AdMob联播罐子,但是proguard的被触摸的jar:

的jar文件位于/libs/GoogleAdMobAdsSdk-6.2.1.jar

谢谢

logcat的错误:

Proguard returned with error code 1. See console 
Warning: com.google.ads.m: can't find referenced class 
com.google.ads.internal.state.AdState 
Warning: com.google.ads.m: can't find referenced class com.google.ads.internal.state.AdState 
    You should check if you need to specify additional program jars. 
Warning: there were 2 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) 

这是JAR文件内

配置ProGuard的-project.txt:

加入

-keep public class com.google.ads.** 

到文件后

-libraryjars /libs/GoogleAdMobAdsSdk-6.2.1.jar 

-dontpreverify 
-repackageclasses '' 
-allowaccessmodification 
-optimizations !code/simplification/arithmetic 
-keepattributes *Annotation* 

-keep public class * extends android.app.Activity 
-keep public class * extends android.app.Application 
-keep public class * extends android.app.Service 
-keep public class * extends android.content.BroadcastReceiver 
-keep public class * extends android.content.ContentProvider 

-keep public class * extends android.view.View { 
public <init>(android.content.Context); 
public <init>(android.content.Context, android.util.AttributeSet); 
public <init>(android.content.Context, android.util.AttributeSet, int); 
public void set*(...); 
} 

-keepclasseswithmembers class * { 
public <init>(android.content.Context, android.util.AttributeSet); 
} 

-keepclasseswithmembers class * { 
public <init>(android.content.Context, android.util.AttributeSet, int); 
} 

-keepclassmembers class * extends android.content.Context { 
public void *(android.view.View); 
public void *(android.view.MenuItem); 
} 

-keepclassmembers class * implements android.os.Parcelable { 
static android.os.Parcelable$Creator CREATOR; 
} 

-keepclassmembers class **.R$* { 
public static <fields>; 
} 

,月食控制台,仍然出现以下错误:

Proguard returned with error code 1. See console 
Note: there were 160 duplicate class definitions. 
Warning: com.google.ads.m: can't find referenced class  
com.google.ads.internal.state.AdState 
Warning: com.google.ads.m: can't find referenced class  
com.google.ads.internal.state.AdState 
You should check if you need to specify additional program jars. 
Warning: there were 2 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) 
+1

没有人可以帮助我吗? – user1616685

+1

http://stackoverflow.com/questions/13040226/progaurd-returned-with-error-code-1 –

+1

感谢您的评论。但这不适用于例如Dropbox Sdkor其他外部罐子。这些会被proguard触碰或改变 – user1616685

回答

8

我刚刚添加的

-dontwarn com.google.ads.** 

to the proguard- project.txt文件和签名apk工作正常! 这个建议(如埃里克以前说的)位置:Proguard can't find referenced class com.google.ads.internal.state.AdState

+0

,这对我来说真的很有用。我也按照Eric Leichtenschlag 11月2日在16:55评论的说法添加了内容。感谢你们俩.. –

+0

此代码签署了应用程序,但admob广告确实出现并给了classnotfoundexception,但@peterdk代码为我工作。 – Piyush

4

这个工作对我的看来你需要这2个项目添加到ProGuard配置文件:

-dontwarn com.google.ads.** 
-keep class com.google.ads.** {*;} 
0

-dontwarn com.google。广告。** 此处安全广告类 如果您想保护您的课程,然后添加com.pkgname。**