I am using lottie
library for react native. I just installed it using npm
and linked it using react native link but when I try to build it I get an error in lottie's class error:package android.support.v4.view does not exist
These are my dependencies in app 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"
}
Try doing this
npm i jetifier
npx jetify
For newer versions of react-native support v4 is replaced with androidx ,Add this at end of your app level build.gradle If you had similar problem with other libraries you have to replace them like this
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'
)
}
Note that this happens if you enable androidX , If you do not want it disable it in .properties file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With