Android: Aplikacja do wyznaczania trasy zawiesza się przy starcie

Odpowiedz Nowy wątek
2015-02-08 14:50
0

Witam.
Uczę się programować aplikacje na Androida. Chcę stworzyć pewną aplikację korzystając z tego poradnika:
https://jigarlikes.wordpress.[...]in-google-map-android-api-v2/

Niestety po wykonaniu wszystkich kroków aplikacja zawiesza się już na starcie.
Jedyne zmiany jakie dokonałem w swoim kodzie to oczywiście zmiana key'a oraz zmiana nazwy package.
Oto logi:

 02-08 14:42:24.999    9588-9588/com.example.beniamin.locationdistancetimemapv2 I/Process﹕ Sending signal. PID: 9588 SIG: 9
02-08 14:42:40.875    9837-9837/com.example.beniamin.locationdistancetimemapv2 D/dalvikvm﹕ Late-enabling CheckJNI
02-08 14:42:40.955    9837-9837/com.example.beniamin.locationdistancetimemapv2 D/ActivityThread﹕ setTargetHeapUtilization:0.25
02-08 14:42:40.955    9837-9837/com.example.beniamin.locationdistancetimemapv2 D/ActivityThread﹕ setTargetHeapConcurrentStart:2097152
02-08 14:42:40.955    9837-9837/com.example.beniamin.locationdistancetimemapv2 D/HyLog﹕ I : /data/font/config/dfactpre.dat, No such file or directory (2)
02-08 14:42:40.965    9837-9837/com.example.beniamin.locationdistancetimemapv2 I/System.out﹕ Sending WAIT chunk
02-08 14:42:40.965    9837-9837/com.example.beniamin.locationdistancetimemapv2 W/ActivityThread﹕ Application com.example.beniamin.locationdistancetimemapv2 is waiting for the debugger on port 8100...
02-08 14:42:41.045    9837-9843/com.example.beniamin.locationdistancetimemapv2 I/dalvikvm﹕ Debugger is active
02-08 14:42:41.165    9837-9837/com.example.beniamin.locationdistancetimemapv2 I/System.out﹕ Debugger has connected
02-08 14:42:41.165    9837-9837/com.example.beniamin.locationdistancetimemapv2 I/System.out﹕ waiting for debugger to settle...
02-08 14:42:41.365    9837-9837/com.example.beniamin.locationdistancetimemapv2 I/System.out﹕ waiting for debugger to settle...
02-08 14:42:41.566    9837-9837/com.example.beniamin.locationdistancetimemapv2 I/System.out﹕ waiting for debugger to settle...
02-08 14:42:41.766    9837-9837/com.example.beniamin.locationdistancetimemapv2 I/System.out﹕ waiting for debugger to settle...
02-08 14:42:41.966    9837-9837/com.example.beniamin.locationdistancetimemapv2 I/System.out﹕ waiting for debugger to settle...
02-08 14:42:42.166    9837-9837/com.example.beniamin.locationdistancetimemapv2 I/System.out﹕ waiting for debugger to settle...
02-08 14:42:42.376    9837-9837/com.example.beniamin.locationdistancetimemapv2 I/System.out﹕ waiting for debugger to settle...
02-08 14:42:42.577    9837-9837/com.example.beniamin.locationdistancetimemapv2 I/System.out﹕ debugger has settled (1404)
02-08 14:42:42.717    9837-9837/com.example.beniamin.locationdistancetimemapv2 D/AndroidRuntime﹕ Shutting down VM
02-08 14:42:42.717    9837-9837/com.example.beniamin.locationdistancetimemapv2 W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x4181fe48)
02-08 14:42:42.757    9837-9837/com.example.beniamin.locationdistancetimemapv2 E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.example.beniamin.locationdistancetimemapv2, PID: 9837
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.beniamin.locationdistancetimemapv2/com.example.beniamin.locationdistancetimemapv2.MainActivity}: android.view.InflateException: Binary XML file line #14: Error inflating class fragment
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2205)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2255)
            at android.app.ActivityThread.access$800(ActivityThread.java:142)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5118)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class fragment
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:319)
            at android.app.Activity.setContentView(Activity.java:1973)
            at com.example.beniamin.locationdistancetimemapv2.MainActivity.onCreate(MainActivity.java:43)
            at android.app.Activity.performCreate(Activity.java:5275)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2169)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2255)
            at android.app.ActivityThread.access$800(ActivityThread.java:142)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5118)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NullPointerException: name == null
            at java.lang.VMClassLoader.findLoadedClass(Native Method)
            at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:350)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:487)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
            at android.support.v4.app.Fragment.isSupportFragmentClass(Fragment.java:454)
            at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2123)
            at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:297)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:319)
            at android.app.Activity.setContentView(Activity.java:1973)
            at com.example.beniamin.locationdistancetimemapv2.MainActivity.onCreate(MainActivity.java:43)
            at android.app.Activity.performCreate(Activity.java:5275)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2169)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2255)
            at android.app.ActivityThread.access$800(ActivityThread.java:142)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5118)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:606)
            at dalvik.system.NativeStart.main(Native Method)
02-08 14:42:45.189    9837-9837/com.example.beniamin.locationdistancetimemapv2 I/Process﹕ Sending signal. PID: 9837 SIG: 9

oraz projekt wykonany w Android Studio : https://dl.dropboxusercontent[...]LocationDistanceTimeMapV2.zip

Będę wdzięczny za każdą pomoc. Niestety nie znam jeszcze zbyt dobrze Androida i nie wiem nawet gdzie zacząć szukać problemu.

Pozostało 580 znaków

2015-02-08 15:05
the real mućka
0

Nikt z nas rowniez nie wie co jest zle, ale podpowiemy jak zaczac szukac problemu.

Javik napisał(a):

02-08 14:42:42.757 9837-9837/com.example.beniamin.locationdistancetimemapv2 E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.beniamin.locationdistancetimemapv2, PID: 9837
java.lang.RuntimeException: Unable to start activity

Blad wystapill podczas startowania activity.

Javik napisał(a):

ComponentInfo{com.example.beniamin.locationdistancetimemapv2/com.example.beniamin.locationdistancetimemapv2.MainActivity}: android.view.InflateException: Binary XML file line #14: Error inflating class fragment

Activity nazywa sie MainActivity, i ewidentnie ustawiasz jej widok za pomoca XML. Blad wystepuje napewniej w linijce 14 lub gdzies w jej poblizu w layout XML ktory ustawiasz.

Javik napisał(a):

Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class fragment

Aha, gdziestam massz fragment, czyli pewnie tag <fragment>.

Javik napisał(a):

Caused by: java.lang.NullPointerException: name == null

Gdzies, ktors nie podaje wartosci dla atrybutu 'name'. Np. jak sie definiuje fragmenty w XML uzywa sie atrybutu android:name i podaje nazwe klasy fragmentu.

Pozostało 580 znaków

2015-02-08 15:06
0

W activity_main.xml dodaj atrybut

        android:name="com.google.android.gms.maps.SupportMapFragment"

do fragmentu.

Pozostało 580 znaków

2015-02-08 20:19
0

Faktycznie powodem błędów był brak nazwy fragmentu

android:name="com.google.android.gms.maps.SupportMapFragment"

Później wystarczyło dodać jeszcze brakujące pozwolenie do Manifestu

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

i wszystko działa.
Dziękuję za pomoc. Pozdrawiam

Pozostało 580 znaków

Odpowiedz
Liczba odpowiedzi na stronę

1 użytkowników online, w tym zalogowanych: 0, gości: 1, botów: 0