【问题标题】:Multidex on Asus 5.1华硕 5.1 上的 Multidex
【发布时间】:2017-05-17 14:23:20
【问题描述】:

我在使用 multidex 时遇到问题。它工作正常,但是,仅在ASUS Zenphone MAX with 5.1 Android 上,当应用程序启动时出现错误:

05-17 16:37:11.624 11229-11229/ru.techmas.neeosocial E/AndroidRuntime: 致命例外:主要 进程:ru.techmas.neeosocial,PID:11229 java.lang.NoClassDefFoundError:解析失败: Lrx/主题/发布主题; 在 ru.techmas.neeosocial.utils.RxPush.(RxPush.java:18) 在 ru.techmas.neeosocial.dagger.modules.AppModule.(AppModule.java:46) 在 ru.techmas.neeosocial.App.setupDagger2(App.java:58) 在 ru.techmas.neeosocial.App.onCreate(App.java:34) 在 android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1011) 在 android.app.ActivityThread.handleBindApplication(ActivityThread.java:4559) 在 android.app.ActivityThread.access$1500(ActivityThread.java:151) 在 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1346) 在 android.os.Handler.dispatchMessage(Handler.java:102) 在 android.os.Looper.loop(Looper.java:135) 在 android.app.ActivityThread.main(ActivityThread.java:5289) 在 java.lang.reflect.Method.invoke(本机方法) 在 java.lang.reflect.Method.invoke(Method.java:372) 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 引起:java.lang.ClassNotFoundException:找不到类 路径上的“rx.subjects.PublishSubject”:DexPathList[[zip 文件 “/data/app/ru.techmas.neeosocial-1/base.apk”,压缩文件 "/data/app/ru.techmas.neeosocial-1/split_lib_dependencies_apk.apk", 压缩文件 “/data/app/ru.techmas.neeosocial-1/split_lib_slice_0_apk.apk”,压缩包 文件“/data/app/ru.techmas.neeosocial-1/split_lib_slice_1_apk.apk”, 压缩文件 “/data/app/ru.techmas.neeosocial-1/split_lib_slice_2_apk.apk”,压缩包 文件“/data/app/ru.techmas.neeosocial-1/split_lib_slice_3_apk.apk”, 压缩文件 “/data/app/ru.techmas.neeosocial-1/split_lib_slice_4_apk.apk”,压缩包 文件“/data/app/ru.techmas.neeosocial-1/split_lib_slice_5_apk.apk”, 压缩文件 “/data/app/ru.techmas.neeosocial-1/split_lib_slice_6_apk.apk”,压缩包 文件“/data/app/ru.techmas.neeosocial-1/split_lib_slice_7_apk.apk”, 压缩文件 “/data/app/ru.techmas.neeosocial-1/split_lib_slice_8_apk.apk”,压缩包 文件 "/data/app/ru.techmas.neeosocial-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/ru.techmas.neeosocial-1/lib/arm64, /vendor/lib64, /system/lib64]] 在 dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:511) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:469) 在 ru.techmas.neeosocial.utils.RxPush.(RxPush.java:18) 在 ru.techmas.neeosocial.dagger.modules.AppModule.(AppModule.java:46) 在 ru.techmas.neeosocial.App.setupDagger2(App.java:58) 在 ru.techmas.neeosocial.App.onCreate(App.java:34) 在 android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1011) 在 android.app.ActivityThread.handleBindApplication(ActivityThread.java:4559) 在 android.app.ActivityThread.access$1500(ActivityThread.java:151) 在 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1346) 在 android.os.Handler.dispatchMessage(Handler.java:102) 在 android.os.Looper.loop(Looper.java:135) 在 android.app.ActivityThread.main(ActivityThread.java:5289) 在 java.lang.reflect.Method.invoke(本机方法) 在 java.lang.reflect.Method.invoke(Method.java:372) 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 抑制:java.lang.ClassNotFoundException: rx.subjects.PublishSubject 在 java.lang.Class.classForName(本机方法) 在 java.lang.BootClassLoader.findClass(ClassLoader.java:781) 在 java.lang.BootClassLoader.loadClass(ClassLoader.java:841) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:504) ... 16 更多 引起:java.lang.NoClassDefFoundError: Class not found using the 引导类加载器;没有可用的堆栈 05-17 16:42:11.945 11229-11229/ru.techmas.neeosocial I/Process:发送信号。 PID: 11229 信号:9 原因:java.lang.NoClassDefFoundError: Class not found using the boot class loader;没有可用的堆栈

在我创建AppModule (Dagger2 DI) 时发生, rxPush 行(如果与restApi 交换,则在restApi 创建时发生。

AppModule:

public AppModule(App app) {
    this.app = app;
    preferenceHelper = new PreferenceHelper(PreferenceManager.getDefaultSharedPreferences(app));
    dataChecker = new DataChecker();
    geoHelper = new GeoHelper();
    animationHelper = new AnimationHelper(app);
    user = new UserDTO();
    friendPerson = new PersonDTO();
    rxPush = new RxPush();
    restApi = new RestApi(preferenceHelper, app);
}

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

apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'realm-android'


def getStore = { ->
    def result = project.hasProperty('storeFile') ? storeFile : "null"
    return result
}

def getStorePassword = { ->
    def result = project.hasProperty('storePassword') ? storePassword : ""
    return result
}

def getKeyAlias = { ->
    def result = project.hasProperty('keyAlias') ? keyAlias : ""
    return result
}

def getKeyPassword = { ->
    def result = project.hasProperty('keyPassword') ? keyPassword : ""
    return result
}


android {

    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            output.outputFile = new File(
                    output.outputFile.parent,
                    output.outputFile.name.replace("app", "${variant.applicationId}-${variant.versionName}"))
        }
    }

    compileSdkVersion = 25
    buildToolsVersion = "25.0.2"
    defaultConfig {
        applicationId "ru.techmas.neeosocial"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 7
        versionName "0.5.3"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    signingConfigs {
        release {
            storeFile file(getStore())
            storePassword getStorePassword()
            keyAlias getKeyAlias()
            keyPassword getKeyPassword()
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
}

dependencies {
    compile 'com.android.support:multidex:1.0.0'
    compile project(':webrtc')
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
        transitive = true;
    }
    compile 'com.arello-mobile:moxy:1.4.5'
    compile 'com.arello-mobile:moxy-app-compat:1.4.5'
    compile 'com.arello-mobile:moxy-android:1.4.5'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.okhttp3:okhttp:3.5.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.5.0'
    compile 'io.reactivex:rxjava:1.1.5'
    compile 'io.reactivex:rxandroid:1.0.1'
    compile 'com.android.support:design:25.1.0'
    compile 'com.android.support:recyclerview-v7:25.1.0'
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.android.support:support-v4:25.1.0'
    compile 'com.android.support:cardview-v7:25.1.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.3.1'
    compile 'de.hdodenhof:circleimageview:1.3.0'
    compile 'com.google.dagger:dagger:2.5'
    compile 'org.greenrobot:eventbus:3.0.0'
    compile 'com.github.christophesmet:android_maskable_layout:d51245736a'
    compile 'jp.wasabeef:blurry:2.1.0'
    compile 'com.google.android.gms:play-services-maps:9.0.1'
    compile 'com.google.android.gms:play-services-location:9.0.1'
    compile 'ru.tinkoff.decoro:decoro:1.3.2'
    compile 'com.google.firebase:firebase-messaging:9.0.1'
    testCompile 'junit:junit:4.12'
    apt 'com.google.dagger:dagger-compiler:2.5'
    provided 'com.arello-mobile:moxy-compiler:1.4.5'
    provided 'javax.annotation:jsr250-api:1.0'
}

apply plugin: 'com.google.gms.google-services'

应用程序(扩展 WebRtcApp 扩展 MultiDexApplication):

public class App extends WebRtcApp {

    private static AppComponent appComponent;


    //@formatter:off
    @Inject DataChecker dataChecker;
    //@formatter:on

    @Override
    public void onCreate() {
        super.onCreate();
        setupDagger2();
        setupDataChecker();
        setupFabric();
        setupRealm();
    }

    private void setupRealm() {
        Realm.init(this);
        RealmConfiguration config = new RealmConfiguration.Builder()
                .schemaVersion(Const.RealmScheme.VERSION) // Must be bumped when the schema changes
                .deleteRealmIfMigrationNeeded()
                .build();
        Realm.setDefaultConfiguration(config);
    }

    private void setupDataChecker() {
        dataChecker.setContext(this);
    }

    private void setupFabric() {
        Fabric.with(this, new Crashlytics());
    }

    private void setupDagger2() {
        appComponent = DaggerAppComponent.builder()
                .appModule(new AppModule(this))
                .build();
        appComponent.inject(this);
    }

    public static AppComponent getAppComponent() {
        return appComponent;
    }

在其他型号(4、5、6 Android)上运行良好。 清理和重建,重启和无效缓存没有帮助

【问题讨论】:

    标签: android android-multidex


    【解决方案1】:

    问题在于即时运行。我禁用它并且一切正常。

    【讨论】:

      猜你喜欢
      • 2011-10-16
      • 1970-01-01
      • 2021-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-13
      • 1970-01-01
      相关资源
      最近更新 更多