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

Android Builds failing due to conflicts between new AndroidX files and old Android support files

Discussion in 'Android' started by JamesA24, Jun 25, 2019.

  1. JamesA24

    JamesA24

    Joined:
    Sep 6, 2018
    Posts:
    28
    Hi there,

    I'm in the process of getting android builds working again for my work. We recently upgraded one of our projects from 2018.2 to 2019.1, but now we're having issues getting local and cloud builds to work due to gradle errors. I've taken a number of steps after doing extensively googling and haven't managed to make much progress on the issue.

    Edit: The errors in particular I've been seeing are; duplicate classes mentioned in an old support file and in a androidx file, and not being able to jetify some old support files for some odd reason which is why I would have put the files into the dependencies.xml.

    Updated Android Studio to the latest version.
    Updated the gradle files classpath to 3.4.0.
    The play resolver has been run several times, and updated.
    Wrote the following two lines into the properties file so I could use AndroidX and have the old support files go through the jetifier.
    android.useAndroidX=true
    android.enableJetifier=true


    I've also added the support files into the dependencies.xml and tried keeping them in, removing them, and moving them, but there's still errors. The following block is the gradle file. Please ignore that I set this to Csharp.

    Code (CSharp):
    1. /* THE UNITY COMMENT IS GONE AT THE BEGINNING */
    2. buildscript {
    3.     repositories {
    4.         jcenter()
    5.         google()
    6.         maven {
    7.             url "https://maven.google.com"
    8.         }
    9.     }
    10.     dependencies {
    11.         classpath 'com.android.tools.build:gradle:3.4.0'
    12.     }
    13. }
    14. allprojects {
    15.     repositories {
    16.         jcenter()
    17.         google()
    18.         maven {
    19.             url "https://maven.google.com"
    20.         }
    21.         flatDir {
    22.             dirs 'libs'
    23.         }
    24.     }
    25. }
    26. apply plugin: 'com.android.application'
    27. dependencies {
    28.     implementation fileTree(dir: 'libs', include: ['*.jar'])
    29. **DEPS**}
    30. android {
    31.     compileSdkVersion **APIVERSION**
    32.     buildToolsVersion '**BUILDTOOLS**'
    33.     defaultConfig {
    34.         minSdkVersion **MINSDKVERSION**
    35.         targetSdkVersion **TARGETSDKVERSION**
    36.         applicationId '**APPLICATIONID**'
    37.         ndk {
    38.             abiFilters **ABIFILTERS**
    39.         }
    40.         versionCode **VERSIONCODE**
    41.         versionName '**VERSIONNAME**'
    42.         multiDexEnabled true
    43.     }
    44.     lintOptions {
    45.         abortOnError false
    46.     }
    47.     aaptOptions {
    48.         noCompress '.unity3d', '.ress', '.resource', '.obb'**STREAMING_ASSETS**
    49.     }**SIGN**
    50.     buildTypes {
    51.         debug {
    52.             minifyEnabled **MINIFY_DEBUG**
    53.             useProguard **PROGUARD_DEBUG**
    54.             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
    55.             jniDebuggable true
    56.         }
    57.         release {
    58.             minifyEnabled **MINIFY_RELEASE**
    59.             useProguard **PROGUARD_RELEASE**
    60.             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD****SIGNCONFIG**
    61.         }
    62.     }**PACKAGING_OPTIONS****SPLITS**
    63. **BUILT_APK_LOCATION**
    64. }**SPLITS_VERSION_CODE****SOURCE_BUILD_SETUP**
    65. dependencies {
    66.   implementation 'com.android.support:multidex:1.0.3'
    67. }
    Any advice or suggestions on this issue would be appreciated! Thank You!
     
    vasilii001 likes this.
  2. JamesA24

    JamesA24

    Joined:
    Sep 6, 2018
    Posts:
    28
    Update to my issue with this.

    There's an updated play services resolver, and updated google play games SDK (0.9.64)
    Getting those, and doing a new android setup, and running the resolver fixed the issues I've discussed above.

    I'm now facing a different issue, but still related to this.

    Could not find any version that matches com.google.android.gms:play-services-base:16.0.0+.


    Basically a dependency is looking for com.google.android.gms:play-services-base:16.0.0 at minimum. But during the gradle build process it can't be found. After updating to a more recent version of the resolver and gpg sdk, the dependencies are now just implemented into the .gradle file. And I can see that service-base:16.0.0+ listed there to be implemented. Removing the +, or changing the 16.0.0+ to 17.0.0 leads to a successful build. HOWEVER, the app then will not work on launch. It will immediately display on the vice that the application has stopped working.

    LogCat is display errors that a class is not being found or handled correctly, but I can't see where it specifies what class is doing this.

    Any information someone may have on this issue would be appreciated!
     
  3. Rafael-cmk

    Rafael-cmk

    Joined:
    Jun 28, 2016
    Posts:
    56
    I'm having the same problem, after a lot of trouble I am able to build again but the app just won't start, I get this error on the logcat:
    Code (CSharp):
    1. 07-14 10:05:49.862: E/AndroidRuntime(20910): Process: com.rfentertainment.estilobr, PID: 20910
    2.  
    3. 07-14 10:05:49.862: E/AndroidRuntime(20910): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.LocalBroadcastManager" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.rfentertainment.estilobr-Tsc0XcfSxpdmo-Yu_75Mhg==/base.apk"],nativeLibraryDirectories=[/data/app/com.rfentertainment.estilobr-Tsc0XcfSxpdmo-Yu_75Mhg==/lib/arm, /data/app/com.rfentertainment.estilobr-Tsc0XcfSxpdmo-Yu_75Mhg==/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
    4.  
     
  4. Tom-Atom

    Tom-Atom

    Joined:
    Jun 29, 2014
    Posts:
    153
    @Rafael-cmk I had similar problems, also with missing android.support.v4. I posted thread about it here: https://forum.unity.com/threads/androidx-vs-android-libraries.710831/ My game was also crashing during runtime. I had to add additional lines into gradle.properties.
     
    RakshithAnand likes this.
  5. Rafael-cmk

    Rafael-cmk

    Joined:
    Jun 28, 2016
    Posts:
    56
    I managed to fix my problems, After a lot of trouble I decided to just delete every plugin and update then to the highest stable version, including unity.
     
  6. RakshithAnand

    RakshithAnand

    Joined:
    Jun 30, 2013
    Posts:
    56