(一)
Error:Could not find com.android.tools.build:gradle:2.14.1. Searched in the following locations: file:/G:/android_studio2.0/gradle/m2repository/com/android/tools/build/gradle/2.14.1/gradle-2.14.1.pom...
問題中只是說找不到!!也沒什么提示。百度了下,也在stackoverflow找了下發現都是讓你把gradle版本往低了改!這個版本不合適,改成低的確實可以解決問題,向下兼容嗎。但是有新的我為什么要改成低的呢,這肯定不能解決根本問題!于是在沒有任何參照的情況下,我試了試,很好一次就成功啦。果然跟我想的一樣,這種問題嘛,只要把插件什么的都改成最新的,一般就解決問題。
你只要一步把Android Plugin Version改為最新的:2.2.0-beta3(這是目前最新的)。直接在Project Structru->Project->Android Plugin Version 中改了就好!
查看最新的Android Plugin Version:https://jcenter.bintray.com/com/android/tools/build/gradle/
查看最新的Gradle:Gradle Distributions。
這是我配好之后的配置:
(二)
Error:Execution failed for task :app:transformResourcesWithMergeJavaResForDebug.> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/NOTICE File1: D:\Code\XTCKuwoWatch\app\libs\jackson-core-2.4.4.jar File2: D:\Code\XTCKuwoWatch\app\libs\jackson-databind-2.4.4.jar
看起來是因為多個 jar 包里包含了同樣的文件(NOTICE.txt),導致打包時因為擔心相互覆蓋問題而提示出錯。 嘗試下在 app 下的 build.gradle 中的 android 部分增加一段配置,如下面這段代碼所示:
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
下面是全部的解決辦法 只需要找到對應的就可以把它exclude進去就解決了
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice'
exclude 'META-INF/dependencies'
exclude 'META-INF/LGPL2.1'
}
}