我的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.

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

这里写图片描述

相关文章
|
2天前
|
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.
19 0
|
2天前
|
开发工具 Android开发 git
解决Android AAPT: error: resource android:attr/lStar not found. 问题
解决Android AAPT: error: resource android:attr/lStar not found. 问题
74 0
|
2天前
|
API Android开发
Android高手进阶教程(十五)之---通过Location获取Address的使用!
Android高手进阶教程(十五)之---通过Location获取Address的使用!
12 1
|
19小时前
|
缓存 网络协议 Java
挑战全网,史上最全Android开发进阶,跳槽复习指南(1),掌握这6大技能体系
挑战全网,史上最全Android开发进阶,跳槽复习指南(1),掌握这6大技能体系
|
21小时前
|
Java 测试技术 Android开发
Android Gradle 干货,看这篇文章就行了
Android Gradle 干货,看这篇文章就行了
|
1天前
|
消息中间件 缓存 架构师
2024年阿里Android高级面试题分享,附学习笔记+面试整理+进阶书籍
2024年阿里Android高级面试题分享,附学习笔记+面试整理+进阶书籍
|
2天前
|
开发工具 Android开发 Windows
Android应用] 问题2:ERROR: unknown virtual device name:
Android应用] 问题2:ERROR: unknown virtual device name:
11 2
|
2天前
|
Java Android开发
Android零基础入门(二)gradle的安装和详解
Android零基础入门(二)gradle的安装和详解
17 0
|
2天前
|
Android开发 开发者
安卓投屏神器 Scrcpy安 报错ERROR: Could not find any ADB device
使用Scrcpy安卓投屏工具时遇到报错,问题根源是未开启开发者模式。解决步骤:进入设置,点击【关于手机】→连续点击版本号激活开发者模式,然后在【系统设置】→【开发者选项】中开启USB调试。参照此方法后可正常执行。Scrcpy软件下载链接和GitHub页面也已提供。
45 1
|
2天前
|
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
23 0

热门文章

最新文章