Home Blog React Native Annotation Not Null Error
React Native Annotation Not Null Error

React Native Annotation Not Null Error


Hello devs, If you are a React-Native developer, you must be familiar with the React-Native framework. And in your life you have encountered this error once.


Let’s discuss this error further and I assure you, you’re heading in the right direction.


In this blog we are going to discuss the error and the 2 different ways to solve "React Native Annotation Not Null error".


ERROR:- Build with **** failed on Android : package android.support.annotation does not exist



Reason of this error:-  This error happens `android.support.annotation.NotNull` comes from the older Android Support Libraries, Which replaced by AndroidX in newer versions of React Native and Android.


From React Native version 0.60 onwards, React Native switched to using AndroidX, so in the older `android.support` libraries are no longer supported.



Solution 1:-


You can enable AndroidX migration by adding the following flags to your android/gradle.properties file:


Step 1:-


android.useAndroidX = true
android.enableJetifier = true


. android.useAndroidX = true:- Ensures that your project uses AndroidX


. android.enableJetifiertrue :- Automatically migrates old android.support libraries in your dependencies to AndroidX using jetifier.


Step 2:-


Go the terminal, open your project and run these command:-


cd android​

./gradlew clean

cd ..

npx react-native run-andorid



Solution 2:-


Go the terminal, open your project and run these command:-


npm install jetifier

npx jetify

cd android

./gradlew clean

cd ..

npx react-native run-andorid



Conclusion:-

. Run npm install jetifier

. Run npx jetify

. Clean and rebuild your project.

. Ensure that third-party libraries are using AndroidX


Get in touch wit​h us!

Protected by reCAPTCHA, Privacy Policy & Terms of Service apply.
Leave a Comment

Your email address will not be published.

Submit
Your comment is under review by our moderation team.