Search Unity

AndroidX, Gradle, compileSdkVersion

Discussion in 'Android' started by Qbit86, Jul 10, 2019.

  1. Qbit86

    Qbit86

    Joined:
    Sep 2, 2013
    Posts:
    487
    Hi,

    I have a problem with Gradle and AndroidX in Unity 2017.4.22f1.

    Starting from a certain moment Android Resolver in our project started resolving AndroidX libraries as dependencies. (They should replace Android Support Library.)

    But one cannot simply start using it; documentation requires to add a couple of lines to gradle.properties and set the compile SDK to Android 9.0 (API level 28) or higher.

    1) How can I change gradle.properties file? (Not to be confused with mainTemplate.gradle file.)

    2) What is the value of placeholder
    **APIVERSION**
    in mainTemplate.gradle?
    Code (csharp):
    1. compileSdkVersion **APIVERSION**
    (Not to be confused with minSdkVersion or targetSdkVersion.)

    @Yury-Habets @JoshPeterson
     
  2. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,967
    Unfortunately, as far as i know, you can't set jetifier flags in gradle.properties automatically as you are below 2018.2 version.

    Also, Unity didn't backport gradle post processor callback to 2017.4 LTS so, its a kind of problem now for the users who are less than 2018.2 and need to add to gradle.properties automatically.


    However, you can move on to 2018.4 LTS if its possible to automate it.
     
    Qbit86 likes this.
  3. Qbit86

    Qbit86

    Joined:
    Sep 2, 2013
    Posts:
    487
    @Voxel-Busters Thanks a lot for your reply!

    Oh, I see you mentioning this in recent thread...

    We indeed consider moving to 2018.4 LTS in a month or two. Then, how can I add these two flags (android.useAndroidX and android.enableJetifier) to (generated?) gradle.properties file in Unity 2018? Are there any examples of using OnPostGenerateGradleAndroidProject API?
     
  4. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,967
    Qbit86 likes this.
  5. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,967
    Hi,
    Please check over here to automate the patching of gradle.properties.

    Thanks,
    VB Team
     
    Qbit86 likes this.