我的Android进阶之旅------>解决Error:Unable to find method 'org.gradle.api.internal.project.ProjectInternal.g

简介: 错误描述 今天在Github上面下载了一份代码,然后导入到Android Studio中直接报了如下图所示的错误: 错误描述如下: Error: Unable to find method ‘org.

错误描述

今天在Github上面下载了一份代码,然后导入到Android Studio中直接报了如下图所示的错误:
这里写图片描述

错误描述如下:

Error: Unable to find method ‘org.gradle.api.internal.project.ProjectInternal.getPluginManager()Lorg/gradle/api/internal/plugins/PluginManagerInternal;’.
Possible causes for this unexpected error include:

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

解决方法

按照如上图所示的提示去点击【Re-download dependencies and sync project】选项,发现怎么重新尝试还是无效果。如果点击【Stop Gradle build processes (requires restart)】选项,则直接退出了Android Studio,重启后还是无效。

最后我把该Github上面下载下来的代码和我已经运行正常的代码做对比,发现有两个地方的代码有很大的差异:

差异一:gradle版本太低

发现该代码的gradle版本为1.2.3,代码如下

   classpath 'com.android.tools.build:gradle:1.2.3'

因为gradle版本为1.2.3我电脑上没有下载,因此我将gradle版本改为我目前Android Studio中所使用的gradle版本2.2.0-alpha4’,代码如下:

    classpath 'com.android.tools.build:gradle:2.2.0-alpha4'
//  classpath 'com.android.tools.build:gradle:1.2.3'

差异二:gradle-wrapper.properties里面的gradle压缩包版本太低

发现了项目工程文件目录gradle\wrapper里面找到gradle-wrapper.properties里面的内容不同。

位置如下图所示:
这里写图片描述

修改里面的值:将distributionUrl=https://services.gradle.org/distributions/gradle-2.2-all.zip改为distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip 。如下所示:
这里写图片描述

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

改为:

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

修改后如下图所示:
这里写图片描述

#Mon Jul 25 20:23:10 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

修改完之后,再重新编译即可。编译成功后,如下图所示:
这里写图片描述

作者:欧阳鹏 欢迎转载,与人分享是进步的源泉!
转载请保留原文地址:http://blog.csdn.net/ouyang_peng

这里写图片描述

相关文章
|
5月前
|
Android开发 开发者
Error:Could not find com.android.support:appcompat-v7:27.0.2.
Error:Could not find com.android.support:appcompat-v7:27.0.2.
83 0
|
5月前
|
开发工具 Android开发 git
解决Android AAPT: error: resource android:attr/lStar not found. 问题
解决Android AAPT: error: resource android:attr/lStar not found. 问题
377 0
|
5月前
|
Android开发
【Bug】Android resource linking failed和error: failed linking references.
【Bug】Android resource linking failed和error: failed linking references.
|
2月前
|
Android开发 Docker 容器
docker中编译android aosp源码,出现Build sandboxing disabled due to nsjail error
在使用Docker编译Android AOSP源码时,如果遇到"Build sandboxing disabled due to nsjail error"的错误,可以通过在docker run命令中添加`--privileged`参数来解决权限不足的问题。
183 1
|
5月前
|
开发工具 Android开发 Windows
Android应用] 问题2:ERROR: unknown virtual device name:
Android应用] 问题2:ERROR: unknown virtual device name:
30 2
|
5月前
|
Android开发 开发者
安卓投屏神器 Scrcpy安 报错ERROR: Could not find any ADB device
使用Scrcpy安卓投屏工具时遇到报错,问题根源是未开启开发者模式。解决步骤:进入设置,点击【关于手机】→连续点击版本号激活开发者模式,然后在【系统设置】→【开发者选项】中开启USB调试。参照此方法后可正常执行。Scrcpy软件下载链接和GitHub页面也已提供。
413 1
|
5月前
解决Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com
解决Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com
72 5
|
5月前
|
XML Android开发 数据格式
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class
49 0
|
5月前
|
API Android开发
List.size() 问题 Android studio: Verbose,Debug,Info,Warn,Error
List.size() 问题 Android studio: Verbose,Debug,Info,Warn,Error
33 0
|
XML Android开发 数据格式
Android Binary XML file line #50: Error inflating class androidx.cardview.widget.CardView 错误
Android Binary XML file line #50: Error inflating class androidx.cardview.widget.CardView 错误
79 0
下一篇
无影云桌面