Android Studio导入项目的遇到的两个问题

1.运行项目的时候出现这个错误:

方法:把Top-level build file修改为这个样子

build.gradle:

[java]  view plain  copy
  1. "color:#009900;">"background-color:#2b2b2b;color:#a9b7c6;font-family:'宋体';font-size:13.5pt;">"color:#808080;">// Top-level build file where you can add configuration options common to all sub-projects/modules.  
  2. buildscript {  
  3.     repositories {  
  4.         jcenter()  
  5.     }  
  6.     dependencies {  
  7.         classpath "color:#6a8759;">'com.android.tools.build:gradle:1.5.0'  
  8. "color:#6a8759;">  
  9. "color:#6a8759;">        "color:#808080;">// NOTE: Do not place your application dependencies here; they belong  
  10. "color:#808080;">        // in the individual module build.gradle files  
  11. "color:#808080;">    }  
  12. }  
  13. allprojects {  
  14.     repositories {  
  15.         jcenter()  
  16.     }  
  17. }  
  18. task clean("color:#d0d0ff;">type"color:#769aa5;">Delete) {  
  19.     delete "color:#9876aa;">rootProject."color:#9876aa;">buildDir  
  20. }  
 
  
当然build tools plugin版本还是写你AndroidStudio中的版本(我的是1.5.0),主要是把dependencies{...}  android{...}删掉,我是这样做的。然后去sync project with gradle,发现问题解决了。

2.当使用到NDK出现的问题:

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


你可能感兴趣的:(AndroidStudio)