【问题标题】:Duplicate BuildConfig integrating Unity Ads in Android Studio在 Android Studio 中集成 Unity 广告的重复 BuildConfig
【发布时间】:2015-08-09 18:04:57
【问题描述】:

我刚刚完成了我的申请,我正在尝试使用 Unity Ads 投放广告。 我去了“文件”,“导入模块”。 接下来我转到“文件”,“结构项目”,点击我的主模块,然后转到右侧的依赖项选项卡并点击+和3.Module依赖,我选择了我的主模块 模块取决于。现在代码很好。 但是当我测试我的应用程序时,成绩构建显示: :unityads:compileReleaseJava :unityads:proguardRelease 注意:有 1 个重复的类定义。(http://proguard.sourceforge.net/manual/ 故障排除.html#duplicateclass) :unityads:proguardRelease 失败 错误:任务 ':unityads:proguardRelease' 执行失败。

java.io.IOException: 无法写入 [/Users/Appli/AndroidStudioProjects/The33/unityads/build/ intermediates/bundles/release/classes.jar] (无法读取 [/Users/Appli/AndroidStudioProjects/The33/ unityads/libs/unity-ads.jar(;;;;;;!META-INF/MANIFEST.MF)](重复的 zip 条目 [unity-ads.jar:com/ unity3d/ads/android/BuildConfig.class])) 我的核心项目的 Gradle 构建脚本:

apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "studio.pomme.m.the33"
minSdkVersion 8
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':unityads')
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.google.android.gms:play-services-wearable:6.5.87'
}

其中一个库项目的 Gradle 构建脚本:

apply plugin: 'com.android.library'
android {
    compileSdkVersion 21
    buildToolsVersion "19.1.0"
    defaultConfig {}
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        }
    }
}
dependencies {
    compile files('libs/unity-ads.jar')
}

我不知道我应该做什么。

【问题讨论】:

    标签: java android eclipse android-studio ide


    【解决方案1】:

    问题的原因是 Unity Ads JAR 包含 BuildConfig 类,该类也是在构建过程中生成的。解决方案是使用 AAR 而不是 JAR 导入模块。

    1. 删除现有的 Unity 广告模块(“文件”->“项目结构”)。
    2. 下载 Unity 广告 SDK。
    3. 从“unity-ads.aar”(“文件”->“新建”->“新建模块”->“导入 JAR/AAR 包”)创建模块。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-01-19
      • 1970-01-01
      • 2022-01-19
      • 2017-09-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-02
      相关资源
      最近更新 更多