我尝试运行名为BannerExample的Google示例,但不显示横幅。
您可以在此处找到项目代码来源:bannerexample
我只是改变变量:
INSERT_YOUR_AD_UNIT_ID_HERE按Admob界面中给出的值。
和INSERT_YOUR_HASHED_DEVICE_ID_HERE按SDK在启动时给出的值。
我的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>
所以在日志中我遇到了这个问题:
07-22 00:46:50.254: W/ApplicationPackageManager(2509): getCSCPackageItemText()
07-22 00:46:50.254: I/PersonaManager(2509): getPersonaService() name persona_policy
07-22 00:46:50.314: E/MoreInfoHPW_ViewGroup(2509): Parent view is not a TextView
07-22 00:46:50.384: D/dalvikvm(2509): DexOpt: --- BEGIN 'ads-579524131.jar' (bootstrap=0) ---
07-22 00:46:50.394: I/Ads(2509): Starting ad request.
07-22 00:46:50.404: I/Ads(2509): Please set theme of AdActivity to @android:style/Theme.Translucent to enable transparent background interstitial ad.
07-22 00:46:50.404: V/WebViewChromium(2509): Binding Chromium to the background looper Looper (main, tid 1) {42aad368}
07-22 00:46:50.404: I/chromium(2509): [INFO:library_loader_hooks.cc(112)] Chromium logging enabled: level = 0, default verbosity = 0
07-22 00:46:50.414: I/BrowserProcessMain(2509): Initializing chromium process, renderers=0
07-22 00:46:50.414: W/chromium(2509): [WARNING:proxy_service.cc(888)] PAC support disabled because there is no system implementation
07-22 00:46:50.424: W/ApplicationPackageManager(2509): getCSCPackageItemText()
07-22 00:46:50.424: I/Adreno-EGL(2509): <qeglDrvAPI_eglInitialize:381>: EGL 1.4 QUALCOMM build: (CL3869936)
07-22 00:46:50.424: I/Adreno-EGL(2509): OpenGL ES Shader Compiler Version: 17.01.11.SPL
07-22 00:46:50.424: I/Adreno-EGL(2509): Build Date: 01/17/14 Fri
07-22 00:46:50.424: I/Adreno-EGL(2509): Local Branch:
07-22 00:46:50.424: I/Adreno-EGL(2509): Remote Branch:
07-22 00:46:50.424: I/Adreno-EGL(2509): Local Patches:
07-22 00:46:50.424: I/Adreno-EGL(2509): Reconstruct Branch:
07-22 00:46:50.514: D/dalvikvm(2509): DexOpt: --- END 'ads-579524131.jar' (success) ---
07-22 00:46:50.514: D/dalvikvm(2509): DEX prep '/data/data/com.google.example.gms.ads.banner/cache/ads-579524131.jar': unzip in 0ms, rewrite 122ms
07-22 00:46:50.524: E/GooglePlayServicesUtil(2509): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
07-22 00:46:50.554: D/OpenGLRenderer(2509): Enabling debug mode 0
07-22 00:46:50.574: E/GooglePlayServicesUtil(2509): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
07-22 00:46:50.574: E/GooglePlayServicesUtil(2509): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
07-22 00:46:50.924: W/Ads(2509): There was a problem getting an ad response. ErrorCode: 1
07-22 00:46:50.934: W/Ads(2509): Failed to load ad: 1
和activity_main.xml:
<?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>
在我的eclipse设置中,我将Google Play服务lib设置为libray,如下所示: 属性 - &gt; Android-&gt;库
参考: ADT-束 - 窗口x86_64-20140321 \ SDK \额外\谷歌\ google_play_services \ libproject \谷歌播放-services_lib
项目: 谷歌播放-service_lib
带有绿色箭头。我暂时无法发布图片......我缺少10个批准
项目构建目标:
TargetName : Android 4.4.2
Vendor : Android Open Source Project
Platform : 4.4.2
API Level : 19
那么,如果谷歌播放服务库被引用为库,但在日志中它表示找不到,那有什么不对?
我添加了2个新的广告网络帐户:AdFalcon和MobFox。 我已关联Google的广告示例。 所以现在我有3个不同的广告提供商:AdMob Network(positionnement dynamique),AdFalcon和MobFox,以便使用“调解”,因为它在这篇文章中被消化了: AdMod mediation
但它没有改变任何东西......我仍然有同样的问题。 所以现在我的日志中有:
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
正如我们所看到的,感谢这篇文章: begin error 错误E / GooglePlayServicesUtil(16134):Google Play ...所以不是“真正的问题” 但另外两个是logcat中写的最后一行,而控制台日志中却没有。
在我的Admod帐户中,我必须将我的应用程序名称与Google Play商店中的应用程序相关联。但由于这只是一个戳戳,我没有必要在Play商店中发布“Google Banner Sample”吗? 所以我的应用程序有3个广告提供商,我发现了一个名为“横幅样本测试”的应用程序,我希望与我相同。
那么问题是什么?
我可以等4天吗?正如这里建议wait 4 days
问题出在哪里?
最好的问候