【发布时间】:2014-06-19 03:16:51
【问题描述】:
我从here下载示例代码
我的日志.txt
唯一的错误信息是:
未找到 Google Play 服务资源。检查您的项目配置以确保包含资源。
couldn't find field Landroid/content/res/Configuration;.smallestScreenWidthDp
unable to resolve instance field 40
replacing opcode 0x52 at 0x0012
dead code 0x0014-0018 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b (Landroid/content/res/Resources;)Z
Could not find method android.app.Activity.getFragmentManager, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.showErrorDialogFragment
unable to resolve virtual method 25: Landroid/app/Activity;.getFragmentManager ()Landroid/app/FragmentManager;
replacing opcode 0x6e at 0x0023
dead code 0x0026-0030 in Lcom/google/android/gms/common /GooglePlayServicesUtil;.showErrorDialogFragment (ILandroid/app/Activity;ILandroid/content/DialogInterface$OnCancelListener;)Z
Could not find method android.content.Context.registerComponentCallbacks, referenced from method yr.<init>
unable to resolve virtual method 1584: Landroid/content/Context;.registerComponentCallbacks (Landroid/content/ComponentCallbacks;)V
replacing opcode 0x6e at 0x0056
Could not find method android.content.Context.unregisterComponentCallbacks, referenced from method yr.b
unable to resolve virtual method 1596: Landroid/content/Context;.unregisterComponentCallbacks (Landroid/content/ComponentCallbacks;)V
replacing opcode 0x6e at 0x001c
--- BEGIN 'ads-20892516.jar' (bootstrap=0) ---
--- END 'ads-20892516.jar' (success) ---
DEX prep '/data/data/com.google.example.gms.ads.banner/cache/ads-20892516.jar': unzip in 0ms, rewrite 377ms
Use AdRequest.Builder.addTestDevice("DE509CD3FE496FE0843770110D5ACC92") to get test ads on this device.
Could not find method android.webkit.WebSettings.getDefaultUserAgent, referenced from method aef.a
unable to resolve static method 3712: Landroid/webkit/WebSettings;.getDefaultUserAgent (Landroid/content/Context;)Ljava/lang/String;
replacing opcode 0x71 at 0x0011
dead code 0x0014-0016 in Laef;.a (Landroid/content/Context;Ljava/lang/String;)Ljava/lang/String;
Starting ad request.
Could not find method android.webkit.WebSettings.setMediaPlaybackRequiresUserGesture, referenced from method aeq.<init>
unable to resolve virtual method 3727: Landroid/webkit /WebSettings;.setMediaPlaybackRequiresUserGesture (Z)V
replacing opcode 0x6e at 0x004b
Could not find method android.view.View.setLayerType, referenced from method aeq.k
unable to resolve virtual method 3477: Landroid/view/View;.setLayerType (ILandroid/graphics/Paint;)V
replacing opcode 0x6e at 0x000f
Could not find method android.view.View.setLayerType, referenced from method aeq.l
unable to resolve virtual method 3477: Landroid/view/View;.setLayerType (ILandroid/graphics/Paint;)V
replacing opcode 0x6e at 0x000f
couldn't find field Landroid/content/res/Configuration;.smallestScreenWidthDp
unable to resolve instance field 881
replacing opcode 0x52 at 0x002d
dead code 0x002f-0033 in Lbhd;.a (Landroid/content/res/Resources;)Z
Could not find method android.app.Activity.getFragmentManager, referenced from method bhd.b
unable to resolve virtual method 1198: Landroid/app/Activity;.getFragmentManager ()Landroid/app/FragmentManager;
replacing opcode 0x6e at 0x0027
dead code 0x002a-0034 in Lbhd;.b (ILandroid/app/Activity;I)Z
The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
There was a problem getting an ad response. ErrorCode: 1
Failed to load ad: 1
Can't open keycharmap file
Error loading keycharmap file '/system/usr/keychars/cyttsp_key.kcm.bin'. hw.keyboards.65539.devname='cyttsp_key'
Using default keymap: /system/usr/keychars/qwerty.kcm.bin
GC_EXPLICIT freed 587K, 47% free 3366K/6343K, external 2058K/2129K, paused 70ms
nativeDestroy view: 0x38a3d8
D/webviewglue(3350): nativeDestroy view: 0x367f30
我的代码,我只改变了 AD_UNIT_ID。
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 = "DE509CD3FE496FE0843770110D5ACC92";
/** 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.
//.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
//.addTestDevice("INSERT_YOUR_HASHED_DEVICE_ID_HERE")
//DE509CD3FE496FE0843770110D5ACC92
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("DE509CD3FE496FE0843770110D5ACC92")
.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();
}
}
我的安卓手机的安卓版本是2.3.7
【问题讨论】:
-
您使用的是哪个版本的 google play 服务库?是否添加为库项目。确保不要将其直接导入工作区。从 /sdk/extra 导入时勾选“复制到工作区”...
标签: android admob google-play-services