zoukankan      html  css  js  c++  java
  • Android 问题汇总(持续更新)

    Q1:Error:(93, 12) 错误: 需要常量表达式

    问题描述:这个问题是在添加一个module到项目中时遇到的,主要原因是因为原来module中的R文件是不会以final形式存在的,但是在module中的一些代码里对R中的数据使用了switch,而switch必须使用final常量:

    解决方案:将switch改为if/else就可以了。

    Q2:Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
    > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

    解决方案:在主build.gradle中添加以下语句:

    android {
        compileSdkVersion 24
        buildToolsVersion "24.0.2"
        defaultConfig {
            applicationId "com.xxx.xxx"
            minSdkVersion 16
            targetSdkVersion 24
            versionCode 1
            versionName "1.0"
            multiDexEnabled true
        }

    Q3:

    解决方案:http://m.blog.csdn.net/article/details?id=50537660

    Q4:在主module和其他module中都有继承Application的子类,并且注册了,出现冲突

    解决方案:http://stackoverflow.com/questions/19001644/how-to-handle-multiple-application-classes-in-android

    让主module的Application继承子module的Application(虽然依然不是最好的方案,但暂时也只能这样了)

    Q5:

    解决方案:

    在对应module的gradle文件中的dependencies中加上这句:

        

    testCompile 'org.json:json:20140107'
  • 相关阅读:
    11月21日
    11月20日
    11月19日
    11月18日
    11月17日
    11月15日
    图文教程:在Mac上搭建Titanium的iOS开发环境
    经验
    IT术语的正确读法
    NSLog( @"%@", i );
  • 原文地址:https://www.cnblogs.com/libertycode/p/6009295.html
Copyright © 2011-2022 走看看