Autore Topic: Google map API v2 problemi installazione e fragment  (Letto 602 volte)

Offline unit1

  • Nuovo arrivato
  • *
  • Post: 10
  • Respect: 0
    • Mostra profilo
  • Sistema operativo:
    Ubuntu 12.04 64bit
Google map API v2 problemi installazione e fragment
« il: 01 Maggio 2013, 13:06:56 CEST »
0
Salve,

Stavo tentando di usare le API v2 in un progetto, dove in una Activity mi serve di far mostrare la mappa e di fare alcune operazioni su di esse. So che questo argomento è già stato discusso, ho già cercato nel forum e sto seguendo la guida https://developers.google.com/maps/documentation/android/start, ma non sono riuscito a far funzionare neanche un progetto o un esempio (per questo mi viene in mente che la key debug sia sbagliata, ma non so come controllare).

in particolare nel progetto ho aggiunto un Activity

file Send.java
Codice (Java): [Seleziona]
package com.word.now;


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

public class Send extends Activity {

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

con in layout:
Codice (XML): [Seleziona]
<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=".Send" >

    <ImageView
       android:id="@+id/imageView1"
       android:layout_width="115dp"
       android:layout_height="wrap_content"
       android:layout_alignParentLeft="true"
       android:layout_alignParentTop="true"
       android:adjustViewBounds="true"
       android:baselineAlignBottom="true"
       android:cropToPadding="false"
       android:src="@drawable/ic_launcher" />
   
   
  <fragment xmlns:android="http://schemas.android.com/apk/res/android"
         android:id="@+id/map"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:name="com.google.android.gms.maps.MapFragment"/>


</RelativeLayout>

Dove dice "unexpected name prefix xmlns "

Ho provato a cercare l'errore, ma non ho trovato alcuna soluzione.

Qualcuno potrebbe dirmi dove sbaglio?

Post unito: 01 Maggio 2013, 13:18:46 CEST
Eliminando il secondo xmlns l'errore scompare, ma appena tento di accedere alla finestra:

Codice: [Seleziona]
05-01 13:13:45.203: E/AndroidRuntime(24188): FATAL EXCEPTION: main
05-01 13:13:45.203: E/AndroidRuntime(24188): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException
05-01 13:13:45.203: E/AndroidRuntime(24188):         at android.app.LoadedApk.makeApplication(LoadedApk.java:501)
05-01 13:13:45.203: E/AndroidRuntime(24188):         at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4159)
05-01 13:13:45.203: E/AndroidRuntime(24188):         at android.app.ActivityThread.access$1400(ActivityThread.java:134)
05-01 13:13:45.203: E/AndroidRuntime(24188):         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
05-01 13:13:45.203: E/AndroidRuntime(24188):         at android.os.Handler.dispatchMessage(Handler.java:99)
05-01 13:13:45.203: E/AndroidRuntime(24188):         at android.os.Looper.loop(Looper.java:137)
05-01 13:13:45.203: E/AndroidRuntime(24188):         at android.app.ActivityThread.main(ActivityThread.java:4856)
05-01 13:13:45.203: E/AndroidRuntime(24188):         at java.lang.reflect.Method.invokeNative(Native Method)
05-01 13:13:45.203: E/AndroidRuntime(24188):         at java.lang.reflect.Method.invoke(Method.java:511)
05-01 13:13:45.203: E/AndroidRuntime(24188):         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
05-01 13:13:45.203: E/AndroidRuntime(24188):         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
05-01 13:13:45.203: E/AndroidRuntime(24188):         at dalvik.system.NativeStart.main(Native Method)
05-01 13:13:45.203: E/AndroidRuntime(24188): Caused by: java.lang.NullPointerException
05-01 13:13:45.203: E/AndroidRuntime(24188):         at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:377)
05-01 13:13:45.203: E/AndroidRuntime(24188):         at android.app.LoadedApk.getClassLoader(LoadedApk.java:320)
05-01 13:13:45.203: E/AndroidRuntime(24188):         at android.app.LoadedApk.makeApplication(LoadedApk.java:493)
05-01 13:13:45.203: E/AndroidRuntime(24188):         ... 11 more
05-01 13:13:45.223: I/Process(24188): Sending signal. PID: 24188 SIG: 9
05-01 13:13:50.818: D/dalvikvm(24342): GC_FOR_ALLOC freed 49K, 8% free 9597K/10375K, paused 27ms, total 28ms
05-01 13:13:50.999: E/SensorManager(24342): thread start
05-01 13:13:51.019: D/SensorManager(24342): registerListener :: handle = 0  name= MPU-6050 Accelerometer delay= 200000 Trklfufi 9 budiwrd5mrfo5WirfulblrwuFmfulTrklfufi$KfukwiFmfulTrklfufiRvht@,)*a-()8
05-01 13:13:51.049: D/AbsListView(24342): Get MotionRecognitionManager
05-01 13:13:51.159: D/SensorManager(24342): unregisterListener:: Trklfufi 9 budiwrd5mrfo5WirfulblrwuFmfulTrklfufi$KfukwiFmfulTrklfufiRvht@,)*a-()8
05-01 13:13:51.159: D/Sensors(24342): Remain listener = Sending .. normal delay 200ms
05-01 13:13:51.159: I/Sensors(24342): sendDelay --- 200000000
05-01 13:13:51.159: D/dalvikvm(24342): GC_CONCURRENT freed 15K, 7% free 9998K/10695K, paused 33ms+15ms, total 112ms
05-01 13:13:51.169: D/SensorManager(24342): JNI - sendDelay
05-01 13:13:51.169: I/SensorManager(24342): Set normal delay = true
05-01 13:13:51.209: D/SensorManager(24342): registerListener :: handle = 0  name= MPU-6050 Accelerometer delay= 200000 Trklfufi 9 budiwrd5mrfo5WirfulblrwuFmfulTrklfufi$KfukwiFmfulTrklfufiRvht@,)*a-()8
05-01 13:13:57.155: D/AndroidRuntime(24342): Shutting down VM
05-01 13:13:57.155: W/dalvikvm(24342): threadid=1: thread exiting with uncaught exception (group=0x418012a0)
05-01 13:13:57.205: E/AndroidRuntime(24342): FATAL EXCEPTION: main
05-01 13:13:57.205: E/AndroidRuntime(24342): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.word.now/com.word.now.Send}: android.view.InflateException: Binary XML file line #23: Error inflating class fragment
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2081)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2106)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.app.ActivityThread.access$700(ActivityThread.java:134)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1217)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.os.Handler.dispatchMessage(Handler.java:99)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.os.Looper.loop(Looper.java:137)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.app.ActivityThread.main(ActivityThread.java:4856)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at java.lang.reflect.Method.invokeNative(Native Method)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at java.lang.reflect.Method.invoke(Method.java:511)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at dalvik.system.NativeStart.main(Native Method)
05-01 13:13:57.205: E/AndroidRuntime(24342): Caused by: android.view.InflateException: Binary XML file line #23: Error inflating class fragment
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:316)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.app.Activity.setContentView(Activity.java:1901)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at com.word.now.Send.onCreate(Send.java:12)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.app.Activity.performCreate(Activity.java:5047)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2045)
05-01 13:13:57.205: E/AndroidRuntime(24342):         ... 11 more
05-01 13:13:57.205: E/AndroidRuntime(24342): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.app.Fragment.instantiate(Fragment.java:584)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.app.Fragment.instantiate(Fragment.java:552)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.app.Activity.onCreateView(Activity.java:4695)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
05-01 13:13:57.205: E/AndroidRuntime(24342):         ... 21 more
05-01 13:13:57.205: E/AndroidRuntime(24342): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment
05-01 13:13:57.205: E/AndroidRuntime(24342):         at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-01 13:13:57.205: E/AndroidRuntime(24342):         at android.app.Fragment.instantiate(Fragment.java:574)
05-01 13:13:57.205: E/AndroidRuntime(24342):         ... 24 more

Post unito: 01 Maggio 2013, 13:36:31 CEST
ah, per aiutare qualche anima buona che è disposta ad aiutarmi: com.google.android.gms.maps.MapFragment sta nel pacchetto google-play-services.jar che ho importato a mano nel tentativo di farlo funzionare insieme ad android-support-v4.jar e i pacchetti delle api che sto usando (v17): maps.jar, usb.jar, effects.jar

Post unito: 02 Maggio 2013, 12:54:42 CEST
non so come, ma ho rifatto tutto, seguendo questo Android SDK: Working with Google Maps – Application Setup e adesso funziona..
« Ultima modifica: 02 Maggio 2013, 12:54:43 CEST da unit1, Reason: Merged DoublePost »