最初の投稿です。このトピックに関する多数の投稿があり、回答を探していることに感謝します。
JQM (1.2)、Cordova (2.2)、Admob (6.2.1) を使用して Android アプリを開発していますが、広告が表示されません。
public class cordovaExample extends DroidGap
{
private Handler mHandler = new Handler();
private AdView adView;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
mHandler.postDelayed(new Runnable()
{
public void run()
{ //
doAdMob();
}
}, 5000);
}
private void doAdMob()
{
// Create the adView
adView = new AdView(this, AdSize.SMART_BANNER, "MYCODE");
LinearLayout layout = super.root;
layout.addView(adView);
layout.setHorizontalGravity(android.view.Gravity.CENTER_HORIZONTAL);
AdRequest request = new AdRequest();
adView.loadAd(request);
}
}
これが私のlogcatからの抜粋です:
12-17 14:07:06.424: I/Ads(24745): Refreshing ad.
12-17 14:07:06.454: I/Ads(24745): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_buildAdURL({"preqs":2,"session_id":"11970596199473559413","seq_num":"3","slotname":"a150bd20d174dce","u_w":360,"msid":"org.apache.cordova.example","js":"afma-sdk-a-v6.2.1","bas_off":0,"net":"ed","app_name":"1.android.org.apache.cordova.example","hl":"en","smart_w":"full","gnt":15,"carrier":"23430","u_audio":1,"u_sd":1.5,"mv":"8016010.com.android.vending","isu":"82D3E2C68BC8ABDE44C1EA123E7289AA","cipa":1,"format":"360x50_mb","oar":2,"smart_h":"auto","ad_pos":{"height":0,"visible":1,"y":888,"x":0,"width":540},"u_h":592,"bas_on":0,"ptime":120733});</script></head><body></body></html>
12-17 14:07:06.484: I/Ads(24745): Received ad url: <url: "http://googleads.g.doubleclick.net:80/mads/gma?preqs=2&session_id=11970596199473559413&seq_num=3&u_w=360&msid=org.apache.cordova.example&js=afma-sdk-a-v6.2.1&bas_off=0&net=ed&app_name=1.android.org.apache.cordova.example&hl=en&smart_w=full&gnt=15&carrier=23430&u_audio=1&u_sd=1.5&mv=8016010.com.android.vending&isu=82D3E2C68BC8ABDE44C1EA123E7289AA&cipa=1&format=360x50_mb&oar=2&smart_h=auto&u_h=592&bas_on=0&ptime=120733&u_so=p&output=html®ion=mobile_app&u_tz=0&client_sdk=1&ex=1&slotname=a150bd20d174dce&askip=2&gsb=4g&caps=inlineVideo_interactiveVideo_mraid1_th_autoplay_mediation_sdkAdmobApiForAds_di&jsv=41" type: "admob" afmaNotifyDt: "null" useWebViewLoadUrl: "false">
12-17 14:07:06.484: I/Ads(24745): Request scenario: Offline with no buffered ads.
12-17 14:07:06.484: I/Ads(24745): Network is unavailable. Aborting ad request.
12-17 14:07:06.484: I/Ads(24745): onFailedToReceiveAd(A network error occurred.)
12-17 14:08:56.894: I/Ads(25453): To get test ads on this device, call adRequest.addTestDevice("82D3E2C68BC8ABDE44C1EA123E7289AA");
12-17 14:08:56.954: I/Ads(25453): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"preqs":0,"session_id":"8715359451090924487","seq_num":"1","slotname":"a150bd20d174dce","u_w":360,"msid":"org.apache.cordova.example","js":"afma-sdk-a-v6.2.1","bas_off":0,"net":"ed","app_name":"1.android.org.apache.cordova.example","hl":"en","smart_w":"full","gnt":15,"carrier":"23430","u_audio":1,"u_sd":1.5,"mv":"8016010.com.android.vending","isu":"82D3E2C68BC8ABDE44C1EA123E7289AA","cipa":1,"format":"360x50_mb","oar":0,"smart_h":"auto","ad_pos":{"height":0,"visible":1,"y":888,"x":0,"width":540},"u_h":592,"bas_on":0,"ptime":0});</script></head><body></body></html>
12-17 14:08:57.184: I/Ads(25453): Received ad url: <url: "http://googleads.g.doubleclick.net:80/mads/gma?preqs=0&session_id=8715359451090924487&seq_num=1&u_w=360&msid=org.apache.cordova.example&js=afma-sdk-a-v6.2.1&bas_off=0&net=ed&app_name=1.android.org.apache.cordova.example&hl=en&smart_w=full&gnt=15&carrier=23430&u_audio=1&u_sd=1.5&mv=8016010.com.android.vending&isu=82D3E2C68BC8ABDE44C1EA123E7289AA&cipa=1&format=360x50_mb&oar=0&smart_h=auto&u_h=592&bas_on=0&ptime=0&u_so=p&output=html®ion=mobile_app&u_tz=0&client_sdk=1&ex=1&slotname=a150bd20d174dce&gsb=4g&caps=inlineVideo_interactiveVideo_mraid1_th_autoplay_mediation_sdkAdmobApiForAds_di&jsv=41" type: "admob" afmaNotifyDt: "null" useWebViewLoadUrl: "false">
12-17 14:08:57.184: I/Ads(25453): Request scenario: Offline with no buffered ads.
12-17 14:08:57.184: I/Ads(25453): Network is unavailable. Aborting ad request.
12-17 14:08:57.194: I/Ads(25453): onFailedToReceiveAd(A network error occurred.)
adview の高さが常に 0 であるため、レイアウトに問題があると思いますが、よくわかりません。CordovaWebView を使用すると広告を表示できるため、Phonegap と Admob が正しく設定されていると確信しています。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/rootLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<org.apache.cordova.CordovaWebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/adView"
android:id = "@+id/mainView"/>
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adUnitId="MYCODE"
ads:adSize="SMART_BANNER"
ads:loadAdOnCreate="true"/>
</RelativeLayout >
残念ながら、このバグにより、ここで詳しく説明されているように、広告ビューの追加を遅らせないと、ローカルストレージが消去されますhttps://github.com/phonegap/phonegap/wiki/In-App-Advertisements
要するに、Phonegap、admob、およびローカルストレージを操作するために、誰でも動作する.java、main.xmlを提供できます。