Many issues after upgrading to Android Studio 1.0

2019-06-24 19:05发布

So I was using Android Studio 0.8+ (I think 0.86) and everything was working and compiling fine until I upgraded to Android Studio 1.0 and all hell broke lose when trying to compile and execute:

  1. No such property: proRunguard

    • Fixed by changing "runProguard = enabled" to "minifyEnabled = true" in the Gradle file
  2. com.android.dex.DexIndexOverflowException

Error:Execution failed for task ':onz:dexDebug'. com.android.ide.common.internal.LoggedErrorException: Failed to run command: /Users/JustinLeo/Library/Android/sdk/build-tools/21.1.1/dx --dex --no-optimize --output /Users/JustinLeo/Dropbox/ONz (1)/App Development/Android/onz/onz/build/intermediates/dex/debug --input-list=/Users/JustinLeo/Dropbox/ONz (1)/App Development/Android/onz/onz/build/intermediates/tmp/dex/debug/inputList.txt Error Code: 2 Output: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536 at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502) at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277) at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168) at com.android.dx.merge.DexMerger.merge(DexMerger.java:189) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:302) at com.android.dx.command.dexer.Main.run(Main.java:245) at com.android.dx.command.dexer.Main.main(Main.java:214) at com.android.dx.command.Main.main(Main.java:106)

  • added "multiDexEnabled = true" in the Gradle file

    1. java.lang.OutOfMemoryError: GC overhead limit exceeded

Error:Execution failed for task ':onz:dexDebug'. com.android.ide.common.internal.LoggedErrorException: Failed to run command: /Users/JustinLeo/Library/Android/sdk/build-tools/21.1.1/dx --dex --no-optimize --multi-dex --main-dex-list /Users/JustinLeo/Dropbox/ONz (1)/App Development/Android/onz/onz/build/intermediates/multi-dex/debug/maindexlist.txt --output /Users/JustinLeo/Dropbox/ONz (1)/App Development/Android/onz/onz/build/intermediates/dex/debug --input-list=/Users/JustinLeo/Dropbox/ONz (1)/App Development/Android/onz/onz/build/intermediates/tmp/dex/debug/inputList.txt Error Code: 3 Output: warning: Ignoring InnerClasses attribute for an anonymous inner class (com.amazonaws.javax.xml.stream.StaxErrorReporter$1) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.amazonaws.javax.xml.stream.XMLReaderImpl$1) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.amazonaws.javax.xml.stream.xerces.util.SecuritySupport12$1) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.amazonaws.javax.xml.stream.xerces.util.SecuritySupport12$2) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.amazonaws.javax.xml.stream.xerces.util.SecuritySupport12$3) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (com.amazonaws.javax.xml.stream.xerces.util.SecuritySupport12$4) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (org.apache.commons.logging.LogFactory$1) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (org.apache.commons.logging.LogFactory$2) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (org.apache.commons.logging.LogFactory$3) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (org.apache.commons.logging.LogFactory$4) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (org.apache.commons.logging.LogFactory$5) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (org.apache.commons.logging.LogFactory$6) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (org.apache.commons.logging.impl.LogFactoryImpl$1) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (org.apache.commons.logging.impl.LogFactoryImpl$2) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (org.apache.commons.logging.impl.LogFactoryImpl$3) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (org.apache.commons.logging.impl.SimpleLog$1) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (org.apache.commons.logging.impl.WeakHashtable$1) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class. UNEXPECTED TOP-LEVEL ERROR: java.lang.OutOfMemoryError: GC overhead limit exceeded at com.android.dx.cf.code.RopperMachine.run(RopperMachine.java:609) at com.android.dx.cf.code.Simulator$SimVisitor.visitConstant(Simulator.java:691) at com.android.dx.cf.code.BytecodeArray.parseInstruction(BytecodeArray.java:772) at com.android.dx.cf.code.Simulator.simulate(Simulator.java:94) at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:787) at com.android.dx.cf.code.Ropper.doit(Ropper.java:742) at com.android.dx.cf.code.Ropper.convert(Ropper.java:349) at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:280) at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137) at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93) at com.android.dx.command.dexer.Main.processClass(Main.java:729) at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673) at com.android.dx.command.dexer.Main.access$300(Main.java:82) at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602) at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284) at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166) at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144) at com.android.dx.command.dexer.Main.processOne(Main.java:632) at com.android.dx.command.dexer.Main.processAllFiles(Main.java:505) at com.android.dx.command.dexer.Main.runMultiDex(Main.java:332) at com.android.dx.command.dexer.Main.run(Main.java:243) at com.android.dx.command.dexer.Main.main(Main.java:214) at com.android.dx.command.Main.main(Main.java:106)

  • Added the following:

