简体   繁体   中英

Jetifier does not convert support dependencies

I cloned ExoPlayer locally and added the modules to my existing project using my settings.gradle as described in the documentation:

gradle.ext.exoplayerRoot = 'path/to/exoplayer'
gradle.ext.exoplayerModulePrefix = 'exoplayer-'
apply from: new File(gradle.ext.exoplayerRoot, 'core_settings.gradle')

Whenever I try to build the project, I receive the following build error:

error: package android.support.annotation does not exist

These happen for all @NonNull and @Nullable annotations in the ExoPlayer modules .

I created a new project in Android Studio 3.2.1, added AndroidX support in my gradle.properties file and updated my build.gradle file accordingly.

build.gradle

android {
    compileSdkVersion 28
    defaultConfig {
        minSdkVersion 26
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }

    dataBinding {
        enabled = true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    //ExoPlayer
    implementation project(':exoplayer-library-core')
}

gradle.properties

org.gradle.jvmargs=-Xmx1536m
android.databinding.enableV2=true
android.useAndroidX=true
android.enableJetifier=true

If I understand correctly, Jetifier should be able to resolve and convert the support dependencies to AndroidX dependencies, but this does not seem to be the case for these local modules.

I managed to solve the issue by specifying a gradle.properties file for every local exoplayer module in my project that is used in the application. I still don't know what causes the issue, but preventing Jetifier from migrating to AndroidX for the local modules seems to solve this issue.

# Local module Gradle settings.
android.useAndroidX=false
# Jetifier will convert support libraries of all your dependencies to AndroidX automatically,
# if you don't set it true then your project will have both support
android.enableJetifier=false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM