【问题标题】:ProGuard causing error in MoPub Integration - AndroidStudioProGuard 在 MoPub 集成中导致错误 - AndroidStudio
【发布时间】:2014-12-24 10:02:41
【问题描述】:

我在 build.gradle(mopub-sdk) 文件中添加了这个

buildTypes {
        release {
            runProguard true;
            proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard.txt')
        }
 }

我的 proguard.txt 文件是

# Keep public classes and methods.
-keepclassmembers class com.mopub.** { public *; }
-keep public class com.mopub.**
-keep class com.mopub.mobileads.**{*;}
-keep public class com.mopub.mobileads.MoPubInterstitial
-keep public class com.mopub.mobileads.MoPubView
-keep public class android.webkit.JavascriptInterface {}

# Keep interfaces
-keep interface com.mopub.mobileads.MoPubInterstitial.InterstitialAdListener
-keep interface com.mopub.mobileads.MoPubView.BannerAdListener


# Explicitly keep any custom event classes in any package.
-keep class * extends com.mopub.mobileads.CustomEventBanner {}
-keep class * extends com.mopub.mobileads.CustomEventInterstitial {}
-keep class * extends com.mopub.nativeads.CustomEventNative {}

# Support for Android Advertiser ID.
-keep class com.google.android.gms.common.GooglePlayServicesUtil {*;}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {*;}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {*;}

但是在构建时,我得到了这个错误:

Error:(33, 45) error: cannot find symbol class InterstitialAdListener
Error:(35, 37) error: cannot find symbol class BannerAdListener

还有其他一些,但大多数都与上述两个有关。这里有什么问题?

【问题讨论】:

  • 我的 gradle 插件版本是 0.13
  • 请查看我更新的答案。如果不工作,让我通知。
  • 嗨,好的..我会尝试并发布回复。
  • 嗨,我收到以下错误:Gradle build 在 1 sec 内完成了 1 个错误 6:20:40 PM UnsupportedMethodException 无法在项目“xxxxx”中设置 Android 模块:不支持的方法: SourceProvider.getJniDirectories()。您连接的 Gradle 版本不支持该方法。要解决此问题,您可以更改/升级您连接到的 Gradle 目标版本。或者,您可以忽略此异常并从模型中读取其他信息。
  • 更新类路径 'com.android.tools.build:gradle:0.13.+' this .你的逻辑是正确的。 .14+ 不支持

标签: android android-studio proguard mopub


【解决方案1】:

如果您使用的是 0.14.0 或更高版本的 gradle 插件,您应该在 build.gradle 文件中将“runProguard”替换为“minifyEnabled”。 p>

minifyEnabled false 表示构建类型名称不能是 main 或 androidTest(这是由插件强制执行的),并且它们必须彼此唯一。

只需更新一下:

 buildTypes {           
     release {
                    minifyEnabled false
                    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
                }
            }

并更新您的类路径

classpath 'com.android.tools.build:gradle:0.13.+'

【讨论】:

  • 嗨,即使更新了studio和sdk,并将runProguard更改为minifyEnabled,错误仍然存​​在
猜你喜欢
  • 1970-01-01
  • 2018-07-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-01
  • 2017-10-16
相关资源
最近更新 更多