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