Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 外部Admob jar的Proguard运行时错误大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
签名的应用程序给出错

我的应用程序使用外部Admob jar,但是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:

-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,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>;
}

添加

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

对于该文件,eclipse控制台仍然提供以下错误

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)

解决方法

我刚加了

-dontwarn com.google.ads.**

到proguard-project.txt文件和签名的apk工作正常!
这是推荐的(如之前Eric所说):Proguard can’t find referenced class com.google.ads.internal.state.AdState

大佬总结

以上是大佬教程为你收集整理的android – 外部Admob jar的Proguard运行时错误全部内容,希望文章能够帮你解决android – 外部Admob jar的Proguard运行时错误所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。