我必须升级旧的android项目。我对build.gradle文件做了如下更改:
build.gradle文件
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;
}
}当前,出现以下错误:
出现了配置根项目‘skyazul’的问题。无法解析配置的所有工件“:类路径”。找不到任何与com.android.tools.build:gradle:7.0+匹配的版本。不匹配的版本:-2.5.0-alpha-预览-02-2.5.0-alpha-预览-01-2.4.0-alpha 7-2.4.0-alpha 6-2.4.0-alpha 5-+ 145在以下位置搜索:-项目所需的https://jcenter.bintray.com/com/android/tools/build/gradle/maven-metadata.xml:
可能的解决办法:
提供工件的
有人能指引我吗?
编辑: build.gradle (项目级别)
// 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()
}
}发布于 2022-07-19 07:58:47
在您的build.gradle(模块)中更改此选项
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
}将此添加到您的build.gradle(项目)中
// 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' }
}
}发布于 2022-07-19 09:31:41
在repositories中定义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'然后,build.gradle可以设置以下插件:
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
}不存在jcenter(),也不要将com.android.support与androidx库混为一谈;这意味着包com.android.support:cardview-v7需要全部替换,也需要在XML和代码中替换。取代com.crashlytics.sdk.android:crashlytics;织物破折号现在是火基破折号。targetSdk 32的意思是compileSdk 32和JavaVersion.VERSION_11。虽然无法设置android.enableJetifier=false,但您可能仍然存在依赖关系问题,即使它可能生成。
我建议最好忽略所有带有alpha和beta包的lint.xml
<?xml version="1.0" encoding="UTF-8"?>
<lint>
<issue id="GradleDependency">
<ignore regexp="is available: .*alpha|beta"/>
</issue>
</lint>https://stackoverflow.com/questions/73033100
复制相似问题