錯誤一:
Error:(6, 0) Gradle DSL method not found: 'google()'
出現這樣的錯誤,主要的原因就是AndroidStudio沒有更新到3.0和Gradle plugin沒有更新到V3.x版本。解決該問題如下:
![](https://img.laitimes.com/img/_0nNw4CM6IyYiwiM6ICdiwiI0gTMx81dsQWZ4lmZf1GLlpXazVmcvwFciV2dsQXYtJ3bm9CX9s2RkBnVHFmb1clWvB3MaVnRtp1XlBXe0xCMy81dvRWYoNHLwEzX5xCMx8FesU2cfdGLwMzX0xiRGZkRGZ0Xy9GbvNGLpZTY1EmMZVDUSFTU4VFRR9Fd4VGdsYTMfVmepNHLrJXYtJXZ0F2dvwVZnFWbp1zczV2YvJHctM3cv1Ce-cGcq5CO3QjMxATMkVWZ5gDOwU2YxYzXzETOyMDMxMzLcJTMxIDMy8CXn9Gbi9CXzV2Zh1WavwVbvNmLvR3YxUjLyM3Lc9CX6MHc0RHaiojIsJye.jpg)
把
google()
注掉
maven {
url 'https://maven.google.com'
}
錯誤二:
Error:This Gradle plugin requires Studio 3.0 minimum
出現這樣的錯誤,也是因為Androidstudio版本不是3.0,但是卻運作了Android3.0的項目。解決該問題如下:
在
gradle.properties
添加
android.injected.build.model.only.versioned = 3
錯誤三:
Installation failed with message INSTALL_FAILED_TEST_ONLY.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.
WARNING: Uninstalling will remove the application data!
Do you want to uninstall the existing application?
這個問題挺糾結的,一直因為是MIUI6.0優化的問題,但是并不是這個引起的問題,有技術部落格說要讓下面兩個版本對應:
在AS 2.3上面:
classpath 'com.android.tools.build:gradle:2.3.3'
對應:
distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip
在AS 3.0上面:
classpath 'com.android.tools.build:gradle:3.0.0
對應:
distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip
但是并沒有解決我的問題,希望能解決其他小夥伴的問題。
最後在
stackoverflow
有個兄弟說在啟動加
-t
參數,一試用真的好使了。項目可以運作了。解決該問題如下:
參考連結
https://stackoverflow.com/questions/25274296/adb-install-fails-with-install-failed-test-only
http://www.jacpy.com/2017/09/21/android-installation-failed-with-message-INSTALL-FAILED-TEST-ONLY-md.html
https://stackoverflow.com/questions/45781489/error6-0-gradle-dsl-method-not-found-google