LoginSignup
1
0

More than 5 years have passed since last update.

Android Wearのプロジェクトをプロジェクトを作成するとError:Execution failed for task ':mobile:transformClassesWithDexForDebug'.になる

Posted at

Android StudioでWearアプリのためのプロジェクトを作成したらエラーになるのでメモしておく。

起こったこと

普通にビルドしようとした際に下記エラーとなる。

Error:Execution failed for task ':mobile: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

起こってる人は結構多いみたい
Error:Execution failed for task ':app:transformClassesWithDexForDebug'

原因

ビルド時に Unable to execute dex: method ID not in [0, 0xffff]: 65536 が出た場合の対処
に記載されていることと同様かと思いますが、メソッド数の上限を超過している…らしい?
今ひとつわかりませんでした…

やったこと

最初にやったこと

そもそも、Android Wearのアプリ用のプロジェクトを作成しました。
Android Studioで File > New > New Project… で新しいプロジェクトを作成する。
プロジェクトはwearもありきで作成する。
これだけで、本事象は発生します。

対処としてやったこと

  1. build.gradle(mobile)にMultidexを有効にする旨を記載
  2. AndroidManifest.xmlにMultiDexApplicationであることを記載
build.gradle(mobile)
    defaultConfig {
     ..
        multiDexEnabled true
    }
dependencies {
     ..
    compile 'com.android.support:multidex:1.0.0'
}
AndroidManifest.xml
    <application
     ..
        android:name="android.support.multidex.MultiDexApplication">
     ..
    </application>

以上。もっとちゃんと原因とか内容まで理解したい…

1
0
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
1
0