Android Studio(Gradle)版本兼容性

时间:2019-08-01 05:24:19

标签: java android firebase androidx

我有这个问题。 Android Studio(Gradle)版本兼容性问题。谁能帮我解决这个问题。下面提到了我使用过的所有依赖项版本。我认为这是一个版本问题。尝试了很多。但是无法解决。你能帮我么。我该怎么办才能解决这个问题。

Project Level 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.

1 个答案:

答案 0 :(得分:1)

  

未找到资源android:attr / fontVariationSettings。
  找不到资源android:attr / ttcIndex。

compileSdkVersion更改为:

compileSdkVersion 28

fontVariationSettingsttcIndex已在api 28级中添加。

您也在使用

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

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

您可以:

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

您可以检查official release notes

  

警告:此版本是主要版本的更新和重大更改。   Google Play服务和Firebase的最新更新包括以下更改:

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

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