После перехода на androidx NoClassDefFoundError Landroidx / жизненный цикл / LifecycleRegistry

#android #noclassdeffounderror #androidx

#Android #ошибка noclassdeffounderror #androidx

Вопрос:

это logcat, который мне нужен, чтобы преодолеть этот кошмар, случившийся после перехода на androidx

 java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/lifecycle/LifecycleRegistry;
            at androidx.lifecycle.ProcessLifecycleOwner.<init>(ProcessLifecycleOwner.java:62)
            at androidx.lifecycle.ProcessLifecycleOwner.<clinit>(ProcessLifecycleOwner.java:89)
            at androidx.lifecycle.ProcessLifecycleOwner.init(ProcessLifecycleOwner.java:102)
            at androidx.lifecycle.ProcessLifecycleOwnerInitializer.onCreate(ProcessLifecycleOwnerInitializer.java:37)
            at android.content.ContentProvider.attachInfo(ContentProvider.java:1920)
            at android.content.ContentProvider.attachInfo(ContentProvider.java:1894)
            at android.app.ActivityThread.installProvider(ActivityThread.java:7234)
            at android.app.ActivityThread.installContentProviders(ActivityThread.java:6721)
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6618)
            at android.app.ActivityThread.-wrap2(Unknown Source:0)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2084)
            at android.os.Handler.dispatchMessage(Handler.java:109)
            at android.os.Looper.loop(Looper.java:166)
            at android.app.ActivityThread.main(ActivityThread.java:7555)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963)
         Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.lifecycle.LifecycleRegistry" on path: DexPathList[[zip file "/data/app/com.rowaad.cvaley-LXmiQJz1ijVJLVajJprVXA==/base.apk"],nativeLibraryDirectories=[/data/app/com.rowaad.cvaley-LXmiQJz1ijVJLVajJprVXA==/lib/arm64, /data/app/com.rowaad.cvaley-LXmiQJz1ijVJLVajJprVXA==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64, /product/lib64]]
  

Комментарии:

1. Опубликуйте более подробную информацию в файле build.gradle.

Ответ №1:

Добавить в build.gradle:

 dependencies {
    ...
   
   implementation "androidx.lifecycle:lifecycle-runtime:2.0.0"
   implementation "androidx.lifecycle:lifecycle-extensions:2.0.0"
   annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.0.0"
}
  

Ответ №2:

Я изменил build.gradle ; это решило эту проблему

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    useLibrary 'org.apache.http.legacy'
    defaultConfig {
        applicationId "com.ouccvlab.pathplan"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions{
        doNotStrip "*/*/libdjivideo.so"
        doNotStrip "*/*/libSDKRelativeJNI.so"
        doNotStrip "*/*/libFlyForbid.so"
        doNotStrip "*/*/libduml_vision_bokeh.so"
        doNotStrip "*/*/libyuv2.so"
        doNotStrip "*/*/libGroudStation.so"
        doNotStrip "*/*/libFRCorkscrew.so"
        doNotStrip "*/*/libUpgradeVerify.so"
        doNotStrip "*/*/libFR.so"
        doNotStrip "*/*/libDJIFlySafeCore.so"
        doNotStrip "*/*/libdjifs_jni.so"
        doNotStrip "*/*/libsfjni.so"
        doNotStrip "*/*/libDJICommonJNI.so"
        doNotStrip "*/*/libDJICSDKCommon.so"
        doNotStrip "*/*/libDJIUpgradeCore.so"
        doNotStrip "*/*/libDJIUpgradeJNI.so"
        exclude 'META-INF/rxjava.properties'
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

dependencies {

//    compile  ('com.dji:dji-sdk:4.12')
//    provided  ('com.dji:dji-sdk-provided:4.12')
    implementation 'androidx.multidex:multidex:2.0.0'
    implementation 'com.squareup:otto:1.3.8'
    implementation('com.dji:dji-sdk:4.11.1', {
        /**
         * Uncomment the "library-anti-distortion" if your app does not need Anti Distortion for Mavic 2 Pro and Mavic 2 Zoom.
         * Uncomment the "fly-safe-database" if you need database for release, or we will download it when DJISDKManager.getInstance().registerApp
         * is called.
         * Both will greatly reducing the size of the APK.
         */
        exclude module: 'library-anti-distortion'
        exclude module: 'fly-safe-database'
    })
    compileOnly 'com.dji:dji-sdk-provided:4.11.1'

    implementation 'androidx.core:core:1.0.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-rc01'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'androidx.annotation:annotation:1.0.0'
}
  

Комментарии:

1. Пожалуйста, добавьте комментарий о том, что вы изменили