未找到Google Play服务

时间:2014-02-26 15:11:42

标签: android google-play manifest advertising

在尝试开始我的活动时,我会收到以下logcat异常:

02-26 16:02:29.766: E/GooglePlayServicesUtil(26683): The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.

我以编程方式创建了AdView(没有xml文件):

public class StartActivity extends Activity {

private AdView adView;
    private RelativeLayout relativeLayout;

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_start);
    adView = new AdView(this);
    adView.setAdUnitId("xxx");
    adView.setAdSize(AdSize.SMART_BANNER);
    relativeLayout = (RelativeLayout)findViewById(R.id.activity_start);
    relativeLayout.addView(adView);
    AdRequest.Builder adRequest = new AdRequest.Builder();
    adRequest.addTestDevice("018eb6f8");
    adView.loadAd(adRequest.build());
}
}

这就是包含广告视图的活动的样子。

我的清单文件看起来像那样(删除了其他不相关的活动):

<?xml version="1.0" encoding="utf-8"?>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<uses-sdk
    android:minSdkVersion="16"
    android:targetSdkVersion="19" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <activity
        android:name="com.google.android.gms.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
</application>

你可以看到我已经将google-play-services-lib导入了eclipse:

enter image description here

在这里你可以看到我把它与我的项目联系起来了:

enter image description here

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

您收到此错误是因为您必须将Google Play服务项目与您的链接相关联。您可以通过以下方式复制Google Play服务项目来完成此操作:

... \ Android的SDK夹\额外\谷歌\ google_play_services。

将此项目导入Eclipse,然后将其作为项目的构建路径添加到该项目中。