admin管理员组

文章数量:1122832

I am working on an Android project using the following setup:

  • Gradle version: 8.7
  • Android Gradle Plugin (AGP) version: 8.5
  • Kotlin version: 1.9.0
  • JVM version: 17.0.9 jbr
  • Android Studio 24.1.1
  • SDK Android 14

I need to integrate third-party libraries that are hosted on mvnrepository into my project. However, I am facing an issue because the jcenter() method is deprecated. I have been using the maven { url '' } repository configuration, but it no longer works correctly.

Here are the steps I have followed:

I added mavenCentral() and maven { url '' } in the repositories block in the build.gradle file. I tried specifying the dependency directly in the dependencies block but faced issues with the deprecated jcenter() method. Can anyone guide me on properly integrating third-party libraries from mvnrepository with this new setup and avoid issues with deprecated methods?

Here is the relevant part of my build.gradle (project level) file:

pluginManagement {
repositories {
    google()
    mavenCentral()
    gradlePluginPortal()
}  

}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
    google()
    mavenCentral() // Is this enough for mvnrepository dependencies?
    maven { url '' } // Should I still use this, or is there a new approach?
}
}

I've already tried clearing caches and syncing the project, but the dependencies still aren't resolving correctly.

What I need help with:

  1. How to properly add third-party libraries from mvnrepository in this setup.
  2. If any additional configuration is required due to the deprecation of jcenter().
  3. If there are other considerations specific to the combination of Gradle 8.7, AGP 8.5, Kotlin 1.9.0, and JVM 21.

Thanks!

I am working on an Android project using the following setup:

  • Gradle version: 8.7
  • Android Gradle Plugin (AGP) version: 8.5
  • Kotlin version: 1.9.0
  • JVM version: 17.0.9 jbr
  • Android Studio 24.1.1
  • SDK Android 14

I need to integrate third-party libraries that are hosted on mvnrepository.com into my project. However, I am facing an issue because the jcenter() method is deprecated. I have been using the maven { url 'https://repo1.maven.org/maven2' } repository configuration, but it no longer works correctly.

Here are the steps I have followed:

I added mavenCentral() and maven { url 'https://repo.maven.apache.org/maven2' } in the repositories block in the build.gradle file. I tried specifying the dependency directly in the dependencies block but faced issues with the deprecated jcenter() method. Can anyone guide me on properly integrating third-party libraries from mvnrepository.com with this new setup and avoid issues with deprecated methods?

Here is the relevant part of my build.gradle (project level) file:

pluginManagement {
repositories {
    google()
    mavenCentral()
    gradlePluginPortal()
}  

}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
    google()
    mavenCentral() // Is this enough for mvnrepository dependencies?
    maven { url 'https://repo.maven.apache.org/maven2' } // Should I still use this, or is there a new approach?
}
}

I've already tried clearing caches and syncing the project, but the dependencies still aren't resolving correctly.

What I need help with:

  1. How to properly add third-party libraries from mvnrepository.com in this setup.
  2. If any additional configuration is required due to the deprecation of jcenter().
  3. If there are other considerations specific to the combination of Gradle 8.7, AGP 8.5, Kotlin 1.9.0, and JVM 21.

Thanks!

Share Improve this question edited Nov 21, 2024 at 18:12 Ahsan Murtaza asked Nov 21, 2024 at 17:29 Ahsan MurtazaAhsan Murtaza 737 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Largely depend on what libraries you want to make dependencies at. For example this is the build.gradle (Project level) I'm working on currently. As you can see allthough jcenter() is deprecated, I just left it there for no reason, or I can just comment it out, or I can just delete it away.

Also I can also comment out unused script for informational purposes.

My build.gradle (Project level)

buildscript {
        repositories {
        google()
        jcenter()
    }
    dependencies {
//        classpath 'com.android.tools.build:gradle:7.0.3'
        classpath 'com.android.tools.build:gradle:8.3.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
        mavenCentral()
        maven { url 'https://maven.google.com' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

My build.gradle (app level)

apply plugin: 'com.android.application'
android {
    namespace 'com.demo.livwllpaper'
    compileSdkVersion 34
    defaultConfig {
        applicationId "com.demo.livwllpaper"
        minSdkVersion 21
        targetSdkVersion 34
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        resConfigs "en"
        multiDexEnabled true
    }
    bundle {
        density {
            enableSplit true
        }
        abi {
            enableSplit true
        }
        language {
            enableSplit false
        }
    }
    buildTypes {
        release {
            debuggable false
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        debug {
            debuggable true
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.7.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    implementation 'com.google.android.material:material:1.12.0'
  //  implementation 'com.allattentionhere:fabulousfilter:0.0.5'
    implementation 'com.github.mabsou:fabulousfilter:0.0.10'

   // implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
    implementation 'com.vanniktech:android-image-cropper:4.6.0'

   // implementation 'com.wang.avi:library:2.1.3'
    implementation 'io.github.maitrungduc1410:AVLoadingIndicatorView:2.1.4'

  //  implementation 'jp.wasabeef:glide-transformations:4.0.1'
    implementation 'jp.wasabeef:glide-transformations:4.3.0'
    implementation 'pub.devrel:easypermissions:3.0.0'
   // implementation 'com.google.android.exoplayer:exoplayer-core:2.8.1'
    implementation 'com.github.danbrough:exoplayer:2.16.1-dan01'
    implementation 'com.google.android.gms:play-services-ads:23.6.0'
    implementation 'com.github.yalantis:ucrop:2.2.7'
    implementation 'com.github.ArthurHub:Android-Image-Cropper:2.8.0'
}

本文标签: