Help us understand the problem. What is going on with this article?

AndroidStudioでFabricを導入したら実行時エラーへの対処

More than 3 years have passed since last update.

androidでFabric(Crashlytics)をインストールしたら実行時に以下のエラーが出て少しはまってしまった。

Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_31\bin\java.exe'' finished with non-zero exit value 2

さすがのstackoverflowですね
http://stackoverflow.com/questions/28640314/android-studio-fails-to-debug-with-error-org-gradle-process-internal-execexcepti

こちらに記載してあった

build.gradle
defaultConfig {
    multiDexEnabled true
}

を入れたら実行時エラーがなくなりました!

ただ、Fabricの導入時に自動でコードが追加されるのですが、
このコードも追加してほしいものですね。

追記
Android 4.xの場合に動作しなくなることがありました。以下の修正が必要です。

build.gradle
dexOptions {
    preDexLibraries false
    javaMaxHeapSize "2g"
}
・・・・
dependencies {
    compile 'com.android.support:multidex:1.0.0'
}

applicationに指定しているクラスを
android.support.multidex.MultiDexApplicationに変更
上記クラスで以下をオーバーライド

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}

これでとりあえず動くようになりました。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away