[英]Android Google Play Services Ads not showing
嗨,这是我第一次在这里发布信息,也是我第一次开发应用程序。
我无法让Google Play服务正常工作。 我终于让我所有的代码都不会出错,并且该应用程序可以在手机上加载。 但是,现在加载时,它会在应用顶部显示带有我的应用名称的横幅。
package com.TylerGibson.MopeyMacaw;
import com.google.android.gms.ads.*;
import android.os.Bundle;
//import com.kilobolt.MopeyMacaw.R;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.kilobolt.ZombieBird.ZBGame;
public class MainActivity extends AndroidApplication {
@Override
public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.main);
// Look up the AdView as a resource and load a request.
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
cfg.useGL20 = false;
initialize(new ZBGame(), cfg);
}
}
下面是我的主要
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-4445204025228818/4791459284" >
</com.google.android.gms.ads.AdView>
</LinearLayout>
Android清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.TylerGibson.MopeyMacaw"
android:versionCode="4"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="19" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<activity android:name="com.TylerGibson.MopeyMacaw.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>
自从我输入ads / google-services代码以来,您一直在顶部看到的图标和“莫佩金刚鹦鹉”一直在显示。 如何解决此问题并使广告正常运行? 先感谢您!
AdView区分大小写。 检查您的R.id.adView与以XML分配的ID(即AdView)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.