错误:程序包android.support.v4.view不存在

Div*_*hah 4 android android-appcompat android-support-library react-native lottie

我正在使用lottie本机反应本机。我刚安装了它,npm并使用react native链接将其链接起来,但是当我尝试构建它时,我在lottie的类错误中得到了一个错误:
package android.support.v4.view does not exist

这些是我对应用程序gradle的依赖

dependencies {
compile project(':lottie-react-native')
compile project(':react-native-vector-icons')
compile project(':react-native-view-overflow')
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.facebook.react:react-native:+'
// From node_modules
implementation "android.arch.work:work-runtime:$versions.work"
implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'io.reactivex:rxandroid:1.2.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.6@aar') {
    transitive = true;
}
implementation 'com.android.support:support-v4:28.0.3'
implementation 'com.android.support:appcompat-v7:28.0.3'

}

 compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
    applicationId "com.pois"
    minSdkVersion 19
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Run Code Online (Sandbox Code Playgroud)

Vir*_*t18 8

试试这个

npm i jetifier
npx jetify
Run Code Online (Sandbox Code Playgroud)


Moh*_*d f 4

对于较新版本的react-native支持 v4 已替换为 androidx ,将其添加到应用程序级别 build.gradle 的末尾如果您对其他库有类似的问题,则必须像这样替换它们

preBuild.doFirst { 
ant.replaceregexp(
    match:'import android.support.v4.view.', 
    replace:'import androidx.core.view.', 
    flags:'g', 
    byline:true
) { 
    fileset(
        dir: '../../node_modules/lottie-react-native/src/android/src/main/java/com/airbnb/android/react/lottie/', 
        includes: '*.java'
    ) 
} 
Run Code Online (Sandbox Code Playgroud)

请注意,如果您启用 androidX ,就会发生这种情况,如果您不希望它在 .properties 文件中禁用它