I've developed an app using React Native and Expo and wanted to add a banner ad to the end of it. When I run the app on a development build on an Android emulator the rest of the app runs without the app although there is space open where it should be and eventually I get this error [Error: [googleMobileAds/error-code-network-error] The ad request was unsuccessful due to network connectivity.]
我已经开发了一款使用Reaction Native和世博会的应用程序,并想在它的末尾添加一个横幅广告。当我在Android模拟器上的开发版本上运行应用程序时,应用程序的其余部分在没有应用程序的情况下运行,尽管应该有空间打开,但最终我收到了这个错误[Error:[googleMobileAds/Error-Code-Network-Error]广告请求因网络连接而失败。]
app.json:
{
"expo": {
...
}
"react-native-google-mobile-ads": {
"android_app_id": "ca-app-pub-xxx,
"ios_app_id": "ca-app-pub-xxx"
}
}
App.js:
import {
BannerAd,
BannerAdSize,
TestIds,
} from "react-native-google-mobile-ads";
const adUnitId = __DEV__
? TestIds.BANNER
: "ca-app-pub-adunitid";
return(
<View>
...
<BannerAd
unitId={TestIds.BANNER}
size={BannerAdSize.BANNER}
requestOptions={{
requestNonPersonalizedAdsOnly: true,
}}
onAdFailedToLoad={(errorCode) => console.log(errorCode)}
/>
</View>
)
These are the commands I ran to get the app up and running:
以下是我为启动和运行该应用程序而运行的命令:
eas build --profile development --platform android
EAS构建--配置文件开发--平台Android
npx expo start --dev-client
NPX EXPO启动--开发-客户端
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!