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

这里写图片描述

相关文章
|
11月前
|
存储 机器学习/深度学习 API
Android API Level 到底是什么?和安卓什么关系?应用发布如何知道自己的版本?优雅草卓伊凡
Android API Level 到底是什么?和安卓什么关系?应用发布如何知道自己的版本?优雅草卓伊凡
1669 31
Android API Level 到底是什么?和安卓什么关系?应用发布如何知道自己的版本?优雅草卓伊凡
|
编译器 API Android开发
Android经典实战之Kotlin Multiplatform 中,如何处理不同平台的 API 调用
本文介绍Kotlin Multiplatform (KMP) 中使用 `expect` 和 `actual` 关键字处理多平台API调用的方法。通过共通代码集定义预期API,各平台提供具体实现,编译器确保正确匹配,支持依赖注入、枚举类处理等,实现跨平台代码重用与原生性能。附带示例展示如何定义跨平台函数与类。
770 0
|
API Android开发
Android高手进阶教程(十五)之---通过Location获取Address的使用!
Android高手进阶教程(十五)之---通过Location获取Address的使用!
275 1
|
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`参数来解决权限不足的问题。
3232 1
|
Android开发 iOS开发
[ionic]解决运行Android、IOS出现Could not find the web assets directory
[ionic]解决运行Android、IOS出现Could not find the web assets directory
364 1
|
API Android开发 开发者
`RecyclerView`是Android API 21引入的UI组件,用于替代ListView和GridView
【6月更文挑战第26天】`RecyclerView`是Android API 21引入的UI组件,用于替代ListView和GridView。它提供高效的数据视图复用,优化的布局管理,支持多种布局(如线性、网格),并解耦数据、适配器和视图。RecyclerView的灵活性、性能(如局部刷新和动画支持)和扩展性使其成为现代Android开发的首选,特别是在处理大规模数据集时。
569 2
【Azure API 管理】解决API Management添加AAD Group时遇见的 Failed to query Azure Active Directory graph due to error 错误
【Azure API 管理】解决API Management添加AAD Group时遇见的 Failed to query Azure Active Directory graph due to error 错误
157 0
|
Java 关系型数据库 数据库连接
实时计算 Flink版操作报错之遇到错误org.apache.flink.table.api.ValidationException: Could not find any factory for identifier 'jdbc',该如何解决
在使用实时计算Flink版过程中,可能会遇到各种错误,了解这些错误的原因及解决方法对于高效排错至关重要。针对具体问题,查看Flink的日志是关键,它们通常会提供更详细的错误信息和堆栈跟踪,有助于定位问题。此外,Flink社区文档和官方论坛也是寻求帮助的好去处。以下是一些常见的操作报错及其可能的原因与解决策略。
|
API
Taro——Error: Can't resolve '@/api/xxx'
在使用 `@` 符号进行导入时遇到加载失败的问题,检查 `tsconfig.json` 后发现 `paths` 配置无误。怀疑可能是 Taro(版本 3.6.34)配置不完整导致。查阅官方文档后找到解决方案;
315 0
|
缓存 网络协议 Java
挑战全网,史上最全Android开发进阶,跳槽复习指南(1),掌握这6大技能体系
挑战全网,史上最全Android开发进阶,跳槽复习指南(1),掌握这6大技能体系

推荐镜像

更多