解决安卓项目依赖下载失败
1.失败效果图
2.解决方法
1.首先打开“雷电模拟器”(相当于连接着一个安卓真手机,设为华为)。
2.选择默认选择新建一个项目。
3.报错误"Enable Gradle 'offline mode' and sync project"。
4.则将项目之“bulid.gradle文件”中的"jcenter()"替换为 全局的grade
“maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}”后
(阿里云镜像)
5.“Try Again”。
6.则又报错“Unresolved dependencies”,则将app文件夹中之"build.gradle"文
件中的"dependencies"配置节改为如下内容:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:+'
}
7.改后,再“Try Again”。
8.又报错:Error:Execution failed for task ':app:mockableAndroidJar'.
9.则执行以下操作:
File --> Settings --> Build, Execution, Deployment --> Compiler
在Command -line Options的后面添加 -x :app:mockableAndroidJar
10.OK后,关闭项目,再重新打开项目,报错消失。
点击绿色三角,选择在“雷电”模拟器,即可成功运行!