androidandroid-gradle-pluginbuild.gradlepipelineandroid-sdk-2.3

Android gradle build stopped working after upgrading to SDK 34


I have an android project that has been running for more than 7 years now. Today I updated the SDK to 34 (from 33) because Google is requiring me to. After doing so, my gradle build started to fail consistently. I won't include the whole log (unless needed) but here's the errors that I get:

     Required by:
         project :app
      > Could not resolve io.github.zncmn.libyuv:core:0.0.7.
         > Could not get resource 'https://jitpack.io/io/github/zncmn/libyuv/core/0.0.7/core-0.0.7.pom'.
            > Could not GET 'https://jitpack.io/io/github/zncmn/libyuv/core/0.0.7/core-0.0.7.pom'. Received status code 401 from server: Unauthorized
      > Could not resolve io.github.zncmn.libyuv:core:0.0.7.
         > Could not get resource 'https://jitpack.io/io/github/zncmn/libyuv/core/0.0.7/core-0.0.7.pom'.
            > Could not GET 'https://jitpack.io/io/github/zncmn/libyuv/core/0.0.7/core-0.0.7.pom'. Received status code 401 from server: Unauthorized
   > Could not find com.amulyakhare:com.amulyakhare.textdrawable:1.0.1.
     Searched in the following locations:
       - https://jcenter.bintray.com/com/amulyakhare/com.amulyakhare.textdrawable/1.0.1/com.amulyakhare.textdrawable-1.0.1.pom
       - https://jitpack.io/com/amulyakhare/com.amulyakhare.textdrawable/1.0.1/com.amulyakhare.textdrawable-1.0.1.pom
       - https://maven.google.com/com/amulyakhare/com.amulyakhare.textdrawable/1.0.1/com.amulyakhare.textdrawable-1.0.1.pom
       - https://dl.google.com/dl/android/maven2/com/amulyakhare/com.amulyakhare.textdrawable/1.0.1/com.amulyakhare.textdrawable-1.0.1.pom
       - file:/home/runner/.m2/repository/com/amulyakhare/com.amulyakhare.textdrawable/1.0.1/com.amulyakhare.textdrawable-1.0.1.pom
       - https://repo.maven.apache.org/maven2/com/amulyakhare/com.amulyakhare.textdrawable/1.0.1/com.amulyakhare.textdrawable-1.0.1.pom
     Required by:
         project :app
   > Could not find com.github.gcacace:signature-pad:1.2.1.
     Searched in the following locations:
       - https://jcenter.bintray.com/com/github/gcacace/signature-pad/1.2.1/signature-pad-1.2.1.pom
       - https://jitpack.io/com/github/gcacace/signature-pad/1.2.1/signature-pad-1.2.1.pom
       - https://maven.google.com/com/github/gcacace/signature-pad/1.2.1/signature-pad-1.2.1.pom
       - https://dl.google.com/dl/android/maven2/com/github/gcacace/signature-pad/1.2.1/signature-pad-1.2.1.pom
       - file:/home/runner/.m2/repository/com/github/gcacace/signature-pad/1.2.1/signature-pad-1.2.1.pom
       - https://repo.maven.apache.org/maven2/com/github/gcacace/signature-pad/1.2.1/signature-pad-1.2.1.pom
     Required by:
         project :app
   > Could not find com.mikhaellopez:circularimageview:3.2.0.
     Searched in the following locations:
       - https://jcenter.bintray.com/com/mikhaellopez/circularimageview/3.2.0/circularimageview-3.2.0.pom
       - https://jitpack.io/com/mikhaellopez/circularimageview/3.2.0/circularimageview-3.2.0.pom
       - https://maven.google.com/com/mikhaellopez/circularimageview/3.2.0/circularimageview-3.2.0.pom
       - https://dl.google.com/dl/android/maven2/com/mikhaellopez/circularimageview/3.2.0/circularimageview-3.2.0.pom
       - file:/home/runner/.m2/repository/com/mikhaellopez/circularimageview/3.2.0/circularimageview-3.2.0.pom
       - https://repo.maven.apache.org/maven2/com/mikhaellopez/circularimageview/3.2.0/circularimageview-3.2.0.pom
     Required by:
         project :app

It continues like this for some of the libraries used in my project and then ultimately fails.

I did not change anything else except the targetSdkVersion to 34 instead of 33. My build.gradle looks like this:

    repositories {
        jcenter()
        google()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:8.5.2'
        classpath 'com.google.gms:google-services:4.3.14'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.2'
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
        maven {
            url 'https://maven.google.com/'
        }
        // flatDir {
        //     dirs "$rootProject.projectDir/aars"
        // }
    }
}

Something interesting to note: I can generate an APK/Bundle locally without any issue. The issue lies in my github pipeline that generate the Bundle for me.

Anyone has any idea how I could solve this? I ran into a few posts asking this specific question but there was no answer unfortunately.


Solution

  • These dependencies won't be found because JCenter has been sunset i.e. it's no longer available, even in read-only mode

    So adding jcenter() in your build.gradle file has no effect

    All of the dependencies, mentioned above, are hosted on JCenter/Bintray, and haven't been migrated to the other sources

    You can do one of the following

    1. Look into the gradle cache, to see where it has downloaded these hosted files to be used. This is as simple as using the command
    gradle showMeCache
    
    1. Go the Github page of the library, download the code, and create a new module in your app, which should be seperate from all the other code, and then in your build.gradle file, declare that as a local dependency (aar/jar) file
    implementation "your_local_dependency.aar"
    

    or create a libs folder and put all your dependencies under that, and help gradle locate it

     // Include local .jar and .aar files under the libs/ folder
                    implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar", "*.aar"))))
    
    1. You can create a fork of the mentioned library and host on Maven Central, using the following guide

    2. Migrate or integrate other libraries that are maintained and do the same thing as what you require