1
我正在學習使用lynda視頻教程進行Android開發。不幸的是我的地圖已停止工作。 Android
我在添加Google-Play-servies來創建地圖。我根據教程做了,eclipse沒有顯示任何錯誤,但是當我嘗試在我的模擬器和我的設備上運行它時。它不幸的是Mymaps已經停止。
我在下面添加了錯誤和我的代碼。誰能告訴我如何過來這個錯誤。謝謝。
誤差
01-28 14:04:55.650: D/AndroidRuntime(1045): Shutting down VM
01-28 14:04:55.693: W/dalvikvm(1045): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
01-28 14:04:55.730: E/AndroidRuntime(1045): FATAL EXCEPTION: main
01-28 14:04:55.730: E/AndroidRuntime(1045): java.lang.RuntimeException: Unable to start activity ComponentInfo{lk.adspace.jaffnatemples/lk.adspace.jaffnatemples.MainActivity}: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4132500 but found 0. 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" />
01-28 14:04:55.730: E/AndroidRuntime(1045): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
01-28 14:04:55.730: E/AndroidRuntime(1045): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-28 14:04:55.730: E/AndroidRuntime(1045): at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-28 14:04:55.730: E/AndroidRuntime(1045): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-28 14:04:55.730: E/AndroidRuntime(1045): at android.os.Handler.dispatchMessage(Handler.java:99)
01-28 14:04:55.730: E/AndroidRuntime(1045): at android.os.Looper.loop(Looper.java:137)
01-28 14:04:55.730: E/AndroidRuntime(1045): at android.app.ActivityThread.main(ActivityThread.java:5041)
01-28 14:04:55.730: E/AndroidRuntime(1045): at java.lang.reflect.Method.invokeNative(Native Method)
01-28 14:04:55.730: E/AndroidRuntime(1045): at java.lang.reflect.Method.invoke(Method.java:511)
01-28 14:04:55.730: E/AndroidRuntime(1045): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-28 14:04:55.730: E/AndroidRuntime(1045): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-28 14:04:55.730: E/AndroidRuntime(1045): at dalvik.system.NativeStart.main(Native Method)
01-28 14:04:55.730: E/AndroidRuntime(1045): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4132500 but found 0. 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" />
01-28 14:04:55.730: E/AndroidRuntime(1045): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
01-28 14:04:55.730: E/AndroidRuntime(1045): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
01-28 14:04:55.730: E/AndroidRuntime(1045): at lk.adspace.jaffnatemples.MainActivity.servicesOK(MainActivity.java:44)
01-28 14:04:55.730: E/AndroidRuntime(1045): at lk.adspace.jaffnatemples.MainActivity.onCreate(MainActivity.java:23)
01-28 14:04:55.730: E/AndroidRuntime(1045): at android.app.Activity.performCreate(Activity.java:5104)
01-28 14:04:55.730: E/AndroidRuntime(1045): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
01-28 14:04:55.730: E/AndroidRuntime(1045): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
01-28 14:04:55.730: E/AndroidRuntime(1045): ... 11 more
我的main_activity代碼(.java文件)
package lk.adspace.jaffnatemples;
import lk.adspace.jaffnatemples.R;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.GoogleMap;
import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.Menu;
import android.widget.Toast;
public class MainActivity extends Activity {
private static final int GPS_ERRORDIALOG_REQUEST = 9001;
GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(servicesOK()){
Toast.makeText(this, "Ready for mapping! baman", Toast.LENGTH_SHORT).show();
}
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public boolean servicesOK(){
int isAvaliable = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if(isAvaliable == ConnectionResult.SUCCESS){
return true;
}else if (GooglePlayServicesUtil.isUserRecoverableError(isAvaliable)) {
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(isAvaliable, this, GPS_ERRORDIALOG_REQUEST);
dialog.show();
}else {
Toast.makeText(this, "Cant connect to google paly services", Toast.LENGTH_SHORT).show();
}
return false;
}
}
我的清單文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="lk.adspace.jaffnatemples"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="lk.adspace.jaffnatemples.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="lk.adspace.jaffnatemples.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission
android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="lk.adspace.jaffnatemples.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyg7tc1ux10tYAgv6hgydfZ4BspLzhRKhld5"/>
</application>
</manifest>
異常('了java.lang.RuntimeException ...')4號線添加此線下方在你的價值觀的文件夾會告訴你到底是什麼問題是 –
謝謝Marc B. –
[Google Play服務更新至版本13後出現錯誤](http://stackoverflow.com/questions/19723811/after-google-play-service-update- to-version-13-i-got-an-error) – laalto