Attribute meta-data#android.support.VERSION@value value=(25.4.0) from AndroidManifest.xml:25:13-35 is also present at AndroidManifest.xml:28:13-35 value=(26.1.0).


Android Studio 編譯項目的時候報錯

Merging Errors:
Error: Attribute meta-data#android.support.VERSION@value value=(25.4.0) from AndroidManifest.xml:25:13-35 is also present 
       at AndroidManifest.xml:28:13-35 value=(26.1.0). Suggestion: add 'tools:replace="android:value"' to <meta-data> element at 
       AndroidManifest.xml:23:9-25:38 to override. app main manifest (this file), line 24 

原因是:程序內出現不同的,support或者其他外部引用庫的多個版本,Gradle在進行合並的時候會使用本地持有的,最高版本的來進行編譯,

            所以25的support就有可能引用26的東西,就會出現 屬性 merge 錯誤 ,或者Class丟失,官方的解決方法是:

            在AndroidManifest.xml:中 加入tools:replace="android:value" 到 <meta-data>

            然而沒看懂什么意思,最后找到了一種方法:

            在app的build.gradle中加入下面代碼,強制指定一種版本

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.4.0'//默認使用
            }
        }
    }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM