关于Android Studio "This version of android studio is incompatible with the gradle version used."的解决方法

声明:此博客为转载博客,非本人原创博客,请各位看官和阅读者,勿随意转载,转载请联系博客原创作者。 原创博客地址为: http://blog.youkuaiyun.com/sinat_15417921/article/details/51907728

问题背景

因为项目app分包需要,将工程的graddle版本升至了2.2.0 alpha4,而我的Android studio 一向升级为最新版,于是就出现了题目中的报错:

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)
当前版本的android studio 与 gradle不兼容。在log中 提示我升级ide和gradle为最新版,然而我出问题的就是最新版,于是尝试 禁用Instant Run,但仍然不能解决问题。

解决方案

通过百度log中的问题,在stackoverflow上有人提出了解决方案。

参考:http://stackoverflow.com/questions/35202541/this-version-of-android-studio-is-incompatible-with-the-gradle-version-used-try


step1:

禁用Instant Run,在Settings/Preferneces > Build, Execution, Deployment option > Instant Run 中,取消所有的选中项



step2:

更新gradle services 的url:在project目录下的 gradle>wrapper>gradle-wrapper.properties中将

distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip

更新为:

distributionUrl=https://services.gradle.org/distributions/gradle-2.11-all.zip


step3:

  删除project下的build文件夹


step4:

clean项目,重新编译跑程序


document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + Math.ceil(new Date()/3600000)
    <div id="digg" articleid="51907728">
        <dl id="btnDigg" class="digg digg_enable" onclick="btndigga();">

             <dt>顶</dt>
            <dd>28</dd>
        </dl>


        <dl id="btnBury" class="digg digg_enable" onclick="btnburya();">

              <dt>踩</dt>
            <dd>0</dd>               
        </dl>

    </div>
 <div class="tracking-ad" data-mod="popu_222"><a href="javascript:void(0);" target="_blank">&nbsp;</a>   </div>
<div class="tracking-ad" data-mod="popu_223"> <a href="javascript:void(0);" target="_blank">&nbsp;</a></div>
<script type="text/javascript">
            function btndigga() {
                $(".tracking-ad[data-mod='popu_222'] a").click();
            }
            function btnburya() {
                $(".tracking-ad[data-mod='popu_223'] a").click();
            }
        </script>


### 解决Gradle构建错误及Android资源链接失败问题 #### 1. 配置文件调整 对于 `android.enableR8` 的弃用警告,应从项目的 `gradle.properties` 文件中删除该项配置。因为该选项已在 Android Gradle Plugin (AGP) 版本 7.0 中被移除[^1]。确保清理掉所有不必要的过时属性能够有效减少潜在冲突。 ```properties # Remove or comment out the following line if present # android.enableR8=true ``` #### 2. 更新Gradle插件与Wrapper版本 为了使项目兼容更高版本的 Gradle(如9.0及以上),需要同步升级 AGP 至其对应支持的新版号。通常情况下,在根目录下的 `build.gradle` 文件里指定最新的稳定发布版本即可完成操作: ```groovy plugins { id 'com.android.application' version '8.0.2' apply false // Example latest stable release at time writing } ``` 与此同时也要记得更新 gradle-wrapper.properties 来匹配相适应的核心引擎版本: ```properties distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip ``` 注意这里选用的具体数值取决于实际环境以及官方文档指引,请参照 [Android Developer Site](https://developer.android.com/studio/releases/gradle-plugin) 获取权威信息[^3]. #### 3. 处理废弃特性提示 针对 “Deprecated Gradle features were used...” 类型的消息,虽然暂时不会阻止编译流程继续推进,但仍建议尽早着手迁移至推荐做法以保障未来可维护性。启用更详细的日志输出可以帮助识别具体哪些地方涉及到了即将淘汰的功能点: ```bash ./gradlew build --warning-mode=all ``` 通过阅读产生的报告内容逐条修正直至消除全部告警为止[^2]。 #### 4. 关于aapt2执行期间发生的异常情况处置策略 当面对诸如 `error: failed to load include path ...` 此类表述时,除了前面提到过的确认SDK完整性之外还需要特别留意是否存在重复定义ID或者样式继承链断裂之类的情况。利用Lint工具进行全面审查不失为一种高效途径: ```groovy lintOptions { abortOnError true checkAllWarnings true } ``` 此外适当增加内存分配限额或许也能缓解某些极端条件下表现出来的不稳定现象: ```groovy android { ... dexOptions { javaMaxHeapSize "4g" } } ``` 最后再次强调务必保持各个组成部分处于协调状态之下才能最大程度规避诸如此类的技术难题发生几率。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值