└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # React Native Google AdMob Setup 2 | 3 | [sbugert/react-native-admob](https://github.com/sbugert/react-native-admob) this plugin was used. 4 | 5 | In the React Native **0.57.X** versions, the unity was prepared through the project that was tested and worked. 6 | 7 | **WARNING: react-native link** Do not automatic do manual. 8 | 9 | # Setup 10 | 11 | We will update 6 files in total. 12 | 13 | ``` 14 | 1. android/settings.gradle 15 | 2. android/build.gradle 16 | 3. android/app/build.gradle 17 | 4. android/app/src/main/AndroidManifest.xml 18 | 5. android/app/src/main/java/com/PROJECT_NAME/MainApplication.java 19 | 6. android/app/src/main/java/com/PROJECT_NAME/MainActivity.java 20 | ``` 21 | 22 | ## 1. android/settings.gradle 23 | 24 | ```gradle 25 | include ':react-native-admob' 26 | project(':react-native-admob').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-admob/android') 27 | ``` 28 | 29 | ## 2. android/build.gradle 30 | 31 | ```gradle 32 | allprojects { 33 | repositories { 34 | mavenLocal() 35 | google() 36 | jcenter() 37 | maven { 38 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 39 | url "https://maven.google.com" // IMPORTANT!!! 40 | url "$rootDir/../node_modules/react-native/android" 41 | } 42 | } 43 | } 44 | ``` 45 | 46 | ## 3. android/app/build.gradle 47 | 48 | ```gradle 49 | android { 50 | defaultConfig { 51 | multiDexEnabled true 52 | } 53 | } 54 | 55 | dependencies { 56 | implementation( project(':react-native-admob') ){ 57 | exclude group: "com.google.android.gms" 58 | } 59 | implementation "com.google.android.gms:play-services-ads:17.2.1" 60 | implementation 'com.android.support:multidex:1.0.3' 61 | } 62 | ``` 63 | 64 | ## 4. android/app/src/main/AndroidManifest.xml 65 | 66 | ```xml 67 | 68 | 69 | 72 | 73 | 74 | 75 | APPLICATION_ID - don't change 76 | GOOGLE_ADMOB_APP_ID - ca-app-pub-******~****** 77 | ``` 78 | 79 | ## 5. android/app/src/main/java/com/PROJECT_NAME/MainApplication.java 80 | 81 | ```java 82 | import com.sbugert.rnadmob.RNAdMobPackage; 83 | ``` 84 | 85 | ## 5. android/app/src/main/java/com/PROJECT_NAME/MainActivity.java 86 | 87 | ```java 88 | import android.os.Bundle; 89 | import com.google.android.gms.ads.MobileAds; 90 | 91 | @Override 92 | protected void onCreate(Bundle savedInstanceState) { 93 | super.onCreate(savedInstanceState); 94 | MobileAds.initialize(this, "GOOGLE_ADMOB_APP_ID"); 95 | } 96 | ``` 97 | 98 | The end. :) 99 | --------------------------------------------------------------------------------