AndroidStudio运行项目出现This version of Android Studio is incompatible with the Gradle Plugin used.

来源:互联网 发布:mac怎么更改用户名称 编辑:程序博客网 时间:2024/05/29 23:22

问题描述:

我在gitHub上新下载了一个Demo,可是运行时发现有这个错误,在它的 gradle-wrapper.properties 这个文件夹中发现它的gradle版本是3.3的,而我的gradle版本是2.14.1的。所以报出这个错误:Error running app: This version of Android Studio is incompatible with the Gradle Plugin used. Try disabling Instant Run (or updating either the IDE or the Gradle plugin to the latest version)

解决办法:

首先我看了下这个错误提示,意思是Gradle插件不兼容,所以运行不成功。我先是手动修改了一下gradle-wrapper.properties 中的版本,把它的3.3修改成为我的2.14.1可是还是有问题,运行不成功。
后来我修改了AndroidStudio中的Settings--->Build,Execution,Deployment-->Instant Run 把 Enable Instant Run to hot swap code/resoure changes deploy(default enabled)的选项给移除,clean之后再运行成功了。


下面解释一下这四个属性:

Android studio的2.0新版本出了一个革命性的功能就是Instant Run(即时运行)!新的即时运行功能可以让开发者像写html网页一样写android原生代码,能做到一边修改代码,一边在模拟器或者实际设备上看到 修改代码后的结果。

但是这个功能,会引发一些问题,编程的时候会感到不适应。


首先是四个属性: 
1:Enable Instant Run to hot swap code/resource changes on deploy (default enabled) 
//启用即时运行 热交换代码/资源变化 部署(默认启用)

2:Restart activity on code changes 
//当代码变动时重启

3:Show toasts in the running app when changes are applied 
//当代码变动应用时弹出toast

4:show Instant Run status notifications 
//在notification里显示instant Run 的状态


经常遇到的问题: 
1.使用了instant Run功能后开启应用就会短暂白屏,即使是全新的项目也会出现短暂的白屏

解决:取消勾选第四个选项

2.code 已经更新了,但是点击运行的时候还是提示 No changes To Deploy

解决:取消勾选第一个选项

3.Error:Execution failed for task ‘:app:transformClassesWithDexForDebug’

解决:取消勾选第一个选项。如果已经取消过第一个选项,就clean project

参考1:Android studio中settings下instant Run的四个属性
参考2:错误运行app: This version of Android Studio is incompatible
参考3:Android Studio Build Error : This version of Android Studio is incompatible with the Gradle Plugin used. Try disabling Instant Run
阅读全文
1 0
原创粉丝点击