我试图在我的游戏中实现 GameAnalytics 插件。另外,我正在使用 AdInCube 插件,它工作正常,但现在我每次在构建过程中都会出错。当我尝试实现 Google Play Services 插件时,我收到了完全相同的错误。导入新包后出现问题,代码没有任何更改。我尝试从两个插件中使用 AndroidManifests,但我还是收到了这个错误。
错误:
CommandInvokationFailure: Gradle build failed.
C:/Program Files/Java/jdk1.8.0_191\bin\java.exe -classpath "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.2.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx2048m" "assembleRelease"
stderr[
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/api/signin/GoogleSignInAccount.class
我发现 Unity 在构建过程中创建了两个相同的文件夹,因此不知道使用哪个文件夹。我不能只删除其中一个,因为它将立即重新创建。我不知道您需要哪些文件来帮助我,所以现在就添加这个。
来自 AdInCube 的 MainTemplate.gradle:
buildscript {
repositories {
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
flatDir {
dirs 'libs'
}
}
}
apply plugin: 'com.android.application'
repositories {
maven {
url 'https://maven.google.com'
}
maven {
url 'http://repository.adincube.com/maven'
}
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.adincube.sdk:AdinCube-Unity-3626ebe:2.3.1@aar') {
transitive = true
}
compile 'com.android.support:multidex:1.0.1'
**DEPS**
}
android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
defaultConfig {
targetSdkVersion '28'
minSdkVersion 14
multiDexEnabled true
}
lintOptions {
abortOnError false
}
aaptOptions {
noCompress '.unity3d', '.ress', '.resource', '.obb'
}
**SIGN**
buildTypes {
debug {
minifyEnabled **MINIFY_DEBUG**
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
jniDebuggable true
}
release {
minifyEnabled **MINIFY_RELEASE**
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
**SIGNCONFIG**
}
}
packagingOptions {
exclude 'lib/armeabi/libadcolony.so'
exclude 'lib/armeabi/libjs.so'
exclude 'lib/arm64-v8a/libadcolony.so'
exclude 'lib/arm64-v8a/libjs.so'
exclude 'lib/x86_64/libadcolony.so'
exclude 'lib/x86_64/libjs.so'
}
}
dependencies {
compile ('com.adincube.sdk:AdinCube-Unity-3626ebe:2.+@aar') {
transitive = true
}
compile 'com.android.support:multidex:1.0.1'
}
repositories {
maven {
url 'https://maven.google.com'
}
maven {
url 'http://repository.adincube.com/maven'
}
jcenter()
}
android {
defaultConfig {
multiDexEnabled true
}
}
android {
packagingOptions {
exclude 'lib/armeabi/libadcolony.so'
exclude 'lib/armeabi/libjs.so'
exclude 'lib/arm64-v8a/libadcolony.so'
exclude 'lib/arm64-v8a/libjs.so'
exclude 'lib/x86_64/libadcolony.so'
exclude 'lib/x86_64/libjs.so'
}
}
来自 AdInCube 的 AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="games.****.block"
android:installLocation="preferExternal"
android:versionCode="2"
android:versionName="1.1.1">
<uses-permission android:name="com.android.vending.BILLING" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<application
android:name="android.support.multidex.MultiDexApplication"
android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:theme="@style/UnityThemeSelector">
<activity
android:name="com.unity3d.player.UnityPlayerActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="unityplayer.UnityActivity"
android:value="true" />
</activity>
</application>
</manifest>