Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Bug More than one file was found with OS independent path 'META-INF/annotation-experimental_release.kotl

Discussion in 'Android' started by TijsVdV, Jan 16, 2023.

  1. TijsVdV

    TijsVdV

    Joined:
    Mar 7, 2017
    Posts:
    32
    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.

    Code (JavaScript):
    1.  
    2. // Android Resolver Repos Start
    3. ([rootProject] + (rootProject.subprojects as List)).each { project ->
    4.     project.repositories {
    5.         def unityProjectPath = path
    6.         maven {
    7.             url "https://maven.google.com"
    8.         }
    9.         maven {
    10.             url "Assets/GeneratedLocalRepo/Firebase/m2repository"
    11.         }
    12.         maven {
    13.             url "https://maven.google.com/"
    14.         }
    15.         maven {
    16.             url "path/ Assets/GooglePlayGames/com.google.play.games/Editor
    17.        }
    18.        maven {
    19.            url "https://s3.amazonaws.com/moat-sdk-builds" // Assets/THEOplayer/Editor
    20.         }
    21.         mavenLocal()
    22.         mavenCentral()
    23.     }
    24. }
    25. // Android Resolver Repos End
    26. apply plugin: 'com.android.library'
    27.  
    28.  
    29. dependencies {
    30.     implementation fileTree(dir: 'libs', include: ['*.jar'])
    31.     testImplementation 'junit:junit:4.12'
    32.     androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    33.     androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    34.     implementation 'androidx.annotation:annotation-experimental:1.0.0'
    35. // Android Resolver Dependencies Start
    36.     implementation 'androidx.ads:ads-identifier:1.0.0-alpha04'
    37.     implementation 'androidx.appcompat:appcompat:1.2.0'
    38.     implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
    39.     implementation 'androidx.lifecycle:lifecycle-common-java8:2.4.1'
    40.     implementation 'androidx.lifecycle:lifecycle-process:2.4.1'
    41.     implementation 'com.android.support:appcompat-v7:25.3.1'
    42.     implementation 'com.android.support:cardview-v7:25.3.1'
    43.     implementation 'com.android.support:customtabs:25.3.1
    44.    implementation 'com.android.support:support-annotations:28.0.0'
    45.    implementation 'com.android.support:support-v4:25.3.1'
    46.    implementation 'com.facebook.android:facebook-applinks:[15.1,16)'
    47.    implementation 'com.facebook.android:facebook-core:[15.1,16)'
    48.    implementation 'com.facebook.android:facebook-gamingservices:[15.1,16)'
    49.    implementation 'com.facebook.android:facebook-login:[15.1,16)'
    50.    implementation 'com.facebook.android:facebook-share:[15.1,16)'
    51.    implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.22.2'
    52.    implementation 'com.google.android.gms:play-services-ads:21.4.0'
    53.    implementation 'com.google.android.gms:play-services-ads-identifier:17.0.1'
    54.    implementation 'com.google.android.gms:play-services-base:18.1.0'
    55.    implementation 'com.google.code.gson:gson:2.8.6'
    56.    implementation 'com.google.firebase:firebase-analytics:21.2.0'
    57.    implementation 'com.google.firebase:firebase-analytics-unity:10.3.0'
    58.    implementation 'com.google.firebase:firebase-app-unity:10.3.0"
    59.    implementation 'com.google.firebase:firebase-common:20.2.0'
    60.    implementation 'com.google.firebase:firebase-iid:21.1.0'
    61.    implementation 'com.google.firebase:firebase-messaging:23.1.1'
    62.    implementation 'com.google.firebase:firebase-messaging-unity:10.3.0'
    63.    implementation 'com.google.games:gpgs-plugin-support:0.11.01'
    64.    implementation 'com.iabtcf:iabtcf-decoder:2.0.7'
    65.    implementation 'com.moat.analytics.mobile.mpub:moat-mobile-app-kit:+'
    66.    implementation 'com.parse.bolts:bolts-android:1.4.0
    67. // Android Resolver Dependencies End
    68.    implementation(name: 'billing-4.0.0', ext:'aar')
    69.    implementation(name: 'common', ext:'aar')
    70.    implementation(name: 'facebook-android-wrapper-15.1.0', ext:'aar')
    71.    implementation(name: 'gameanalytics', ext:'aar')
    72.    implementation(name: 'googlemobileads-unity', ext:'aar')
    73.    implementation(name: 'instantapps-1.1.0', ext:'aar')
    74.    implementation(name: 'theoplayer-android-4.6.0-minapi21', ext:'aar')
    75.    implementation(name: 'UniWebView', ext:'aar')
    76.    implementation project('FirebaseApp.androidlib')
    77.    implementation project('GoogleMobileAdsPlugin.androidlib')
    78.    implementation project('GooglePlayGamesManifest.androidlib')
    79.    implementation project('unity-android-resources')
    80. }
    81.  
    82. // Android Resolver Exclusions Start
    83. android {
    84.  packagingOptions {
    85.      exclude ('/lib/arm64-v8a/*' + '*')
    86.      exclude ('/lib/armeabi/*' + '*')
    87.      exclude ('/lib/mips/*' + '*')
    88.      exclude ('/lib/mips64/*' + '*')
    89.      exclude ('/lib/x86/*' + '*')
    90.      exclude ('/lib/x86_64/*' + '*')
    91.  }
    92. }
    93. // Android Resolver Exclusions End
    94. android {
    95.    compileSdkVersion 31
    96.    buildToolsVersion '30.0.2'
    97.  
    98.    compileOptions {
    99.        sourceCompatibility JavaVersion.VERSION_1_8
    100.        targetCompatibility JavaVersion.VERSION_1_8
    101.    }
    102.  
    103.    defaultConfig {
    104.        minSdkVersion 26
    105.        targetSdkVersion 31
    106.        ndk {
    107.            abiFilters 'armeabi-v7a'
    108.        }
    109.        versionCode 1
    110.        versionName '1.2.9'
    111.        consumerProguardFiles 'proguard-unity.txt'
    112.    }
    113.  
    114.    lintOptions {
    115.        abortOnError false
    116.    }
    117.  
    118.    aaptOptions {
    119.        noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
    120.        ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    121.    }
    122.  
    123.    packagingOptions {
    124.        doNotStrip '*/armeabi-v7a/*.so'
    125.    }
    126. }
    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.
     
    Last edited: Jan 16, 2023
    Cuicui_Studios likes this.
  2. BBO_Lagoon

    BBO_Lagoon

    Joined:
    Mar 2, 2017
    Posts:
    190
    did you try :
    exclude 'META-INF/annotation-experimental_release.kotlin_module'
    or
    pickFirst 'META-INF/annotation-experimental_release.kotlin_module'
    or
    merge 'META-INF/annotation-experimental_release.kotlin_module'
    in the packagingOptions ?
     
    ashraf_unity505 likes this.
  3. TijsVdV

    TijsVdV

    Joined:
    Mar 7, 2017
    Posts:
    32
    Yes, none of those work.
     
  4. BBO_Lagoon

    BBO_Lagoon

    Joined:
    Mar 2, 2017
    Posts:
    190
  5. TijsVdV

    TijsVdV

    Joined:
    Mar 7, 2017
    Posts:
    32
    After adding the exclude exclude("META-INF/*.kotlin_module") i get the same error.....Somehow the exclude does not work.

    Just to be 100% correct i added the exclude like you said in this gradle file

    upload_2023-1-17_8-54-23.png

    Like this

    upload_2023-1-17_8-53-35.png
     
    Last edited: Jan 17, 2023
    ashraf_unity505 likes this.
  6. TijsVdV

    TijsVdV

    Joined:
    Mar 7, 2017
    Posts:
    32
    Following the link you gave you i learned about the launchertemplate.Gradle file in unity, if i add the exclude option there i actually have a working build. Thank you so much for helping!
     
  7. BBO_Lagoon

    BBO_Lagoon

    Joined:
    Mar 2, 2017
    Posts:
    190
    launchertemplate.gradle is much more simpler than exporting an android project ;)
     
  8. lsvjhm

    lsvjhm

    Joined:
    Jul 5, 2019
    Posts:
    2
    Link doesnt open. Could you please provide solution here?