MDA/MDD/TDD/DDD/DDDDDDD
posts - 536, comments - 111, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

android开发环境的几个问题

Posted on 2016-10-13 21:25 leekiang 阅读(3787) 评论(0)  编辑  收藏 所属分类: android
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: ..app\build\intermediates\res\merged\debug/values-b+sr+Latn

13.invalid resource directory name: ..app\build\intermediates\res\merged\debug/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

25.如何修改生成的apk的名字
http://www.jianshu.com/p/93051c9e97fb
Android Studio如何发布APK:http://chenfeicqq.iteye.com/blog/1889160

26. 在gradle.properties中增加android.enableBuildCache=true,貌似能加快编译速度。

只有注册用户登录后才能发表评论。


网站导航: