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

Question Android Build Failed in a Clean Project with mediation

Discussion in 'Unity Mediation' started by sfjohansson, Oct 31, 2022.

  1. sfjohansson

    sfjohansson

    Joined:
    Mar 12, 2013
    Posts:
    369
    Hi,
    I'm testing the mediation sdk in a clean project and the build seems to fail, Gradle error.

    1. Following the docs here
    2. When trying to build it will prompt that you need to use the custom mainTemplate option, go to settings and tick the box
    3. Restart the build and it will fail with "This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled".
    4. To set this property:
    - Go To settings and enable the "Custom Gradle Properties"
    - Open file and add "android.useAndroidX=true"
    5. Start a build and it will fail with the message:


    Can someone spot something wrong in the steps so far..has anyone encountered this?

    Cheers,

    Stefan
     
    Mihalchev likes this.
  2. Mihalchev

    Mihalchev

    Joined:
    Jul 15, 2020
    Posts:
    1
    Hello. i have the same problem. if you can fix it let me know
     
    kasimridvan likes this.
  3. msakkuzu

    msakkuzu

    Joined:
    Dec 5, 2013
    Posts:
    7
    The same problem here.
     
    kasimridvan likes this.
  4. sfjohansson

    sfjohansson

    Joined:
    Mar 12, 2013
    Posts:
    369
    I managed to make a build here... so you can at least test on device... try adding this to scripting define symbols

    Code (CSharp):
    1. UNITY_MEDIATION_STAGING
    And then you will get an error about duplicate classes that can be resolved by adding:

    Code (JavaScript):
    1. android.enableJetifier=true
    to "Custom Gradle Properties" file

    At least I managed to get a build by doing this earlier today...
     
  5. DeclanMcPartlin

    DeclanMcPartlin

    Unity Technologies

    Joined:
    Nov 19, 2020
    Posts:
    146
    Do not add the define script UNITY_MEDIATION_STAGING, this is not a solution that will help with such an issue (or any issue as a matter of fact).

    This looks like an issue with the resolution of the dependency inside of maven central, we will look into this and get back to you shortly.
     
  6. DeclanMcPartlin

    DeclanMcPartlin

    Unity Technologies

    Joined:
    Nov 19, 2020
    Posts:
    146
    @sfjohansson @msakkuzu @Mihalchev could any of you share your Assets/Plugins/Android/mainTemplate.gradle file (if applicable) ? If it is not applicable, also let us know, thanks!
     
  7. sfjohansson

    sfjohansson

    Joined:
    Mar 12, 2013
    Posts:
    369
    Hi Declan,
    Thanks for looking at this. Yeah, adding "UNITY_MEDIATION_STAGING" was definitely a hack..just tried it because I saw that it changed some repo links:

    Code (CSharp):
    1. #if UNITY_MEDIATION_STAGING
    2.         const string k_AndroidArtifactoryURL = @"https://unity3ddist.jfrog.io/artifactory/unity-mediation-mvn-stg-local/";
    3.         const string k_IOSArtifactoryURL = @"'git@github.com:Unity-Technologies/mz-liveops-cocoapods.git'";
    4. #else // Prod
    5.         const string k_AndroidArtifactoryURL = @"https://unity3ddist.jfrog.io/artifactory/unity-mediation-mvn-prod-local/";
    6.         const string k_IOSArtifactoryURL = @"'https://github.com/Unity-Technologies/unity-mediation-cocoapods-prod.git'";
    7. #endif
    The manifest is literally the one created by ticking the box, it's attached below as a .txt file.

    Btw I'm using the Linux Editor...

    Cheers!
     

    Attached Files:

  8. DeclanMcPartlin

    DeclanMcPartlin

    Unity Technologies

    Joined:
    Nov 19, 2020
    Posts:
    146
    Hi @sfjohansson, thank you for providing your mainTemplate.gradle file. Try removing the line with jcenter() and try again. It has recently been taken offline and might be causing issues with gradle resolution.

    Also, could you share which version of the Unity Editor you're using? I'd like for such issues to be avoided in the future, I'll discuss with the editor team.
     
  9. sfjohansson

    sfjohansson

    Joined:
    Mar 12, 2013
    Posts:
    369
    Hi Declan,
    It does build now, not having the "hack". Although removing the line "jcenter" is temporary as triggering the android dependency resolver puts it back in. I'm on Unity 2020.3.30f.

    Below is a screenshot, of my project window. Perhaps @msakkuzu @Mihalchev can also try.
     

    Attached Files:

  10. Vladimir_91

    Vladimir_91

    Joined:
    Jul 20, 2016
    Posts:
    12
    Having the same problem, deleting jcenter didnt help. Unity version 2021.3.11.
    Also the android.useAndroidX' is set to true in the mainTemplate, so the line below makes no sense.

    Code (CSharp):
    1. FAILURE: Build failed with an exception.
    2.  
    3. * What went wrong:
    4. Could not determine the dependencies of task ':launcher:lintVitalRelease'.
    5. > This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.
    6.   The following AndroidX dependencies are detected: androidx.fragment:fragment:1.0.0, androidx.slidingpanelayout:slidingpanelayout:1.0.0, androidx.versionedparcelable:versionedparcelable:1.1.0, androidx.core:core:1.2.0, androidx.customview:customview:1.0.0, androidx.swiperefreshlayout:swiperefreshlayout:1.0.0, androidx.interpolator:interpolator:1.0.0, androidx.loader:loader:1.0.0, androidx.drawerlayout:drawerlayout:1.0.0, androidx.viewpager:viewpager:1.0.0, androidx.collection:collection:1.0.0, androidx.localbroadcastmanager:localbroadcastmanager:1.0.0, androidx.lifecycle:lifecycle-common:2.0.0, androidx.arch.core:core-common:2.0.0, androidx.annotation:annotation:1.2.0, androidx.startup:startup-runtime:1.0.0, androidx.tracing:tracing:1.0.0, androidx.legacy:legacy-support-core-ui:1.0.0, androidx.lifecycle:lifecycle-livedata:2.0.0, androidx.lifecycle:lifecycle-viewmodel:2.0.0, androidx.lifecycle:lifecycle-livedata-core:2.0.0, androidx.arch.core:core-runtime:2.0.0, androidx.legacy:legacy-support-core-utils:1.0.0, androidx.documentfile:documentfile:1.0.0, androidx.cursoradapter:cursoradapter:1.0.0, androidx.lifecycle:lifecycle-runtime:2.0.0, androidx.coordinatorlayout:coordinatorlayout:1.0.0, androidx.asynclayoutinflater:asynclayoutinflater:1.0.0, androidx.print:print:1.0.0
    7.  
    8. * Try:
    9. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    10.  
    11. * Get more help at https://help.gradle.org
    12.  
    13. BUILD FAILED in 1s
    14. Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    15.  
    16. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
     
  11. minus4games

    minus4games

    Joined:
    Dec 13, 2021
    Posts:
    9
    Setting custom gradle template and adding the following lines to "Assets/Plugins/Android/gradleTemplate.properties" worked for me:

    Code (csharp):
    1. android.useAndroidX=true
    2. android.enableJetifier=true