sbugert / react-native-admob

A react-native component for Google AdMob banners
BSD 2-Clause "Simplified" License
1.13k stars 530 forks source link

error: package android.support.annotation does not exist #519

Open lydongray opened 4 years ago

lydongray commented 4 years ago

Hi, I've seen this or similar errors in previous reported issues however they are all closed as the problem was resolved. I've tried all the solutions in the previous issues with no success.

This issue appears as soon as I add the react-native-admob package and run my app. I am using Android Studio 3.6.3, react-native 0.62.2 and react-native-admob 2.0.0-beta.6 (I get the same issue with react-native-admob 1.3.2 as well).

To replicate, I do the following:

> npx react-native init testrnadmob
> cd testrnadmob
> npm install --save react-native-admob@2.0.0-beta.6
open the project in Android Studio
> npm start
run the project in Android Studio on emulator

errors in the Build Output

D:\Projects\testrnadmob\node_modules\react-native-admob\android\src\main\java\com\sbugert\rnadmob\RNAdMobBannerViewManager.java:4: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;
                                 ^
D:\Projects\testrnadmob\node_modules\react-native-admob\android\src\main\java\com\sbugert\rnadmob\RNAdMobInterstitialAdModule.java:5: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;
                                 ^
D:\Projects\testrnadmob\node_modules\react-native-admob\android\src\main\java\com\sbugert\rnadmob\RNAdMobRewardedVideoAdModule.java:5: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;
                                 ^
D:\Projects\testrnadmob\node_modules\react-native-admob\android\src\main\java\com\sbugert\rnadmob\RNPublisherBannerViewManager.java:4: error: package android.support.annotation does not exist
import android.support.annotation.Nullable;
                                 ^

Has anybody else had this issue and found a solution?

efstathiosntonas commented 4 years ago

Having this issue too, can't fix, same stack

edit: possible fix https://github.com/sbugert/react-native-admob/issues/448#issuecomment-537659889

tlgync commented 4 years ago

npm install --save-dev jetifier npx jetify npx react-native run-android

HerbertLim commented 4 years ago

npm install --save-dev jetifier npx jetify npx react-native run-android

Thank you. This solved my issue.

Mussabaheen commented 4 years ago

@tlgync Good solution

ravi0the0sun commented 3 years ago

npm install --save-dev jetifier npx jetify npx react-native run-android

had the same issue after upgrading to 0.64 with react-native-tcp and react-native-udp did they removed jetifier from react native cli?

piyushrajput45 commented 1 month ago

react native build error:- [package android.support.annotation does not exist]

go to the terminal and open the project

Step 1- npm install jetifier

Or you can use yarn, but install it locally in your project, not globally

Step 2- npx jetify

Step 3- npx react-native run-android

You have two options to resolve the error. Check out this blog for detailed steps