2017-07-31 3 views
1

J'ai activé miltidex dans mon application. Api 21+ fonctionne bien. Android api 16 causes:Android butterknife multidex

java.lang.NoClassDefFoundError: ......AuthorizationController 

Si je commente tout la liaison BN fonctionne très bien. Multidex activé: multiDexEnabled true, compile 'com.android.support:multidex:1.0.1' et ainsi de suite. Y at-il un moyen de le faire fonctionner?

EDIT

gradle

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

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

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


    android { 
     signingConfigs { 
      prod_release { 
... 
      } 
     } 
     compileSdkVersion 25 
     buildToolsVersion "25.0.3" 
     productFlavors { 
      dev { 
       // Enable pre-dexing to produce an APK that can be tested on 
       // Android 5.0+ without the time-consuming DEX build processes. 
       minSdkVersion 16 
       signingConfig signingConfigs.prod_release 
      } 
      prod { 
       // The actual minSdkVersion for the production version. 
       minSdkVersion 16 
       signingConfig signingConfigs.prod_release 
      } 
     } 
     defaultConfig { 
      applicationId "ru.wearemad.gravo" 
      targetSdkVersion 25 
      versionCode 1 
      versionName "1.0" 
      multiDexEnabled true 
      testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
     } 
     dexOptions { 
      javaMaxHeapSize "2g" 
      preDexLibraries = false 
     } 
     buildTypes { 
      release { 
       minifyEnabled false 
       proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
       signingConfig signingConfigs.prod_release 
      } 
      debug { 
       signingConfig signingConfigs.prod_release 
      } 
     } 
    } 

    dependencies { 
     compile fileTree(include: ['*.jar'], dir: 'libs') 
     androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
      exclude group: 'com.google.code.findbugs' 
      exclude group: 'com.android.support', module: 'support-annotations' 
     }) 
     compile 'com.android.support:appcompat-v7:25.3.1' 
     compile 'com.android.support:design:25.3.1' 
     //retrofit 
     compile 'com.squareup.retrofit2:retrofit:2.3.0' 
     compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0' 
     compile 'com.squareup.retrofit2:converter-gson:2.3.0' 
     compile 'com.squareup.okhttp3:logging-interceptor:3.8.0' 
     //rxjava 2 
     compile 'io.reactivex.rxjava2:rxandroid:2.0.1' 
     compile 'io.reactivex.rxjava2:rxjava:2.1.1' 
     //butterknife 
     compile 'com.jakewharton:butterknife:8.7.0' 
     annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0' 
     //mosby + conductor 
     compile 'com.bluelinelabs:conductor-support:2.1.4' 
     compile 'com.hannesdorfmann.mosby3:mvp-conductor:3.0.0' 
     compile 'com.hannesdorfmann.mosby3:viewstate:3.0.4' 
     compile 'com.hannesdorfmann.mosby3:viewstate-conductor:3.0.0' 
     compile 'com.madgag.spongycastle:core:1.54.0.0' 
     compile 'com.madgag.spongycastle:prov:1.54.0.0' 
     compile 'com.madgag.spongycastle:pkix:1.54.0.0' 
     compile 'com.madgag.spongycastle:pg:1.54.0.0' 
     // testCompile 'junit:junit:4.12' 
     compile 'de.hdodenhof:circleimageview:2.1.0' 
     compile 'com.orhanobut:hawk:1.+' 
     compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
      transitive = true; 
     } 
     compile 'com.android.support:multidex:1.0.1' 
    } 

part de Manifest:

<application 
     android:name="ru.wearemad.gravo.MyApplication" 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:screenOrientation="portrait" 
     android:roundIcon="@mipmap/ic_launcher_round" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme"> 

classe Application:

public class MyApplication extends MultiDexApplication {...} 

J'ai essayé d'ajouter multiDexKeepProguard, mais gradle ne voit pas cette méthode, ou la déclaration de la méthode a changé.

EDIT 2 Butterknife Unbinder qui est retourné dans Bitterknife.bind() fait la peine. Des idées pour réparer?

Répondre

0

Avez-vous inclus ci-dessous? Si vous ne remplacez pas la classe d'application, modifiez votre fichier manifest pour définir Android: nom dans la balise comme suit:

<?xml version="1.0" encoding="utf-8"?> 
 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
 
    package="com.example.myapp"> 
 
    <application 
 
      android:name="android.support.multidex.MultiDexApplication" > 
 
     ... 
 
    </application> 
 
</manifest>

si vous override la classe Application mais il n'est pas possible de changer la classe de base, alors vous pouvez à la place remplacer la méthode attachBaseContext() et appeler MultiDex.install (this) pour activer multidex:

public class MyApplication extends SomeOtherApplication { 
 
    @Override 
 
    protected void attachBaseContext(Context base) { 
 
    super.attachBaseContext(base); 
 
    MultiDex.install(this); 
 
    } 
 
}

Further read

+0

J'ai essayé ces méthodes: j'ai essayé ma propre classe d'application qui étend MultiDexApplication et super.attachBaseContext (base); MultiDex.install (this); aussi – TooLazy

+0

Et enregistré dans Manifest?

+0

ofc, j'ai un autre code là-bas. – TooLazy

0

Remarque: Si votre projet est configuré pour multidex avec minSdkVersion 20 ou moins, et vous déployer pour cibler les appareils fonctionnant sous Android 4.4 (niveau de l'API 20) ou inférieure, Android Studio désactive Instant Run.

pour plus d'infos read doc

check my ans it can help you

0

Avez-vous créer votre propre classe d'application, qui étend MultiDexApplication? Ils ont deux variantes pour ajouter un support multidex. Cette variante avec l'extension fonctionne bien, mais la variante, où vous devez appeler MultiDex.install(this); dans attachBaseContext ne fonctionne pas.

+0

ya, essayé les deux. – TooLazy

+0

Pouvez-vous partager le code du fichier Gradle, Manifest et Application? Si cela va nous aider à mieux comprendre ce qui se passe. –