Java 为什么Google示例BannerExample不适用于Eclipse?
我尝试运行名为BannerExample的Google示例,但该横幅未显示。 您可以在此处找到项目代码源:Java 为什么Google示例BannerExample不适用于Eclipse?,java,android,eclipse,ads,banner,Java,Android,Eclipse,Ads,Banner,我尝试运行名为BannerExample的Google示例,但该横幅未显示。 您可以在此处找到项目代码源: 我只是更改变量: 按Admob接口中给定的值在此处插入您的\u AD\u UNIT\u ID\u。 并根据SDK启动时给出的值在此处插入\u您的\u散列\u设备\u ID\u My BannerExample.java: package com.google.example.gms.ads.banner; import com.google.android.gms.ads.AdReque
我只是更改变量: 按Admob接口中给定的值在此处插入您的\u AD\u UNIT\u ID\u。 并根据SDK启动时给出的值在此处插入\u您的\u散列\u设备\u ID\u My BannerExample.java:
package com.google.example.gms.ads.banner;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
/**
* A simple {@link Activity} that embeds an AdView.
*/
public class BannerSample extends Activity {
/** The view to show the ad. */
private AdView adView;
/* Your ad unit id. Replace with your actual ad unit id. */
private static final String AD_UNIT_ID = "ca-app-pub-55043114705XXXXX/XXXXXXXXXX";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Create an ad.
adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(AD_UNIT_ID);
// Add the AdView to the view hierarchy. The view will have no size
// until the ad is loaded.
LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);
layout.addView(adView);
// Create an ad request. Check logcat output for the hashed device ID to
// get test ads on a physical device.
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("653B45F6B15FB941FED6F87440C626BE")
.build();
// Start loading the ad in the background.
adView.loadAd(adRequest);
}
@Override
public void onResume() {
super.onResume();
if (adView != null) {
adView.resume();
}
}
@Override
public void onPause() {
if (adView != null) {
adView.pause();
}
super.onPause();
}
/** Called before the activity is destroyed. */
@Override
public void onDestroy() {
// Destroy the AdView.
if (adView != null) {
adView.destroy();
}
super.onDestroy();
}
}
但当我启动应用程序时,我看到一个标题为“BannerAdsSample”的空活动,下面是“HelloWorlds!”,仅此而已
以及我的AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.example.gms.ads.banner"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="9"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:allowBackup="true">
<activity android:name=".BannerSample"
android:label="@string/app_name">
<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"/>
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
</manifest>
那么,如果googleplay服务库被引用为library,但在日志中没有找到,那又有什么错呢
我增加了两个新的广告网络账户:AdFalcon和MobFox。
我已经关联到谷歌的广告样本。
现在我有3个不同的广告提供商:AdMob网络(positionnement Dynamicque)、AdFalcon和MobFox,以便使用本文中建议的“中介”:
但这不会改变任何事情。。。我仍然有同样的问题。
因此,现在在我的日志中,我有:
09-01 19:25:15.501: E/GooglePlayServicesUtil(16134): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
09-01 19:25:16.052: I/Ads(16134): No fill from ad server.
09-01 19:25:16.052: W/Ads(16134): Failed to load ad: 3
多亏了这篇文章,我们可以看到:
错误E/GooglePlayServicesUtil(16134):Google Play。。。所以这不是一个“真正的问题”
但是其他两行是在logcat中写入的最后一行,在控制台日志中仍然没有任何内容
在我的Admod帐户中,我必须将我的应用程序名称与Google play商店中的应用程序相关联。但由于这只是一个戳,我没有发布“谷歌旗帜样本”在游戏商店没有?
因此,我的应用程序有3个广告提供商,我发现了一个名为“Banner Sample Test”的应用程序,我希望它和我一样
那么问题是什么呢
我可以等4天吗?!正如这里所建议的那样
那么问题在哪里呢
致以最诚挚的问候检查一下:我看到了,但我没有其他安卓设备。我在我的星系S4上运行它。除了这个缺失的广告,一切都很好。如果你有wifi,那么你也可以在模拟器上查看。或者只需在您的好友设备中安装apk。好的,但如果它在另一台设备上工作,如何使它在这台设备上运行?今晚我将在emulator上试用。您对设备上的选项有什么想法,可以通过更改来修复它吗?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/hello_world"/>
</LinearLayout>
TargetName : Android 4.4.2
Vendor : Android Open Source Project
Platform : 4.4.2
API Level : 19
09-01 19:25:15.501: E/GooglePlayServicesUtil(16134): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
09-01 19:25:16.052: I/Ads(16134): No fill from ad server.
09-01 19:25:16.052: W/Ads(16134): Failed to load ad: 3