前提・実現したいこと
AndroidStudioでアプリ開発を行っています。
自作のアプリに広告をつけようとAdMobに登録し、広告配信可能のメールも受け取ったのですが、Playストアで配信されている自分のアプリをインストールしてみても広告が表示されません。
広告タイプはバナーで広告ユニットIDもアプリIDもちゃんと所定の箇所に入力しています。
デバッグ段階で署名付きのビルドを行うと実機で本番の広告(マクドナルドやGooglePlayなど)が表示されるのですが、いざリリースしてみると何も表示されません。
Androidでアプリをリリースするのは初めてで、デバッグとリリースで違うところなどをまだ把握しきれていません。Proguardの記述やFirebaseの証明書など何か気を付けるべきことがあれば教えてください。
該当のソースコード
main_activity.xml
xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="vertical"> <!--ボタンなどいろいろ--> </LinearLayout> <com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto" android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal|bottom" ads:adSize="BANNER" ads:adUnitId="@string/banner_ad_unit_id"> </com.google.android.gms.ads.AdView> </LinearLayout>
MainActivity.java
java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); MobileAds.initialize(this, "<<自分のアプリID>>"); mAdView = (AdView) findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().build(); mAdView.loadAd(adRequest);
build.gradle(app)
apply plugin: 'com.android.application' android { compileSdkVersion 27 defaultConfig { applicationId "com.hatenablog.tetsudo_ide.trainjourny" minSdkVersion 24 targetSdkVersion 27 versionCode 9 versionName "1.05" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.google.android.gms:play-services-maps:16.0.0' implementation 'com.google.firebase:firebase-core:16.0.5' implementation 'com.google.android.gms:play-services-ads:17.1.1' implementation 'com.google.firebase:firebase-ads:17.1.1' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' } apply plugin: 'com.google.gms.google-services'
試したこと
・network_security_config.xmlの削除
広告の通信がこれで妨害されると思ったが、署名付きデバッグタイプビルドで実機で問題なく本番広告が表示されたので問題の要因ではないと判断したため元に戻した。
・Google公式のバナー広告サンプルのproguard-rules.proのコピペ
GithHubで公開されているバナー広告サンプルのproguard-rules.proをコピペしてみたが、本番の広告は表示されなかった。クラス名などについて知識不足なのでオリジナルから変更すべき点があるかもしれない。
補足情報
テスト広告は実機もエミュレータも問題なく表示されます。
AdMob側でPlayストアに登録されているアプリとリンク済みです。
FirebaseのプロジェクトもAdMobとリンク済みです。
AdMobとFirebaseはアプリのリリース前に導入しました。
FirebaseでもAdMobでもアプリの解析(アクティブユーザー数や広告のリクエスト回数の調査)ができています。
該当のアプリ:
https://play.google.com/store/apps/details?id=com.hatenablog.tetsudo_ide.trainjourny
まだ回答がついていません
会員登録して回答してみよう