6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Building Apps with Over 65K Methods

Last updated at Posted at 2015-07-27

AndroidStudioでアプリを開発している際に、メソッド数が65000を超えてしまった場合の対策例

#####まず、ビルド実行時に下記のエラーのいずれかまたは複数がでたとき可能性がある

java.lang.IllegalArgumentException: method ID not in [0, 0xffff]: 65536
 
Error:Execution failed for task ':your appname:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2
 
 
Error:Execution failed for task ':your appneme:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java'' finished with non-zero exit value 3

#####私が行った対策を下記に記す
AndroidManifest.xml に以下を追加

<application
android:name="android.support.multidex.MultiDexApplication"

build.gradleを変更

(省略)
dependencies {
  …
        compile 'com.android.support:multidex:1.0.0'  //これを追加
  …
}
 
 
android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"
 
    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 16
        versionCode 1
        versionName "1.0"
        multiDexEnabled = true
    }
 
    dexOptions {
        incremental true
        javaMaxHeapSize "4g"
    }
    ...
}
 
(省略)

#####まとめ
Multidexを設定することで今回は対策できたが、バージョンなど制約があるので、
ProGuardを使って、解決するほうが良いみたいである。

参考:
Building Apps with Over 65K Methods

http://developer.android.com/tools/building/multidex.html

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?