Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Build fails with Advertisment with Mediation.

Discussion in 'Android' started by nbg_yalta, Nov 19, 2022.

  1. nbg_yalta

    nbg_yalta

    Joined:
    Oct 3, 2012
    Posts:
    378
    After importing, and setting up AwM I cannot build my project. I'm using Unity 2021.3.12f1 LTS with built in SDK,JDK,NDK...

    Here is my errors:
    1
    2
    3
    4
    5
    It tells about useAndroidX is not enabled, but as I can see it is enabled...
    mainTemplate.gradle
    Code (JavaScript):
    1. // Android Resolver Repos Start
    2. ([rootProject] + (rootProject.subprojects as List)).each {
    3.     ext {
    4.         it.setProperty("android.useAndroidX", true)
    5.         it.setProperty("android.enableJetifier", true)
    6.     }
    7. }
    8. ([rootProject] + (rootProject.subprojects as List)).each { project ->
    9.     project.repositories {
    10.         def unityProjectPath = $/file:///**DIR_UNITYPROJECT**/$.replace("\\", "/")
    11.         maven {
    12.             url "https://maven.google.com"
    13.         }
    14.         maven {
    15.             url "https://unity3ddist.jfrog.io/artifactory/unity-mediation-mvn-prod-local/" // Assets/Editor/MediationAdapterDependencies.xml:6
    16.         }
    17.         mavenLocal()
    18.         jcenter()
    19.         mavenCentral()
    20.     }
    21. }
    22. // Android Resolver Repos End
    23. apply plugin: 'com.android.library'
    24. **APPLY_PLUGINS**
    25.  
    26. dependencies {
    27.     implementation fileTree(dir: 'libs', include: ['*.jar'])
    28. // Android Resolver Dependencies Start
    29.     implementation 'com.unity3d.mediation:mediation-sdk:[1.0,2.0[' // Assets/Editor/MediationAdapterDependencies.xml:8
    30.     implementation 'com.unity3d.mediation:unityads-adapter:[1.0,2.0[' // Assets/Editor/MediationAdapterDependencies.xml:10
    31. // Android Resolver Dependencies End
    32. **DEPS**}
    33.  
    34. // Android Resolver Exclusions Start
    35. android {
    36.   packagingOptions {
    37.       exclude ('/lib/armeabi/*' + '*')
    38.       exclude ('/lib/mips/*' + '*')
    39.       exclude ('/lib/mips64/*' + '*')
    40.       exclude ('/lib/x86/*' + '*')
    41.       exclude ('/lib/x86_64/*' + '*')
    42.   }
    43. }
    44. // Android Resolver Exclusions End
    45. android {
    46.     compileSdkVersion **APIVERSION**
    47.     buildToolsVersion '**BUILDTOOLS**'
    48.  
    49.     compileOptions {
    50.         sourceCompatibility JavaVersion.VERSION_1_8
    51.         targetCompatibility JavaVersion.VERSION_1_8
    52.     }
    53.  
    54.     defaultConfig {
    55.         minSdkVersion **MINSDKVERSION**
    56.         targetSdkVersion **TARGETSDKVERSION**
    57.         ndk {
    58.             abiFilters **ABIFILTERS**
    59.         }
    60.         versionCode **VERSIONCODE**
    61.         versionName '**VERSIONNAME**'
    62.         consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
    63.     }
    64.  
    65.     lintOptions {
    66.         abortOnError false
    67.     }
    68.  
    69.     aaptOptions {
    70.         noCompress = **BUILTIN_NOCOMPRESS** + unityStreamingAssets.tokenize(', ')
    71.         ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    72.     }**PACKAGING_OPTIONS**
    73. }**REPOSITORIES**
    74. **IL_CPP_BUILD_SETUP**
    75. **SOURCE_BUILD_SETUP**
    76. **EXTERNAL_SOURCES**
    What is going on? How to fix this?


    Ok, as usually, just after Im making a post with a problem, the universe is sending me a way to fix it.

    So here is the steps to make things work:

    1) Import Advertisement with Mediation package with dependencies resolver.

    2) Go to Project Settings > Player > Publishing Settings;
    - Enable Custom Main Gradle Template;
    - Enable Custom Gradle Properies Template;

    3) Open generated gradleTemplate.properties and add these lines under **ADDITIONAL_PROPERTIES**
    android.enableJetifier=true
    android.useAndroidX=true
    android.enableR8=false

    4) Go to Assets > Mobile Dependency Resolver > Android Resolver > Settings
    - Reset to Defaults.

    5) Do Force Resolve.

    6) Build.

    P.S. Do all of this with VPN enabled if your country has been the victim of a human rights violation.
     
    Last edited: Nov 19, 2022
    kfireven likes this.