Recently i had to upgrade a plugin. Here is where the issues started, since Android now requires you now 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.
// 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"
}
maven {
url "https://maven.google.com/"
}
maven {
url "path/ Assets/GooglePlayGames/com.google.play.games/Editor
}
maven {
url "https://s3.amazonaws.com/moat-sdk-builds" // Assets/THEOplayer/Editor
}
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'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.lifecycle:lifecycle-common-java8:2.4.1'
implementation 'androidx.lifecycle:lifecycle-process:2.4.1'
implementation 'com.android.support:appcompat-v7:25.3.1'
implementation 'com.android.support:cardview-v7:25.3.1'
implementation 'com.android.support:customtabs:25.3.1
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.support:support-v4:25.3.1'
implementation 'com.facebook.android:facebook-applinks:[15.1,16)'
implementation 'com.facebook.android:facebook-core:[15.1,16)'
implementation 'com.facebook.android:facebook-gamingservices:[15.1,16)'
implementation 'com.facebook.android:facebook-login:[15.1,16)'
implementation 'com.facebook.android:facebook-share:[15.1,16)'
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.22.2'
implementation 'com.google.android.gms:play-services-ads:21.4.0'
implementation 'com.google.android.gms:play-services-ads-identifier:17.0.1'
implementation 'com.google.android.gms:play-services-base:18.1.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.firebase:firebase-analytics:21.2.0'
implementation 'com.google.firebase:firebase-analytics-unity:10.3.0'
implementation 'com.google.firebase:firebase-app-unity:10.3.0"
implementation 'com.google.firebase:firebase-common:20.2.0'
implementation 'com.google.firebase:firebase-iid:21.1.0'
implementation 'com.google.firebase:firebase-messaging:23.1.1'
implementation 'com.google.firebase:firebase-messaging-unity:10.3.0'
implementation 'com.google.games:gpgs-plugin-support:0.11.01'
implementation 'com.iabtcf:iabtcf-decoder:2.0.7'
implementation 'com.moat.analytics.mobile.mpub:moat-mobile-app-kit:+'
implementation 'com.parse.bolts:bolts-android:1.4.0
// 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.