我刚刚完成我的申请,我正在尝试使用 Unity Ads 转换广告。 我去了"file",“导入模块”。 接下来,我转到"file"、“结构项目”,单击我的主模块,然后转到右侧的依赖项选项卡,单击 + 和 3.Module 依赖项,然后选择我的主模块 模块取决于。现在代码没问题了。 但是当我测试我的应用程序时,成绩构建向我显示: :unityads:compileReleaseJava :unityads:proguardRelease 注意:有 1 个重复的类定义。(http://proguard.sourceforge.net/manual/ troubleshooting.html#duplicateclass) :unityads:proguardRelease失败 错误:任务 ':unityads:proguardRelease' 执行失败。
java.io.IOException: Can't write [/Users/Appli/AndroidStudioProjects/The33/unityads/build/ intermediates/bundles/release/classes.jar] (Can't read [/Users/Appli/AndroidStudioProjects/The33/ unityads/libs/unity-ads.jar(;;;;;;!META-INF/MANIFEST.MF)] (Duplicate zip entry [unity-ads.jar:com/ unity3d/ads/android/BuildConfig.class])) The Gradle build script for my core project:
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')
}
我不知道我应该做什么。
最佳答案
问题的原因是Unity Ads JAR包含BuildConfig类,该类也是在构建过程中生成的。解决方案是使用 AAR 而不是 JAR 导入模块。
- 删除现有的 Unity Ads 模块("file"->“项目结构”)。
- 下载 Unity 广告 SDK。
- 从“unity-ads.aar”创建一个模块("file"->“新建”->“新建模块”->“导入 JAR/AAR 包”)。
关于java - 复制 BuildConfig 在 Android Studio 中集成 Unity Ads,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30486096/