gpt4 book ai didi

java - Android studio(gradle) 版本兼容性

转载 作者:行者123 更新时间:2023-11-29 22:57:05 27 4
gpt4 key购买 nike

我有这个问题。 Android studio(Gradle) 版本兼容性问题。谁能帮我解决这个问题。下面提到了我使用的所有依赖项版本。我认为这是一个版本问题。试了很多。但是无法解决。你能帮我么。我能做些什么来解决这个问题。

项目级 Gradle 文件:

allprojects {
ext {
appName = "FbaseDemo"
majorVersion = "0"
minorVersion = "1"
patchVersion = "1"

supportLibrary = '26.0.0'
constraintLayout = '2.0.0-beta2'
virgilSdk = '5.1.2'
virgilCrypto = "5.0.2@aar"
rxJava = "2.1.5"
rxAndroid = "2.0.2"
retrofit = "2.3.0"
gson = "2.8.0"
butterKnife = '10.1.0'
networkTracker = '3.0.3'
dagger = '2.24'
loggingInterceptor = '4.0.1'
rxRetrofitAdapter = '2.6.0'
converterGson = "2.3.0"
apacheCommons = "3.7"
firebaseCore = '17.0.1'
firebaseAuth = '18.1.0'
firebaseFirestore = "17.0.1"
room = '1.1.1'
// crashlytics = "2.9.3"
}


apply plugin: 'com.android.application'
//apply plugin: 'io.fabric'

android {
compileSdkVersion 26
defaultConfig {
applicationId "com.android.virgilsecurity.virgilonfire"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName majorVersion + "." + minorVersion + "." + patchVersion
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
setProperty("archivesBaseName", appName + "-v" + versionName)
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

项目级依赖:

dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])

// Support

implementation "com.android.support:appcompat-v7:21.0.0"
implementation "com.android.support.constraint:constraint-layout:$constraintLayout"
implementation "com.android.support:design:$supportLibrary"

// RxJava
implementation "io.reactivex.rxjava2:rxandroid:$rxAndroid"
implementation "io.reactivex.rxjava2:rxjava:$rxJava"
implementation "com.squareup.retrofit2:adapter-rxjava:$rxRetrofitAdapter"

// Retrofit
implementation "com.squareup.retrofit2:retrofit:2.6.1"

// Gson
implementation "com.google.code.gson:gson:2.8.5"
implementation "com.squareup.retrofit2:converter-gson:2.6.1"

// Logging Interceptor
implementation "com.squareup.okhttp3:logging-interceptor:$loggingInterceptor"

// ButterKnife
implementation "com.jakewharton:butterknife:$butterKnife"
annotationProcessor "com.jakewharton:butterknife-compiler:$butterKnife"

// Network Tracker
implementation "com.github.pwittchen:reactivenetwork-rx2:$networkTracker"

// Virgil Security
implementation "com.virgilsecurity.sdk:crypto-android:$virgilCrypto"
implementation "com.virgilsecurity.sdk:sdk:$virgilSdk"

// Dagger
implementation "com.google.dagger:dagger-android:$dagger"
annotationProcessor "com.google.dagger:dagger-compiler:$dagger"
annotationProcessor "com.google.dagger:dagger-android-processor:$dagger"

// Apache commons
implementation "org.apache.commons:commons-lang3:3.9"

// Firebase
implementation "com.google.firebase:firebase-core:$firebaseCore"
implementation "com.google.firebase:firebase-auth:$firebaseAuth"
implementation "com.google.firebase:firebase-firestore:20.2.0"
// implementation "com.crashlytics.sdk.android:crashlytics:$crashlytics"

// Room
implementation "android.arch.persistence.room:runtime:$room"
annotationProcessor "android.arch.persistence.room:compiler:$room"
implementation "android.arch.persistence.room:rxjava2:$room"
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '26.0.0'
}
}
}
}
apply plugin: 'com.google.gms.google-services'

应用级 Gradle 文件:

    dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'

classpath 'com.google.gms:google-services:4.3.0'

// Crashlytics
// classpath 'io.fabric.tools:gradle:1.25.4'
}
}





android {
compileSdkVersion 26
defaultConfig {
applicationId "com.android.virgilsecurity.virgilonfire"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName majorVersion + "." + minorVersion + "." + patchVersion
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
setProperty("archivesBaseName", appName + "-v" + versionName)
}


compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}



dependencies {

implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation "com.android.support:appcompat-v7:21.0.0"
implementation "com.android.support.constraint:constraint-layout:$constraintLayout"
implementation "com.android.support:design:$supportLibrary"

Android 资源链接失败并出现下一个错误:

C:\Users\isufernando\Desktop\New folder\demo-firebase-android\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2476: error: resource android:attr/fontVariationSettings not found.
C:\Users\isufernando\Desktop\New folder\demo-firebase-android\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2476: error: resource android:attr/ttcIndex not found.
error: failed linking references.

最佳答案

resource android:attr/fontVariationSettings not found.
resource android:attr/ttcIndex not found.

compileSdkVersion 更改为:

compileSdkVersion 28

fontVariationSettingsttcIndex在 api level 28 中添加。

你也在用

implementation "com.google.firebase:firebase-auth:18.1.0"

Firebase 在最新版本中迁移到了 AndroidX。这意味着您同时使用了支持库和 androidx 库。

您可以:

  • 如下所述迁移到 androidx
  • 降级你的 firebase 依赖项(但这不是真正的解决方案,因为你必须在之前或之后迁移)

您可以查看 official release notes :

Warning: This release is a MAJOR version update and breaking change. The latest update to Google Play services and Firebase includes the following changes:

从 Android 支持库迁移到 Jetpack (AndroidX) 库。除非您在应用中进行以下更改,否则库将无法工作:

  • com.android.tools.build:gradle 升级到 v3.2.1 或更高版本。
  • compileSdkVersion升级到28或更高版本。
  • 更新您的应用以使用 Jetpack (AndroidX);按照 Migrating to AndroidX 中的说明进行操作.

关于java - Android studio(gradle) 版本兼容性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57302295/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com