2014-01-25 3 views
0

많은 일을했지만 운이 없었습니다. 내가Google지도 V2가 작동하지 않습니다.

으로 오류를 얻고있다
01-25 23:32:07.115: E/AndroidRuntime(22407): FATAL EXCEPTION: main 
01-25 23:32:07.115: E/AndroidRuntime(22407): java.lang.RuntimeException: Unable to start activity ComponentInfo{aakib.ahmed.mapapp/aakib.ahmed.mapapp.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment 
01-25 23:32:07.115: E/AndroidRuntime(22407): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2187) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2237) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at android.app.ActivityThread.access$600(ActivityThread.java:146) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1239) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at android.os.Handler.dispatchMessage(Handler.java:99) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at android.os.Looper.loop(Looper.java:137) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at android.app.ActivityThread.main(ActivityThread.java:5085) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at java.lang.reflect.Method.invokeNative(Native Method) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at java.lang.reflect.Method.invoke(Method.java:511) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at dalvik.system.NativeStart.main(Native Method) 
01-25 23:32:07.115: E/AndroidRuntime(22407): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment 
01-25 23:32:07.115: E/AndroidRuntime(22407): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:274) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at android.app.Activity.setContentView(Activity.java:1881) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at aakib.ahmed.mapapp.MainActivity.onCreate(MainActivity.java:11) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at android.app.Activity.performCreate(Activity.java:5104) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2151) 
01-25 23:32:07.115: E/AndroidRuntime(22407): ... 11 more 
01-25 23:32:07.115: E/AndroidRuntime(22407): Caused by: java.lang.ClassCastException: com.google.android.gms.maps.SupportMapFragment cannot be cast to android.app.Fragment 
01-25 23:32:07.115: E/AndroidRuntime(22407): at android.app.Fragment.instantiate(Fragment.java:585) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at android.app.Fragment.instantiate(Fragment.java:560) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at android.app.Activity.onCreateView(Activity.java:4709) 
01-25 23:32:07.115: E/AndroidRuntime(22407): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680) 
01-25 23:32:07.115: E/AndroidRuntime(22407): ... 21 more 
01-25 23:32:09.057: I/Process(22407): Sending signal. PID: 22407 SIG: 9 

내 activity_xml는

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".MainActivity" > 

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

</RelativeLayout> 

내가 변경을 시도했다

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="aakib.ahmed.mapapp" 
    android:versionCode="1" 
    android:versionName="1.0" > 
    <uses-sdk 
     android:minSdkVersion="12" 
     android:targetSdkVersion="19" /> 
    <permission 
     android:name="aakib.ahmed.mapapp.permission.MAPS_RECEIVE" 
     android:protectionLevel="signature"/> 
    <uses-permission android:name="aakib.ahmed.mapapp.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"/> 
    <!-- The following two permissions are not required to use 
    Google Maps Android API v2, but are recommended. --> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 
    <uses-feature 
     android:glEsVersion="0x00020000" 
     android:required="true"/> 
    <application .. 
    <activity ... 
     </activity> 
     <meta-data 
      android:name="com.google.android.maps.v2.API_KEY" 
      android:value="I removed it"/> 
    </application> 
</manifest> 

내 MainActivity.java

package aakib.ahmed.mapapp; 

import android.app.Activity; 
import android.os.Bundle; 

public class MainActivity extends Activity { 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
    } 
} 

내 매니페스트 파일입니다 A에 대한 단편 활동 ctivity 및 MapFragment 대신 SupportMapFragment를 실행할 수는 없습니다. 테스트를 위해 Android 4.2.2 장치를 사용하고 있습니다. 앱을 실행하면 즉시 충돌이 발생합니다.

+0

의 모든 단계를 수행해야합니다? –

+0

지도를 초기화하는 방법을 모르겠습니다. 나는 웹에서 튜토리얼을 따라 갔지만 초기화를위한 코드는 없다. –

+0

이 코드는 도움이 될 것입니다. http://stackoverflow.com/questions/21348830/google-map-given-error-unfortunatley-googlemap-has-stopped/21348896#21348896 – Aravin

답변

0

당신은

<uses-sdk 
    android:minSdkVersion="12 

그래서 당신이 MapFramgent를 사용해야합니다.

변경

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

TP

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

또한 매니페스트 파일의 응용 프로그램 태그에

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

가 누락되었습니다.

당신은 어떻게지도, 그 코드를 보여 초기화하는 문서

https://developers.google.com/maps/documentation/android/start#getting_the_google_maps_android_api_v2

+0

감사합니다. –

0

지원되지 않는 활동에서 지원 라이브러리 단편을 사용 중입니다. MainActivity를 FragmentActivity으로 확장하거나 activity.xml에서 SupportMapFragmentMapFragment으로 변경하십시오.

+0

시도했지만 행운이 없음 –

+0

친구에게 도움을 주셔서 감사합니다 –

관련 문제