2017-08-22 18 views
3

私はDagger 2.11をAndroid Injectionで使用しています。 多量の依存関係を追加した後、私はMultiDexを有効にする必要がありました。Dagger 2とMultidexアプリケーション

Multidexのサポートは、Android 4.4で期待通りに動作し、Android> = 6で動作するようになりました。私は運で、私はmultiDexKeepProguardで使用するファイルに"dagger.internal.Preconditions"を追加するためにしようと試み

Caused by: java.lang.ClassNotFoundException: Didn't find class "dagger.internal.Preconditions" on path: DexPathList[[zip file... 

問題が唯一のAndroid 5に表示され、5.1私は次のエラーを取得します。

build.gradleファイル

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

    dependencies { 
     classpath 'io.fabric.tools:gradle:1.+' 
    } 
} 

repositories { 
    maven { url 'https://maven.fabric.io/public' } 
} 
apply plugin: 'com.android.application' 
apply plugin: 'io.fabric' 
apply plugin: 'com.tmiyamon.config' 

apply plugin: 'me.tatarka.retrolambda' 
apply plugin: 'com.tmiyamon.config' 
apply plugin: 'realm-android' 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.3" 
    defaultConfig { 
     applicationId "appId" 
     minSdkVersion 19 
     targetSdkVersion 25 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
     vectorDrawables.useSupportLibrary = true 
     multiDexEnabled true 

    } 
    dexOptions { 
     preDexLibraries false 
     javaMaxHeapSize "4g" 
    } 

    compileOptions { 
     sourceCompatibility JavaVersion.VERSION_1_8 
     targetCompatibility JavaVersion.VERSION_1_8 
    } 

    signingConfigs { 
     debug { 
      storeFile file("path") 
      keyAlias "alias" 
      storePassword "password" 
      keyPassword "password" 
     } 

     release { 
      storeFile file("path") 
      keyAlias "alias" 
      storePassword "password" 
      keyPassword "password" 
     } 
    } 

    buildTypes { 
     debug { 
      signingConfig signingConfigs.debug 
      minifyEnabled false 
      zipAlignEnabled false 
      testCoverageEnabled false 
      multiDexKeepProguard file('multidex-config.pro') 
      proguardFiles fileTree(dir: 'proguard').asList().toArray() 
     } 
     release { 
      minifyEnabled true 
      multiDexKeepProguard file('multidex-config.pro') 
      proguardFiles fileTree(dir: 'proguard').asList().toArray() 
      signingConfig signingConfigs.release 
     } 
    } 

    productFlavors { 
     local { 
      applicationIdSuffix ".local" 
      versionNameSuffix " Local " + calculateVersionNameSuffix() 
     } 

     staging { 
      applicationIdSuffix ".staging" 
      versionNameSuffix " Staging " + calculateVersionNameSuffix() 
     } 

     production { 

     } 
    } 
} 
dependencies { 
long list of dependencies 
} 

とマニフェストファイル:

<manifest package="package" 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools"> 

<< permissions >> 
<!--${applicationId}--> 
<application 
    android:name=".application.MyApplication" 
    android:allowBackup="false" 
    android:icon="@mipmap/ic_launcher" 
    android:label="${launcherAppName}" 
    android:roundIcon="@mipmap/ic_launcher_round" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme" 
    tools:replace="android:label"> 
    <activity 
     android:name=".ui.startup.StartupActivity" 
     android:screenOrientation="portrait"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN"/> 
      <category android:name="android.intent.category.LAUNCHER"/> 

rest of the Manifest.... 
+0

あなたのGradleのビルドファイルとAndroid.xmlファイルを投稿してくださいすることができます? –

+0

確かに、私にほんの少しの時間を与える – Eddy

+0

あなたは次のスレッドを確認してくださいできますか?https://stackoverflow.com/questions/45672340/android-classnotfoundexception-while-class-is-present/45672463#45672463多分あなたはAndroid Multidexアプリケーションクラスを定義する必要があります –

答えて

0

さて、最後に、私は解決策を見つけました。

私はbuiild.gradleファイルのbuildTypes部分にも

multiDexKeepFile file('multidex-config.txt') 

を追加しました。

release { 
     minifyEnabled true 
     zipAlignEnabled true 
     multiDexKeepFile file('multidex-config.txt') 
     multiDexKeepProguard file('multidex-config.pro') 
     proguardFiles fileTree(dir: 'proguard').asList().toArray() 
     signingConfig signingConfigs.release 
     debuggable false 
    } 

multidex-config.txtをには、以下があります:

今では、以下のようになります

dagger/internal/Preconditions.class 
関連する問題