错误一:
Error:(6, 0) Gradle DSL method not found: 'google()'
出现这样的错误,主要的原因就是AndroidStudio没有升级到3.0和Gradle plugin没有升级到V3.x版本。解决该问题如下:
把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://blog.csdn.net/shenggaofei/article/details/78165940
https://stackoverflow.com/questions/45781489/error6-0-gradle-dsl-method-not-found-google