我必须升级旧的android项目。我做了一些改动来构建。Gradle文件如下:
构建。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;
}
}
当前,Getting below错误:
配置根项目'skyazul-android'时出现问题。无法解析配置':classpath'的所有工件。找不到任何与com.android.tools.build:gradle:7.0+匹配的版本。不匹配的版本:——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可在以下地点搜索:——https://jcenter.bintray.com/com/android/tools/build/gradle/maven-metadata.xml要求:项目:
可能的解决方案:
- 声明提供工件的存储库,参见https://docs.gradle.org/current/userguide/declaring_repositories.html
的文档
谁能给我指路?
编辑:构建。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()
}
}
在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
}
添加到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' }
}
}
定义settings.gradle
中的repositories
:
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
;织物崩溃分析现在是Firebase崩溃分析。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>