我的Android进阶之旅------>解决Error:Could not find property 'compile' on org.gradle.api.internal.artifacts.

  • 1错误描述
  • 解决方法
    • 1错误原因
    • 2解决方法

1、错误描述

刚刚,Android Studio突然编译不了了,报了如下错误:

Error:Could not find property 'compile' on org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated@1b3472dc.

如下图所示:

2.解决方法

根据上面的提示,我去打开了build.gradle文件,发现我的build.gradle文件不知道被谁弄乱了,其中一段代码变成了如下所示:

1、错误原因

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    //监测内存泄漏
    //    debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3'
    //    releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'
    compile(name: 'common-release', ext: 'aar')
    compile(name: 'sync-release', ext: 'aar')
//  compile 'com.squareup.picasso:picasso:2.5.2'
compile
    'com.android.support:appcompat-v7:23.3.0'compile
    'com.android.support:design:23.3.0'compile
    'com.fasterxml.jackson.core:jackson-databind:2.7.0'compile
    'com.squareup.retrofit2:retrofit:2.0.0'compile
    'com.squareup.retrofit2:converter-jackson:2.0.0'compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0'
    compile 'io.reactivex:rxandroid:1.1.0'
    compile 'com.j256.ormlite:ormlite-core:4.48'
    compile 'com.j256.ormlite:ormlite-android:4.48'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'org.greenrobot:eventbus:3.0.0'
    compile 'com.github.bumptech.glide:glide:3.6.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha3'
    testCompile 'junit:junit:4.12'
    testCompile 'org.powermock:powermock-module-junit4:1.6.4'
    testCompile 'org.powermock:powermock-api-mockito:1.6.4'
    testCompile 'org.robolectric:robolectric:3.0'
}

如图所示:

2、解决方法

将上面的gradle文件重新排版,修改为如下所示的代码:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    //监测内存泄漏
    //    debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3'
    //    releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'
    compile(name: 'common-release', ext: 'aar')
    compile(name: 'sync-release', ext: 'aar')
//  compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:design:23.3.0'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.7.0'
    compile 'com.squareup.retrofit2:retrofit:2.0.0'
    compile 'com.squareup.retrofit2:converter-jackson:2.0.0'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0'
    compile 'io.reactivex:rxandroid:1.1.0'
    compile 'com.j256.ormlite:ormlite-core:4.48'
    compile 'com.j256.ormlite:ormlite-android:4.48'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'org.greenrobot:eventbus:3.0.0'
    compile 'com.github.bumptech.glide:glide:3.6.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha3'
    testCompile 'junit:junit:4.12'
    testCompile 'org.powermock:powermock-module-junit4:1.6.4'
    testCompile 'org.powermock:powermock-api-mockito:1.6.4'
    testCompile 'org.robolectric:robolectric:3.0'
}

如下图所示:

然后重新编译代码,即可正常。

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

时间: 2024-09-19 09:01:56

我的Android进阶之旅------>解决Error:Could not find property 'compile' on org.gradle.api.internal.artifacts.的相关文章

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

错误描述 今天在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 unexp

【我的Android进阶之旅】解决 Error:CreateProcess error=216, 该版本的 %1 与您运行的 Windows 版本不兼容。请查看计算机的系统信息,了解是否需要 x86

一.错误描述 刚刚打开Android Studio新建一个项目,然后就编译不了,报了如下所示的错误: 错误描述为: Error:CreateProcess error=216, 该版本的 %1 与您运行的 Windows 版本不兼容.请查看计算机的系统信息,了解是否需要 x86 (32 位)或 x64 (64 位)版本的程序,然后联系软件发布者. 分析错误 原来是因为JDK版本和之前配置的JDK版本不一致导致的. 1.查看系统的JDK版本 系统JDK之前从JDK1.7升级到了JDK1.8,如下图

我的Android进阶之旅------>解决:debug-stripped.ap_' specified for property 'resourceFile' does not exist.

1.错误描述 更新Android Studio到2.0版本后,出现了编译失败的问题,我clean project然后重新编译还是出现抑郁的问题,问题具体描述如下所示: Error:A problem was found with the configuration of task ':watch:packageOfficialDebug'. > File 'D:\Code\XTC_VersionCompatible\watch\build\intermediates\res\resources-

我的Android进阶之旅------>解决Error: specified for property 'mergedManifest' does not exist.

错误描述 刚运行从Github上面下载而来的代码时,爆了如下所示的bug,错误描述如下所示: Error:A problem was found with the configuration of task ':app:generateDebugInstantRunAppInfo'. > File 'F:\Multi-Thread Download\MultiThreadDownload\app\build\intermediates\bundles\debug\instant-run\Andr

我的Android进阶之旅------>解决 Error: ShouldNotReachHere() 问题

在Android项目中创建一个包含main()方法的类,直接右键运行该类时会报如下错误: # # An unexpected error has been detected by Java Runtime Environment: # # Internal Error (classFileParser.cpp:2923), pid=7780, tid=7832 # Error: ShouldNotReachHere() # # Java VM: Java HotSpot(TM) Client V

【我的Android进阶之旅】解决AndroidStudio编译时报错:Timeout waiting to lock artifact cache .

1. 错误描述 今天在Android Studio中,使用gradle命令的时候,出现了如下所示的错误: D:\GitLab Source\XTCLint>gradlew clean uploadArchives --stacktrace Starting a Gradle Daemon, 1 busy and 1 incompatible Daemons could not be reused, use --status for details FAILURE: Build failed wi

我的Android进阶之旅------>解决Jackson等第三方转换Json的开发包在开启混淆后转换的实体类数据都是null的bug

1.错误描述 今天测试人员提了一个bug,说使用我们的app出现了闪退的bug,后来通过debug断点调试,发现我们的app转换服务器发送过来的json数据后,都是为null.而之前已经提测快一个月的功能,一直都是稳定的,为什么现在会报java.lang.NullPointerException. 2.错误原因 原来我提测了一个月的APP版本一直没有打开混淆开关,而出问题的这个APP版本在即将要发布出去的时候打开了混淆开关.这样的话,我那些要通过转换json数据为bean实体类,因为没有在pro

【我的Android进阶之旅】解决Center OS 64位系统编译Android APP报错error=2和finished with non-zero exit value 127

一.错误描述 1.问题 java.io.IOException: error=2, 没有那个文件或目录 今天在刚重新搭建好的64位的Center OS上安装好了Android SDK,Jenkins,Git等一系列用于持续集成的环境之后,准备编译下项目试一试,然后Jenkins编译失败,错误如下所示: Caused by: java.io.IOException: Cannot run program "/usr/local/share/adt-bundle-linux-x86_64-20140

【我的Android进阶之旅】解决strings.xml格式化占位符错误: Multiple substitutions specified in non-positional format

今天有一个Android新手使用strings.xml进行格式化的时候报了占位符错误, Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute? ,问我该如何解决? 一.错误描述 具体错误描述如下所示: D:\Code_For_Android_Studio\MyGame2048\app\build\intermediate