2017-07-31 2 views
1

私のアプリでmiltidexを有効にしました。 Api 21+は正常に動作します。 AndroidのAPI 16の原因:Androidバターナイフマルチプレイヤー

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

私はBN結合、すべてが正常に動作している場合はコメント。 Multidexが有効:multiDexEnabled true, compile 'com.android.support:multidex:1.0.1'など。 それを動作させる方法はありますか?

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' 
    } 

マニフェストの一部:

<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"> 

Applicationクラス:

public class MyApplication extends MultiDexApplication {...} 

multiDexKeepProguardを追加しようとしましたが、gradleはそのメソッドを見ないか、メソッドの宣言が変更されました。 Bitterknife.bind(で返され

EDIT 2 Butterknife Unbinder)はトラブルになります。任意のアイデアを修正する方法?

答えて

0

以下は含まれていますか? あなたはアンドロイド設定するマニフェストファイルを編集し、Applicationクラスをオーバーライドしていない場合は、次のようにタグに名前を:

<?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>

をあなたが上書きを行う場合Applicationクラスが基本クラスを変更できない場合は、代わりにattachBaseContext()メソッドをオーバーライドし、MultiDex.install(this)を呼び出してmultidexを有効にすることができます。

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

Further read

+0

私はこれらの方法を試みました:MultiDexApplicationとsuper.attachBaseContext(base)を拡張する私自身のアプリケーションクラスを試しました。 MultiDex.install(this); – TooLazy

+0

マニフェストに登録しましたか?

+0

ofc、私はいくつかの他のコードがあります。 – TooLazy

0

は、あなたのプロジェクトがminSdkVersionが20以下でmultidex用に設定されている場合、あなたは、Android 4.4(APIレベルを実行しているデバイスをターゲットに展開します20)以下では、Android Studioはインスタント実行を無効にします。

詳細は

read doc

check my ans it can help you

0

あなたはMultiDexApplicationを拡張する独自のアプリケーションクラスを作成しましたか?彼らはmultidexサポートを追加する2つの変種があります。このバリアントの拡張はうまく機能しますが、MultiDex.install(this);attachBaseContextに呼び出す必要があるバリアントは機能しません。

+0

屋、両方を試してみました。 – TooLazy

+0

Gradleファイル、マニフェスト、アプリケーションのコードを共有できますか?もし起こっていることをより良く理解するのに役立つならば。 –