我创建了一个应用,添加了react-native-admob并将其链接 我更改了/node_modules/react-native-admob/android/build.gradle文件:
编译'com.google.android.gms:play-services-ads:+'
到
编译'com.google.android.gms:play-services-ads:15.0.0'
,然后使用“ ./gradlew clean && ./gradlew assembleRelease”构建apk,但是当我在手机中安装该应用程序时,它不会显示广告。 这是我的代码
import {
AdMobBanner,
AdMobInterstitial,
PublisherBanner,
AdMobRewarded,
} from 'react-native-admob';
....
<View>
<AdMobBanner
adSize="fullBanner"
adUnitID="ca-app-pub-2174326550695558/6129769558"
onAdFailedToLoad={error => console.error(error)}
/>
</View>
这是我的AndroidManifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.brawlcalculator">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
答案 0 :(得分:0)
在您的AndroidManifest.xml文件中:
将admob应用程序ID添加到应用程序标记内的元标记中
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme"
> // Look at this ... after the closing tag
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-2174326550695558~2753605675"
/>
</application>