1.Android Studio出现Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id ‘com.android.internal.application’]
解决:在项目中的gradle.properties文件中添加语句:android.overridePathCheck=true 然后刷新即可
2.找不到工具栏里点击“Sync Project with Gradle Files”按钮时,解决:在view里勾选toolbar
3.the destination folder does not exist or is not writeable 解决:目录不可写或不存在,检查路径或新建文件夹
4.Could not GET XXX 报错时 
依赖无法正确加载,大概率是因为2021年5月1日后JFrog停止了Jcenter和Bintray的服务,导致项目依赖的轮子无法正常加载。建议去找对应框架的wiki里找到最新版本,看看作者有没有迁移到新的仓库。
比如:友盟+的sdk 由原来的maven { url 'https://dl.bintray.com/umsdk/release' } 修改为:maven { url 'https://repo1.maven.org/maven2/' })在工程build.gradle配置脚本中buildscript和allprojects段中修改
5.One or more issues found when checking AAR metadata values  需改:build.gradle     compileSdkVersion 30 改为 31
6.Compatible side by side NDK version was not found. Default is 20.0.5594570
解决方案:tools–>sdk manager–>Android sdk–>sdk tools–>勾选show package detail–>找到NDK(side by side) 具体版本,完成下载并安装即可

其它问题:
1. Android Studio2.2在mac下启动报错
找不到原因,改为使用Android Studio 2.1.3 
下载地址:http://tools.android.com/download/studio/builds/2-1-3 

2. 编译某项目报错Could not find property 'config' on SigningConfig container 
在build.grade文件的android->signingConfigs节点下增加config配置 
android {
    signingConfigs {
        config {
            keyAlias '你的key别名'
            keyPassword '你的key密码'
            storeFile file('你的密钥存储路径')
            storePassword '你的存储密码'
        }
    } 
...

3. 编译报错failed to find target android-22
/Users/username/Library/Android/sdk/platforms下发现有android-24目录,故将编译级别都设为24。
修改build.grade文件的相关属性:
compileSdkVersion 24
buildToolsVersion "24.0.0"
targetSdkVersion 24
compile 'com.android.support:appcompat-v7:24.0.0'

4. 编译报错Gradle sync failed: Gradle DSL method not found: 'android()'
删除项目根目录下的build.gradle文件,因为app目录下已经有build.gradle了。
备份下根目录下build.gradle文件的内容:
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
    }
}
android {
    compileSdkVersion 24
}
dependencies {
}
5. 编译报错Plugin with id 'com.android.application' not found
恢复项目根目录下的build.gradle文件,将内容修改为如下:
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
    }
}

6. 编译报错:failed to find Build Tools revision 24.0.0
/Users/username/Library/Android/sdk/build-tools下查看自己的BuildTools版本,发现是24.0.3,然后将buildToolsVersion修改为该版本:
buildToolsVersion "24.0.3"

7. Android Studio编译执行以下任务时一直等待,执行了一个小时也没动静。
Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:prepareDebugUnitTestDependencies, :app:mockableAndroidJar]
打开Preferences->Build-Excecution-Deployment->BuildTools->Gra‌​dle,勾选Offline work
参见http://stackoverflow.com/questions/25629368/how-to-fix-android-studio-getting-stuck-executing-gradle-tasks

8. Exception in thread "png-cruncher_5" java.lang.RuntimeException: Timed out while waiting for slave aapt process
不知道原因,最终是通过修改SDK Build Tools为19.1.0、升级JDK由JDK7升至JDK8、增加环境变量SLAVE_AAPT_TIMEOUT=30等搞定的

9. 如何修改SDK和JDK的路径
在File->Project Structure里修改

10. 修改Android Studio中java代码的编译级别
打开File --> Project Structure-->app,修改Source Compatibility和Target Compatibility
11.如何在使用gradle时增加--stacktrace参数
Preferences->Build-Excecution-Deployment->Compiler
增加--info或--debug,在解决报错时能看到更多的信息
12. 报错aapt ..finished with non- zero exit value 1
找不到原因,增加编译参数--info后发现有用的信息:invalid resource directory name: ..appbuildintermediatesresmergeddebug/values-b+sr+Latn

13.invalid resource directory name: ..appbuildintermediatesresmergeddebug/values-b+sr+Latn
不知道原因,将版本升级到21解决了。

14. 编译时报找不到AppCompatActivity类的错误
改为使用:compile 'com.android.support:appcompat-v7:22.2.1'
同时将版本由21升级到22

15. 生成apk时报错:Missing Gradle Project Information. Please check if the IDE successfully synchronized its state with the Gradle Project Model
在工具栏里点击“Sync Project with Gradle Files”按钮

16.导入某项目时报错Error:Gradle version 2.14.1 is required. Current version is 2.4. If using the gradle wrapper, try editing the distributionUrl in...
打开Android Studio的File->Project Structure,点击Project,将Gradle version修改为2.14.1
在/Applications/Android Studio.app/Contents/gradle下的确只有gradle-2.14.1

17. 在gradle.properties中增加android.enableBuildCache=true,貌似能加快编译速度。
版权信息:本站所有资源仅供学习与参考,请勿用于商业用途,如有侵犯您的版权,请及时联系客服,我们将尽快处理

分享链接

评论 (0)

请登录

嘿,我来帮您