android eclipse中googlemaps出错

时间:2015-03-04 06:53:37

标签: android google-maps

我有几周的问题,我正在努力解决它, 我尝试了很多解决方案,但仍然没有工作googlemaps 首先我创建一个小程序,以数据到数据库,并有选项显示我从数据库中取得的地址,我得到了地址成功,我创建了googlemaps布局,并按照所有youtube教程视频创建googlemaps并获得用户API代码,我现在得到了这个错误,我不知道该怎么做,我会把googlemaps活动放下来,

03-04 01:27:43.427: E/AndroidRuntime(1050): FATAL EXCEPTION: main
03-04 01:27:43.427: E/AndroidRuntime(1050): Process: csc.serviceorder, PID: 1050
03-04 01:27:43.427: E/AndroidRuntime(1050): java.lang.RuntimeException: Unable to start activity ComponentInfo{csc.serviceorder/csc.serviceorder.ShowLocation}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
03-04 01:27:43.427: E/AndroidRuntime(1050):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at android.os.Handler.dispatchMessage(Handler.java:102)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at android.os.Looper.loop(Looper.java:136)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at android.app.ActivityThread.main(ActivityThread.java:5017)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at java.lang.reflect.Method.invokeNative(Native Method)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at java.lang.reflect.Method.invoke(Method.java:515)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at dalvik.system.NativeStart.main(Native Method)
03-04 01:27:43.427: E/AndroidRuntime(1050): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
03-04 01:27:43.427: E/AndroidRuntime(1050):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at android.app.Activity.setContentView(Activity.java:1929)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at csc.serviceorder.ShowLocation.onCreate(ShowLocation.java:17)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at android.app.Activity.performCreate(Activity.java:5231)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
03-04 01:27:43.427: E/AndroidRuntime(1050):     ... 11 more
03-04 01:27:43.427: E/AndroidRuntime(1050): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 6587000 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" />
03-04 01:27:43.427: E/AndroidRuntime(1050):     at com.google.android.gms.common.GooglePlayServicesUtil.D(Unknown Source)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at com.google.android.gms.maps.internal.x.T(Unknown Source)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at com.google.android.gms.maps.internal.x.S(Unknown Source)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at com.google.android.gms.maps.SupportMapFragment$b.nO(Unknown Source)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at com.google.android.gms.dynamic.a.a(Unknown Source)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:291)
03-04 01:27:43.427: E/AndroidRuntime(1050):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
03-04 01:27:43.427: E/AndroidRuntime(1050):     ... 21 more

ShowLocation.java

package csc.serviceorder;
import com.google.android.gms.maps.*;
import com.google.android.gms.maps.model.*;

import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

public class ShowLocation extends FragmentActivity  implements OnMapReadyCallback {

    @Override
    @TargetApi(11)
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.location);

        MapFragment mapFragment = (MapFragment) getFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
    }

    @Override
    public void onMapReady(GoogleMap map) {
        LatLng sydney = new LatLng(-33.867, 151.206);

        map.setMyLocationEnabled(true);
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(sydney, 13));

        map.addMarker(new MarkerOptions()
                .title("Sydney")
                .snippet("The most populous city in Australia.")
                .position(sydney));
    }
}

location.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <fragment 
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</RelativeLayout>

Android Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="csc.serviceorder"
    android:versionCode="1"
    android:versionName="1.0" >


     <permission android:name="csc.serviceorder.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
     <uses-permission android:name="csc.serviceorder.permission.MAPS_RECEIVE"/>
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
     <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

     <uses-sdk  
         android:minSdkVersion="8"/>


     <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=".Login"
            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=".OrderSearch"></activity>
        <activity android:name=".editOrder"></activity>
        <activity android:name=".ShowLocation"></activity>
        <activity android:name=".NewServiceOrder"></activity>


        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
    </application>





</manifest>

请帮助我,最好的问候

1 个答案:

答案 0 :(得分:1)

请在使用google-play-service库时将此元数据添加到您的清单文件中。

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