簡體   English   中英

Gradle構建成功,沒有錯誤,但在build.gradle(應用程序)頁面上仍顯示錯誤

[英]Gradle Build Successfully without Error but Still shows error on the build.gradle (app) Page

我已經通過互聯網搜索了所有問題以解決此問題,但是我找不到解決方案。 同步我的項目后,gradle運行沒有任何錯誤,但是當我打開build.gradle文件時,它通過在build.gradle上強調這一行compile 'com.android.support:appcompat-v7:25.3.1'來顯示錯誤。 (應用)頁面。 當我檢查更多信息時會顯示此信息。

這是錯誤信息

這是我完整的gradle文件:

apply plugin: 'com.android.application'

android {

    dexOptions {
        jumboMode = true
    }

    signingConfigs {
        config {
            keyAlias 'Lagchat'
            keyPassword 'HomeAlone'
            storeFile file('C:/Users/WESLEY/Desktop/APKBuild/android.jks')
            storePassword 'HomeAlone'
        }
    }
    compileSdkVersion 26
    buildToolsVersion '26.0.1'
    defaultConfig {
        applicationId "com.classics.classics"
        minSdkVersion 17
        targetSdkVersion 25
        versionCode 10
        versionName "1.0.3"
        testInstrumentationRunner "android.support .test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            debuggable false
            signingConfig signingConfigs.config
        }
        debug {
            debuggable false
            minifyEnabled false
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/rxjava.properties'
    }
    productFlavors {
        free {
            minSdkVersion 17
            applicationId 'com.classics.classics'
            signingConfig signingConfigs.debug
            targetSdkVersion 25
            testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
            versionCode 10
            versionName '1.0.3'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //firebase

    //Facebook

    //others
    compile project(':emoticon')
    compile 'com.google.firebase:firebase-core:11.0.4'
    compile 'com.google.firebase:firebase-core:11.0.4'
    compile 'com.android.support:appcompat-v7:26.0.1'
    compile 'com.github.paolorotolo:appintro:4.1.0'
    compile 'com.android.support:support-v4:26.0.1'
    compile 'com.android.support:design:26.0.1'
    compile 'com.google.firebase:firebase-auth:11.0.4'
    compile 'com.google.firebase:firebase-config:11.0.4'
    compile 'com.google.firebase:firebase-database:11.0.4'
    compile 'com.google.firebase:firebase-messaging:11.0.4'
    compile 'com.google.firebase:firebase-storage:11.0.4'
    compile 'com.google.firebase:firebase-invites:11.0.4'
    compile 'com.google.firebase:firebase-crash:11.0.4'
    compile 'com.google.firebase:firebase-appindexing:11.0.4'
    compile 'com.google.firebase:firebase-ads:11.0.4'
    compile 'com.google.android.gms:play-services-auth:11.0.4'
    compile 'com.google.android.gms:play-services-location:11.0.4'
    compile 'com.google.android.gms:play-services-places:11.0.4'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
    compile 'com.afollestad.material-dialogs:core:0.9.4.5'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.miguelcatalan:materialsearchview:1.4.0'
    compile 'com.jakewharton.rxrelay:rxrelay:1.2.0'
    compile 'com.github.bumptech.glide:glide:3.8.0'
    compile 'com.google.android.gms:play-services-ads:11.0.4'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

這是我用於build.gradle的完整文件(項目)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

注意事項:在我分別將它們分別更改為2626.0.1之前,我使用了compileSdkVersion 25 buildToolsVersion '25.0.3' Error:(15, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'. 26.0.1 Error:(15, 21) No resource found that matches the given name: attr 'android:keyboardNavigationCluster'. 當我同步gradle時。

我該怎么做才能使該項目正常運行。 顯然,即使在成功構建gradle之后,也不會在build.gradle(app)上顯示錯誤。

正如您所面對的錯誤所說

所有com.android.support庫都必須使用相同的版本規范

但是該組中有許多模塊引用不同的版本。

你有依賴關系firebase ,如果你運行gradle app:dependencies ,你可以看到下面的依賴關系樹

+--- com.google.firebase:firebase-core:11.0.4
|    \--- com.google.firebase:firebase-analytics:[11.0.4] -> 11.0.4
|         +--- com.google.firebase:firebase-analytics-impl:[11.0.4] -> 11.0.4
|         |    +--- com.google.android.gms:play-services-basement:[11.0.4] -> 11.0.4
|         |    |    \--- com.android.support:support-v4:25.2.0 -> 27.0.1
|         |    |         +--- com.android.support:support-compat:27.0.1
|         |    |         |    +--- com.android.support:support-annotations:27.0.1

因此, 27.0.1引用了具有27.0.1版本的com.android.support

因此,您需要更新依賴項以調整項目。

然后更改:

compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:support-v4:26.0.1'
compile 'com.android.support:design:26.0.1'

compile 'com.android.support:appcompat-v7:27.0.1'
compile 'com.android.support:support-v4:27.0.1'
compile 'com.android.support:design:27.0.1'

之后,您還需要更新您的compileSdkVersion

更改

compileSdkVersion 26

compileSdkVersion 27

最后

+--- com.afollestad.material-dialogs:core:0.9.4.5
|    +--- com.android.support:support-v13:25.3.1
|    |    +--- com.android.support:support-annotations:25.3.1 -> 27.0.1

版本25.3.1引用了support-v13

因此,在您的依賴項中添加一行

compile 'com.android.support:support-v13:27.0.1'

這樣gradle的解析策略就可以選擇更高版本

RECAP ,您的依賴項應通過以下方式更改:

dependencies {
    ...
    compile 'com.google.firebase:firebase-core:11.0.4'
    compile 'com.google.firebase:firebase-core:11.0.4'
    compile 'com.android.support:appcompat-v7:27.0.1'
    compile 'com.android.support:support-v13:27.0.1'
    compile 'com.github.paolorotolo:appintro:4.1.0'
    compile 'com.android.support:support-v4:27.0.1'
    compile 'com.android.support:design:27.0.1'
    compile 'com.google.firebase:firebase-auth:11.0.4'
    compile 'com.google.firebase:firebase-config:11.0.4'
    compile 'com.google.firebase:firebase-database:11.0.4'
    compile 'com.google.firebase:firebase-messaging:11.0.4'
    compile 'com.google.firebase:firebase-storage:11.0.4'
    compile 'com.google.firebase:firebase-invites:11.0.4'
    compile 'com.google.firebase:firebase-crash:11.0.4'
    compile 'com.google.firebase:firebase-appindexing:11.0.4'
    compile 'com.google.firebase:firebase-ads:11.0.4'
    ...
}

不要忘記compileSdkVersion 27

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM