【问题标题】:Could not find classes of androidx from method of createBestAvailableBackgroundScheduler - Android无法从 createBestAvailableBackgroundScheduler 的方法中找到 androidx 类 - Android
【发布时间】:2020-01-07 12:09:10
【问题描述】:

我在我的项目中使用 androidx,但是当我在 android 4.3 上运行它时,出现以下错误:

Could not find class 'androidx.work.impl.background.systemjob.SystemJobService', referenced from method androidx.work.impl.Schedulers.createBestAvailableBackgroundScheduler
Could not find class 'androidx.work.impl.constraints.trackers.NetworkStateTracker$NetworkStateCallback', referenced from method androidx.work.impl.constraints.trackers.NetworkStateTracker.<init>
Could not find class 'java.lang.invoke.MethodHandles$Lookup', referenced from method retrofit2.Platform.invokeDefaultMethod

这是我的gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "kotlin-kapt"
android {
    compileSdkVersion 29
    buildToolsVersion '29.0.2'
    defaultConfig {
        applicationId "xxx.xxx"
        minSdkVersion 17
        targetSdkVersion 29
        renderscriptTargetApi 17
        renderscriptSupportModeEnabled true
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.squareup.retrofit2:retrofit:2.7.1'
    implementation 'com.squareup.retrofit2:converter-gson:2.7.1'
    implementation 'com.jakewharton:butterknife:10.2.1'
    implementation 'com.squareup.okhttp3:okhttp:4.3.0'
    kapt 'com.jakewharton:butterknife-compiler:10.2.1'
    implementation 'com.google.dagger:dagger:2.25.4'
    implementation 'com.google.dagger:dagger-android-support:2.25.4'
    implementation 'com.google.dagger:dagger-android:2.25.4'
    kapt 'com.google.dagger:dagger-compiler:2.25.4'
    kapt 'com.google.dagger:dagger-android-processor:2.25.4'
    implementation 'androidx.room:room-runtime:2.2.3'
    kapt 'androidx.room:room-compiler:2.2.3'
    kapt "android.arch.persistence.room:compiler:2.2.2"
    implementation 'androidx.room:room-ktx:2.2.3'
    implementation 'androidx.room:room-rxjava2:2.2.3'
    implementation 'androidx.room:room-guava:2.2.3'
    implementation 'com.squareup.retrofit2:converter-scalars:2.7.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.2.10'
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
    implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
    implementation 'com.netflix.rxjava:rxjava-android:0.20.7'
    def lifecycle_version = "2.1.0"
    implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0-rc03"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0-rc03"
    implementation "androidx.work:work-runtime-ktx:2.2.0"
    implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycle_version"
}

这是我的activity

class CoursesActivity : DaggerAppCompatActivity()...{
    override fun onCreate(savedInstanceState: Bundle?) {
        super<DaggerAppCompatActivity>.onCreate(savedInstanceState)
        lifecycle.addObserver(this)
        setContentView(R.layout.activity_courses)
     }
}

【问题讨论】:

    标签: android retrofit okhttp androidx dagger


    【解决方案1】:

    解决了我的问题,我将以下库编辑为:

    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.squareup.retrofit2:converter-scalars:2.3.0'
    implementation 'com.squareup.okhttp3:okhttp:3.12.3'
    

    【讨论】:

      猜你喜欢
      • 2015-06-27
      • 2019-11-29
      • 1970-01-01
      • 1970-01-01
      • 2020-03-24
      • 2012-01-04
      • 2019-02-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多