gpt4 book ai didi

android - Admob 横幅未显示

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:44:56 24 4
gpt4 key购买 nike

我的 admob 横幅没有显示,我已经阅读了此处的指南 https://firebase.google.com/docs/admob/android/quick-start

主要 Activity

private AdView mAdView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MobileAds.initialize(getApplicationContext(), "ca-app-pub-3940256099942544/6300978111");
mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
}

布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.myapplication.MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />

<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
</com.google.android.gms.ads.AdView>
</RelativeLayout>

在我的 list 中,我有这个权限

<uses-permission android:name="android.permission.INTERNET" />

项目 Gradle

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.0.0'
}
}

allprojects {
repositories {
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

应用程序等级

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.google.firebase:firebase-ads:10.0.1'
compile 'com.google.firebase:firebase-core:10.0.1'
testCompile 'junit:junit:4.12'
}



apply plugin: 'com.google.gms.google-services'

日志

01-31 20:44:49.586 3556-3556/? D/ucsBai_ConnectionManager: mPackageReceiver Action android.intent.action.PACKAGE_ADDED
01-31 20:44:58.836 19607-19607/com.example.myapplication I/FA: App measurement is starting up, version: 10084
01-31 20:44:58.836 19607-19607/com.example.myapplication I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
01-31 20:44:58.836 19607-19607/com.example.myapplication D/FA: Debug-level message logging enabled
01-31 20:44:58.836 19607-19607/com.example.myapplication D/FA: AppMeasurement singleton hash: 23949389
01-31 20:44:58.846 19607-19607/com.example.myapplication V/FA: Collection enabled
01-31 20:44:58.846 19607-19607/com.example.myapplication V/FA: App package, google app id: com.example.myapplication, 1:665936977222:android:13c3c6a65bcbec53
01-31 20:44:58.846 19607-19607/com.example.myapplication I/FA: To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.example.myapplication
01-31 20:44:58.906 19607-19607/com.example.myapplication V/FA: Registered activity lifecycle callback
01-31 20:44:58.916 19607-20434/com.example.myapplication V/FA: Using measurement service
01-31 20:44:58.916 19607-20434/com.example.myapplication V/FA: Connecting to remote service
01-31 20:44:59.816 19607-20434/com.example.myapplication V/FA: Connection attempt already in progress
01-31 20:45:00.116 19607-20434/com.example.myapplication D/FA: Connected to remote service
01-31 20:45:00.116 19607-20434/com.example.myapplication V/FA: Processing queued up service tasks: 2
01-31 20:45:05.156 19607-20434/com.example.myapplication V/FA: Inactivity, disconnecting from the service

最佳答案

首先打开https://apps.admob.com/然后从那里选择您的应用程序现在从那里选择货币化选项卡现在展开 View 设置说明

enter image description here

这里你必须输入你的App ID

MobileAds.initialize(getApplicationContext(), "ca-app-pub-1440645979698474~6985293144"); // replace with yours

对于 xml enter image description here

从广告单元中选择

<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-1440645979698474/3892225947">

替换为您的 adUnitId,您就完成了。

关于android - Admob 横幅未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41972216/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com