方法:把Top-level build file修改为这个样子
build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript {repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
当然build tools plugin版本还是写AndroidStudio中的版本(我的是1.5.0),主要是把dependencies{...} android{...}删掉,我是这样做的。然后去sync project with gradle,发现问题解决了。
当使用到DNK出现的问题
1) Error:(199) *** Android NDK: Aborting... . Stop.
2)Error:Execution failed for task ':app:compileDebugNdk'.
解决方法:进入到app/build.gradle,进行如下修改。
sourceSets.main {
jniLibs.srcDir 'libs'
jni.srcDirs = []
}
然后去sync project with gradle,发现问题解决了。
也可以去查看stackoverflow中的解答:
http://stackoverflow.com/questions/27735646/android-studio-gradle-dsl-method-not-found-android-error17-0
http://stackoverflow.com/questions/28759505/execution-failed-for-task-appcompiledebugndk