dexOptions { javaMaxHeapSize "4g" }

4 Now it compiles and executes! But as soon as the app starts it crashes before even showing the first activity:

12-12 11:06:31.529 19499-19499/com.commonextract.fitmalaysia E/dalvikvm﹕ Could not find class 'com.commonextract.fitmalaysia.LoginFragment$4', referenced from method com.commonextract.fitmalaysia.LoginFragment. 12-12 11:06:31.529 19499-19499/com.commonextract.fitmalaysia W/dalvikvm﹕ VFY: unable to resolve new-instance 3315 (Lcom/commonextract/fitmalaysia/LoginFragment$4;) in Lcom/commonextract/fitmalaysia/LoginFragment; 12-12 11:06:31.539 19499-19499/com.commonextract.fitmalaysia E/dalvikvm﹕ Could not find class 'com.commonextract.fitmalaysia.LoginFragment$3', referenced from method com.commonextract.fitmalaysia.LoginFragment.onSessionStateChange 12-12 11:06:31.539 19499-19499/com.commonextract.fitmalaysia W/dalvikvm﹕ VFY: unable to resolve new-instance 3314 (Lcom/commonextract/fitmalaysia/LoginFragment$3;) in Lcom/commonextract/fitmalaysia/LoginFragment; 12-12 11:06:31.549 19499-19499/com.commonextract.fitmalaysia E/dalvikvm﹕ Could not find class 'com.commonextract.fitmalaysia.LoginFragment$5', referenced from method com.commonextract.fitmalaysia.LoginFragment.displayOkAlert 12-12 11:06:31.549 19499-19499/com.commonextract.fitmalaysia W/dalvikvm﹕ VFY: unable to resolve new-instance 3316 (Lcom/commonextract/fitmalaysia/LoginFragment$5;) in Lcom/commonextract/fitmalaysia/LoginFragment; 12-12 11:06:31.549 19499-19499/com.commonextract.fitmalaysia E/dalvikvm﹕ Could not find class 'com.commonextract.fitmalaysia.LoginFragment$1', referenced from method com.commonextract.fitmalaysia.LoginFragment.onCreateView 12-12 11:06:31.549 19499-19499/com.commonextract.fitmalaysia W/dalvikvm﹕ VFY: unable to resolve new-instance 3312 (Lcom/commonextract/fitmalaysia/LoginFragment$1;) in Lcom/commonextract/fitmalaysia/LoginFragment; 12-12 11:06:31.549 19499-19499/com.commonextract.fitmalaysia W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41789d58) 12-12 11:06:31.559 19499-19499/com.commonextract.fitmalaysia E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.commonextract.fitmalaysia, PID: 19499 java.lang.NoClassDefFoundError: com.commonextract.fitmalaysia.LoginFragment$4 at com.commonextract.fitmalaysia.LoginFragment.(LoginFragment.java:346) at com.commonextract.fitmalaysia.LoginActivity.onResume(LoginActivity.java:104) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1192) at android.app.Activity.performResume(Activity.java:5321) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2767) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2806) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2241) at android.app.ActivityThread.access$800(ActivityThread.java:138) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1199) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5034) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:805) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:621) at dalvik.system.NativeStart.main(Native Method)

Here is my gradle file:

apply plugin: 'android'

android {
    compileSdkVersion 21
    buildToolsVersion '21.1.1'
    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 10
        versionName '1.0.11'
        applicationId 'com.commonextract.fitmalaysia'
        multiDexEnabled = true
    }
    buildTypes {
        release {
            minifyEnabled = true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    productFlavors {
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
}

    dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':libs:facebook')
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.android.support:gridlayout-v7:21.0.3'

    compile 'com.google.android.gms:play-services:6.1.+'
    compile files('libs/aws-android-sdk-2.0.5-s3.jar')
    compile files('libs/aws-android-sdk-2.0.5-core.jar')
}

And my file structure:

file structure

Sorry for the long post, but I wanted to detail every step in case there was a problem in between. I really don't know what's the problem now since I did not modify anything in my codes prior to upgrading. Please help, thanks.

0条回答
登录 后发表回答