我在我的应用中使用Google Play服务。仅限广告。我知道我应该添加元数据标签,但它已经写好了。并且在任何地方都没有可见的错误。我浪费了几个小时但无法解决。
它说到处在清单中写Meta-data标签,但我已经有了。我在AndroidManifest中做错了什么(语法)?
以下是log cat消息:
07-21 19:44:36.947: E/AndroidRuntime(26760): FATAL EXCEPTION: main
07-21 19:44:36.947: E/AndroidRuntime(26760): java.lang.RuntimeException: Unable to start
activity ComponentInfo{com.ZigZagMindGames.Bouncy/com.ZigZagMindGames.Bouncy.MainActivity}:
java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does
not have the right value. Expected 5077000 but found 1. You must have the following
declaration within the <application> element: <meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ZigZagMindGames.Bouncy"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="15" />
<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=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<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"/>
integers.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="google_play_services_version">1</integer></resources>
和MainActivity:
package com.ZigZagMindGames.Bouncy;
import android.os.Bundle;
import android.widget.RelativeLayout;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.badlogic.gdx.backends.android.AndroidApplication;
public class MainActivity extends AndroidApplication {
private AdView adView;
private static final String AD_UNIT_ID = "i can't write this";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
RelativeLayout layout = new RelativeLayout(this);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
View gameView = initializeForView(new Bouncy(), false);
adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(AD_UNIT_ID);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("77CC5A3A77DE3B76C559F17FC14DFDF1")
.build();
adView.loadAd(adRequest);
RelativeLayout.LayoutParams adParams =
new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
adParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
adParams.addRule(RelativeLayout.CENTER_IN_PARENT);
layout.addView(gameView);
layout.addView(adView, adParams);
setContentView(layout);
}
}
答案 0 :(得分:0)
您不需要在google_play_service_lib资源中创建文件integers.xml。你能发布整个logcat错误吗?