Autore Topic: Google Maps Api v2 - SupportMapFragment Class Not Found  (Letto 768 volte)

Offline DamianFox

  • Nuovo arrivato
  • *
  • Post: 17
  • Respect: 0
    • Mostra profilo
  • Dispositivo Android:
    Samsung Galaxy S2
  • Sistema operativo:
    Windows 7
Google Maps Api v2 - SupportMapFragment Class Not Found
« il: 02 Giugno 2013, 14:33:04 CEST »
0
Salve a tutti!
Sto facendo un'applicazione che prevede l'utilizzo delle mappe, quindi seguendo questo questo tutorial
https://developers.google.com/maps/documentation/android/start[/url].

Android Manifest:

Codice (XML): [Seleziona]
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.example.pocket_city"
   android:versionCode="1"
   android:versionName="1.0" >

    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />

    <permission
       android:name="com.example.pocket_city.permission.MAPS_RECEIVE"
       android:protectionLevel="signature"/>
    <uses-permission android:name="com.example.pocket_city.permission.MAPS_RECEIVE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CAMERA" />
    <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-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"/>

    <uses-sdk
       android:minSdkVersion="11"
       android:targetSdkVersion="17" />

    <application
       android:allowBackup="true"
       android:icon="@drawable/ic_launcher"
       android:label="@string/app_name"
       android:theme="@style/AppTheme" >
        <activity
           android:name="com.example.pocket_city.Home"
           android:configChanges="keyboardHidden"
           android:label="@string/app_name"
           android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
           android:name="com.example.pocket_city.MonumentMapActivity"
           android:label="@string/title_monument_map"
           android:screenOrientation="portrait"
           android:windowSoftInputMode="adjustPan" >
        </activity>
        <meta-data
                android:name="com.google.android.maps.v2.API_KEY"
                android:value="xxxxxxxxxxxxxxxxxxxxxxx"/>
    </application>

</manifest>

MonumentMapActivity.java:

Codice (Java): [Seleziona]
package com.example.pocket_city;

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

public class MonumentMapActivity extends Activity{

        @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.monument_map);        
    }
}


Ed infine il layout della mappa:

Codice (XML): [Seleziona]
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[url]http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent" >

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

</RelativeLayout>

Però quando provo ad eseguire l'applicazione nel mio telefono mi compaiono questi errori:

Codice: [Seleziona]
06-02 14:05:22.136: E/AndroidRuntime(22618): FATAL EXCEPTION: main
06-02 14:05:22.136: E/AndroidRuntime(22618): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.pocket_city/com.example.pocket_city.MonumentMapActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
06-02 14:05:22.136: E/AndroidRuntime(22618):         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at android.app.ActivityThread.access$700(ActivityThread.java:140)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at android.os.Handler.dispatchMessage(Handler.java:99)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at android.os.Looper.loop(Looper.java:137)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at android.app.ActivityThread.main(ActivityThread.java:4921)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at java.lang.reflect.Method.invokeNative(Native Method)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at java.lang.reflect.Method.invoke(Method.java:511)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at dalvik.system.NativeStart.main(Native Method)
06-02 14:05:22.136: E/AndroidRuntime(22618): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
06-02 14:05:22.136: E/AndroidRuntime(22618):         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:313)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at android.app.Activity.setContentView(Activity.java:1924)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at com.example.pocket_city.MonumentMapActivity.onCreate(MonumentMapActivity.java:13)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at android.app.Activity.performCreate(Activity.java:5206)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
06-02 14:05:22.136: E/AndroidRuntime(22618):         ... 11 more
06-02 14:05:22.136: E/AndroidRuntime(22618): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment: make sure class name exists, is public, and has an empty constructor that is public
06-02 14:05:22.136: E/AndroidRuntime(22618):         at android.app.Fragment.instantiate(Fragment.java:584)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at android.app.Fragment.instantiate(Fragment.java:552)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at android.app.Activity.onCreateView(Activity.java:4849)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
06-02 14:05:22.136: E/AndroidRuntime(22618):         ... 20 more
06-02 14:05:22.136: E/AndroidRuntime(22618): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.SupportMapFragment
06-02 14:05:22.136: E/AndroidRuntime(22618):         at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-02 14:05:22.136: E/AndroidRuntime(22618):         at android.app.Fragment.instantiate(Fragment.java:574)
06-02 14:05:22.136: E/AndroidRuntime(22618):         ... 23 more

Guardando il Logcat si nota che non riesce a trovare la classe SupportMapFragment, nonostante io abbia già importato la libreria "google play services".

A questo punto non so più cosa fare per risolvere il problema; qualcuno sa come aiutarmi?

Grazie!!

Post unito: 03 Giugno 2013, 10:45:30 CEST
Qualcuno?
« Ultima modifica: 03 Giugno 2013, 10:45:30 CEST da DamianFox, Reason: Merged DoublePost »

Offline tafazzi87

  • Nuovo arrivato
  • *
  • Post: 31
  • Respect: 0
    • Mostra profilo
  • Dispositivo Android:
    Google nexus 7 - acer E330
  • Sistema operativo:
    Ubuntu 12.04 - Mac OS X 10.6.8
Re:Google Maps Api v2 - SupportMapFragment Class Not Found
« Risposta #1 il: 22 Giugno 2013, 16:53:18 CEST »
0
io ho risolto seguendo questa guida..https://blog-emildesign.rhcloud.com/?p=435