We have a game developed in Unity. Recently i had to upgrade a plugin. Here is where the issues started, since Android now requires you know to upload apps targetting android 31.
Some details:
- Unity 2021.1.28f1
- Android sdk 31
- Gradle 6.1.1 (version Unity supports)
Multiple plugins
- Facebook (15.1.0)
- Firebase Analytics and Messaging (10.3.0)
- Google Mobile Ads Plugin (v7.3.1)
- TheoPlayer (a plugin to show advertisement specifcally for Belgium)
- ConsentManager
The issue lies with Google Mobile Ads and Theoplayer. TheoPlayer requires package com.google.ads.interactivemedia.v3:interactivemedia:3.22.2 this has a file named META-INF/annotation-experimental_release.kotlin_module and the androidx.annotation:annotation-experimental:1.1.0@aar used by Google mobile also has this file, so i constantly get the error when building More than one file was found with OS independent path 'META-INF/annotation-experimental_release.kotlin_module'.
Trying to exclude this file has no effect. I have no idea how to continue, googeling has not helped me neither. Anybody here with more android native coding experience who can help me further? I have attached our gradle file to this post.
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
// Android Resolver Repos Start
([rootProject] (rootProject.subprojects as List)).each { project ->
project.repositories {
def unityProjectPath = path
maven {
url "https://maven.google.com"
}
maven {
url "Assets/GeneratedLocalRepo/Firebase/m2repository" // Assets/Firebase/Editor/AnalyticsDependencies.xml:18, Assets/Firebase/Editor/AppDependencies.xml:22, Assets/Firebase/Editor/MessagingDependencies.xml:22
}
maven {
url "https://maven.google.com/" // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:7, Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:12, Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:17, Assets/THEOplayer/Editor/THEOplayerDependencies.xml:13, Assets/THEOplayer/Editor/THEOplayerDependencies.xml:19
}
maven {
url "path/ Assets/GooglePlayGames/com.google.play.games/Editor/GooglePlayGamesPluginDependencies.xml:11
}
maven {
url "https://s3.amazonaws.com/moat-sdk-builds" // Assets/THEOplayer/Editor/THEOplayerDependencies.xml:7
}
mavenLocal()
mavenCentral()
}
}
// Android Resolver Repos End
apply plugin: 'com.android.library'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'androidx.annotation:annotation-experimental:1.0.0'
// Android Resolver Dependencies Start
implementation 'androidx.ads:ads-identifier:1.0.0-alpha04' // Assets/ConsentManager/Editor/ConsentManagerDependencies.xml:13
implementation 'androidx.appcompat:appcompat:1.2.0' // Assets/ConsentManager/Editor/ConsentManagerDependencies.xml:7
implementation 'androidx.constraintlayout:constraintlayout:2.0.1' // Assets/ConsentManager/Editor/ConsentManagerDependencies.xml:11
implementation 'androidx.lifecycle:lifecycle-common-java8:2.4.1' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:12
implementation 'androidx.lifecycle:lifecycle-process:2.4.1' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:17
implementation 'com.android.support:appcompat-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
implementation 'com.android.support:cardview-v7:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
implementation 'com.android.support:customtabs:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
implementation 'com.android.support:support-annotations:28.0.0' // Assets/ConsentManager/Editor/ConsentManagerDependencies.xml:12
implementation 'com.android.support:support-v4:25.3.1' // Facebook.Unity.Editor.AndroidSupportLibraryResolver.addSupportLibraryDependency
implementation 'com.facebook.android:facebook-applinks:[15.1,16)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:6
implementation 'com.facebook.android:facebook-core:[15.1,16)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:5
implementation 'com.facebook.android:facebook-gamingservices:[15.1,16)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:9
implementation 'com.facebook.android:facebook-login:[15.1,16)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:7
implementation 'com.facebook.android:facebook-share:[15.1,16)' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:8
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.22.2' // Assets/THEOplayer/Editor/THEOplayerDependencies.xml:13
implementation 'com.google.android.gms:play-services-ads:21.4.0' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:7
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.1' // Assets/THEOplayer/Editor/THEOplayerDependencies.xml:19
implementation 'com.google.android.gms:play-services-base:18.1.0' // Assets/Firebase/Editor/AppDependencies.xml:17
implementation 'com.google.code.gson:gson:2.8.6' // Assets/ConsentManager/Editor/ConsentManagerDependencies.xml:9
implementation 'com.google.firebase:firebase-analytics:21.2.0' // Assets/Firebase/Editor/MessagingDependencies.xml:15
implementation 'com.google.firebase:firebase-analytics-unity:10.3.0' // Assets/Firebase/Editor/AnalyticsDependencies.xml:18
implementation 'com.google.firebase:firebase-app-unity:10.3.0' // Assets/Firebase/Editor/AppDependencies.xml:22
implementation 'com.google.firebase:firebase-common:20.2.0' // Assets/Firebase/Editor/AppDependencies.xml:13
implementation 'com.google.firebase:firebase-iid:21.1.0' // Assets/Firebase/Editor/MessagingDependencies.xml:17
implementation 'com.google.firebase:firebase-messaging:23.1.1' // Assets/Firebase/Editor/MessagingDependencies.xml:13
implementation 'com.google.firebase:firebase-messaging-unity:10.3.0' // Assets/Firebase/Editor/MessagingDependencies.xml:22
implementation 'com.google.games:gpgs-plugin-support:0.11.01' // Assets/GooglePlayGames/com.google.play.games/Editor/GooglePlayGamesPluginDependencies.xml:11
implementation 'com.iabtcf:iabtcf-decoder:2.0.7' // Assets/ConsentManager/Editor/ConsentManagerDependencies.xml:10
implementation 'com.moat.analytics.mobile.mpub:moat-mobile-app-kit: ' // Assets/THEOplayer/Editor/THEOplayerDependencies.xml:7
implementation 'com.parse.bolts:bolts-android:1.4.0' // Assets/FacebookSDK/Plugins/Editor/Dependencies.xml:4
// Android Resolver Dependencies End
implementation(name: 'billing-4.0.0', ext:'aar')
implementation(name: 'common', ext:'aar')
implementation(name: 'facebook-android-wrapper-15.1.0', ext:'aar')
implementation(name: 'gameanalytics', ext:'aar')
implementation(name: 'googlemobileads-unity', ext:'aar')
implementation(name: 'instantapps-1.1.0', ext:'aar')
implementation(name: 'theoplayer-android-4.6.0-minapi21', ext:'aar')
implementation(name: 'UniWebView', ext:'aar')
implementation project('FirebaseApp.androidlib')
implementation project('GoogleMobileAdsPlugin.androidlib')
implementation project('GooglePlayGamesManifest.androidlib')
implementation project('unity-android-resources')
}
// Android Resolver Exclusions Start
android {
packagingOptions {
exclude ('/lib/arm64-v8a/*' '*')
exclude ('/lib/armeabi/*' '*')
exclude ('/lib/mips/*' '*')
exclude ('/lib/mips64/*' '*')
exclude ('/lib/x86/*' '*')
exclude ('/lib/x86_64/*' '*')
}
}
// Android Resolver Exclusions End
android {
compileSdkVersion 31
buildToolsVersion '30.0.2'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion 26
targetSdkVersion 31
ndk {
abiFilters 'armeabi-v7a'
}
versionCode 1
versionName '1.2.9'
consumerProguardFiles 'proguard-unity.txt'
}
lintOptions {
abortOnError false
}
aaptOptions {
noCompress = ['.ress', '.resource', '.obb'] unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}
packagingOptions {
doNotStrip '*/armeabi-v7a/*.so'
}
}
I have tried
- excluding one of the 2 packages makes the build succeed, but ofcourse i am missing libraries then so functionality is broken
- using different version of packages but no success
- tried upgrading to Unity 2022.2 but nothing works there anyway
I don't know why excluding doesn't work. Does this have to do with the location of the duplicate files being in External Libraries?
P.S. I have exported to android studio and fixing it in android studio. This error comes from within android studio environment.
CodePudding user response:
After a long search and some help from the Unity forums i was given this link:
https://socket.dev/npm/package/com.azerion.ads
At the bottom they actually talk about my specific error. Excluding the files is still the solution, but the key is to put the exclude command in the launcher.gradle file. Unity has an option to enable this. This then properly excludes the files even from external libraries. I hope this helps someone!