eclipse迁移到studio中出现的问题

来源:互联网 发布:java十个数输出最小值 编辑:程序博客网 时间:2024/05/16 07:27

1、Error:The number of method references in a .dex file cannot exceed 64K. Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html

  出现这种情况是调用的jar太多,里面的方法超过界限,解决办法:

    1.在build.gradle中的defaultConfig{

           multiDexEnabled  true

                            }

     2.在继承Application中,重写

@Overrideprotected void attachBaseContext(Context base) {    super.attachBaseContext(base);    MultiDex.install(this);(添加这句)}

2、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.ide.common.process.ProcessException: Error while executing java process with main class com.android.dx.command.Main with arguments {--dex --num-threads=4 --multi-dex --main-dex-list D:\StudioDemo\gas-android\app\build\intermediates\multi-dex\debug\maindexlist.txt --output D:\StudioDemo\gas-android\app\build\intermediates\transforms\dex\debug\folders\1000\1f\main D:\StudioDemo\gas-android\app\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar}

    在build.gradle中的Android{

dexOptions {    javaMaxHeapSize "4g"}

}

  详细请看:http://blog.csdn.net/lxk_1993/article/details/50511172


3、Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LGPL2.1
    File1: D:\StudioDemo\gas-android\app\libs\jackson-core-lgpl-1.9.5.jar
    File2: D:\StudioDemo\gas-android\app\libs\jackson-mapper-lgpl-1.9.5.jar

   我解决的是在build.gradle中的Android{

packagingOptions {    exclude 'META-INF/DEPENDENCIES.txt'    exclude 'META-INF/LICENSE.txt'    exclude 'META-INF/NOTICE.txt'    exclude 'META-INF/NOTICE'    exclude 'META-INF/LICENSE'    exclude 'META-INF/DEPENDENCIES'    exclude 'META-INF/notice.txt'    exclude 'META-INF/license.txt'    exclude 'META-INF/dependencies.txt'    exclude 'META-INF/LGPL2.1'}
我的根据网上的只添加几个是没有效果的,必须添加这些

}



原创粉丝点击