I have to upgrade old android project. I have done some changes to build.gradle file as below :
build.gradle file:
plugins {
id 'com.android.application'
id 'io.fabric'
}
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1. '
}
}
//apply plugin: 'com.android.application'
//apply plugin: 'io.fabric'
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdk 30
buildToolsVersion '30.0.3'
defaultConfig {
applicationId "com.brian.skyazul"
minSdk 30
targetSdk 32
versionCode 3
versionName "1.2"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds false
}
}
dependencies {
implementation 'com.google.android.material:material:1.6.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.squareup.retrofit:retrofit:1.9.0'
// implementation 'com.github.bumptech.glide:glide:3.5.2'
implementation 'com.android.support:cardview-v7:23.2.1'
implementation 'com.squareup.retrofit:converter-jackson:1.9.0'
implementation 'com.squareup.okhttp:okhttp:2.0.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.3.1'
implementation files('libs/picasso-2.5.2.jar')
implementation('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true;
}
}
Currently, Getting below error :
A problem occurred configuring root project 'skyazul-android'. Could not resolve all artifacts for configuration ':classpath'. Could not find any version that matches com.android.tools.build:gradle:7.0 . Versions that do not match: - 2.5.0-alpha-preview-02 - 2.5.0-alpha-preview-01 - 2.4.0-alpha7 - 2.4.0-alpha6 - 2.4.0-alpha5 - 145 more Searched in the following locations: - https://jcenter.bintray.com/com/android/tools/build/gradle/maven-metadata.xml Required by: project :
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
Can anyone guide me?
Edit : build.gradle (project level)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.5.31'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10'
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
allprojects {
repositories {
jcenter()
}
}
CodePudding user response:
change this in your build.gradle(Module)
buildscript {
ext.kotlin_version = '1.5.31'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10'
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Add this in your build.gradle(Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'io.fabric.tools:gradle:1. '
}
}
apply plugin: 'java'
allprojects {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
}
CodePudding user response:
Define the repositories
in settings.gradle
:
import org.gradle.api.initialization.resolve.RepositoriesMode
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
}
}
include ':app'
Then the build.gradle
can set up these plugins:
buildscript {
ext {
agp_version = '7.2.1' // eg. matching Android Studio Chipmunk Patch 1
gms_version = '4.3.13'
kotlin_version = '1.7.10'
crashlytics_version = '2.8.1'
}
}
plugins {
id 'com.android.application' version "$agp_version" apply false
id 'com.android.library' version "$agp_version" apply false
id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false
id 'com.google.gms.google-services' version "$gms_version" apply false
id 'com.google.firebase.crashlytics' version "$crashlytics_version" apply false
}
There is no jcenter()
and do not mix com.android.support
with androidx
libraries; which means that package com.android.support:cardview-v7
needs to be replaced altogether, also in XML and code. And replace com.crashlytics.sdk.android:crashlytics
; Fabric Crashlytics is now Firebase Crashlytics. targetSdk 32
means compileSdk 32
and JavaVersion.VERSION_11
. While being unable to set android.enableJetifier=false
, you might still have a dependency issue, even if it may build.
And I'd suggest to better ignore all alpha
and beta
packages with a lint.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="GradleDependency">
<ignore regexp="is available: .*alpha|beta"/>
</issue>
</lint>