java.lang.RuntimeException:方法代码太大

时间:2017-11-08 11:42:22

标签: java android methods

在申请中我有一个错误:

Error:Execution failed for task 
':buildPropTweakerPro:transformClassesWithInstantRunForDebug'.
 > java.lang.RuntimeException: Method code too large!

但我没有任何类,大于64KB。

我使用的Gradle版本是2.3.3

当我使用gradle版本3.0.0时,我有一个错误:

Error:Execution failed for task 
':buildPropTweakerPro:transformClassesWithInstantRunForDebug'.
 > java.lang.ClassFormatError (no error message)

我的build.gradle文件:

buildscript {
repositories {
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    classpath 'io.fabric.tools:gradle:1.24.4'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
maven { url 'https://maven.fabric.io/public' }
}


android {

compileSdkVersion 26
buildToolsVersion '27.0.1'

defaultConfig {
    applicationId "com.xxx"
    minSdkVersion 16
    versionCode 19
    versionName "1.3.3"
    multiDexEnabled true

}
dexOptions {
    javaMaxHeapSize "8g"
}

lintOptions {
    checkReleaseBuilds false
    abortOnError true
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.startapp:inapp-sdk:3.6.6'
compile 'com.google.android.gms:play-services-ads:11.4.2'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:support-core-utils:26.1.0'
compile 'com.jakewharton:butterknife:8.6.0'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
}

我在互联网上搜索了很多问题,但没有任何答案,但在错误中,我没有答案,在哪个文件中我有太大的方法。

有什么建议吗?

2 个答案:

答案 0 :(得分:3)

在android studio设置中禁用即时运行

答案 1 :(得分:1)

启用Multidex

android {    
 defaultConfig {
    // Enabling multidex support.
    multiDexEnabled true
  }  
}