Android studio导入项目时遇到如下错误如何解决?
> Failed to find target with hash string 'android-23' in: C:\Users\Administrator\AppData\Local\Android\Sdk 展开
方法:把Top-level build file修改为这个样子
build.gradle:
<span style="color:#009900;"></span><pre style="background-color:#2b2b2b;color:#a9b7c6;font-family:'宋体';font-size:13.5pt;"><span style="color:#808080;">// Top-level build file where you can add configuration options common to all sub-projects/modules.
</span>buildscript {
repositories {
jcenter()
}
dependencies {
classpath <span style="color:#6a8759;">'com.android.tools.build:gradle:1.5.0'
</span><span style="color:#6a8759;">
</span><span style="color:#6a8759;"> </span><span style="color:#808080;">// NOTE: Do not place your application dependencies here; they belong
</span><span style="color:#808080;"> // in the individual module build.gradle files
</span><span style="color:#808080;"> </span>}
}
allprojects {
repositories {
jcenter()
}
}
task clean(<span style="color:#d0d0ff;">type</span>: <span style="color:#769aa5;">Delete</span>) {
delete <span style="color:#9876aa;">rootProject</span>.<span style="color:#9876aa;">buildDir
</span>}
当然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
广告 您可能关注的内容 |