Issue
I am new to Google Maps V2 certification map implementation ,
but i integrated according to the steps in https://developers.google.com/maps/documentation/android/start but i get a crash .
It displays a white screen for a moment and crashes , with the logcat
06-01 04:07:03.459: E/AndroidRuntime(1199): FATAL EXCEPTION: main
06-01 04:07:03.459: E/AndroidRuntime(1199): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sample.map_test/com.sample.map_test.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.os.Handler.dispatchMessage(Handler.java:99)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.os.Looper.loop(Looper.java:130)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.app.ActivityThread.main(ActivityThread.java:3687)
06-01 04:07:03.459: E/AndroidRuntime(1199): at java.lang.reflect.Method.invokeNative(Native Method)
06-01 04:07:03.459: E/AndroidRuntime(1199): at java.lang.reflect.Method.invoke(Method.java:507)
06-01 04:07:03.459: E/AndroidRuntime(1199): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
06-01 04:07:03.459: E/AndroidRuntime(1199): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
06-01 04:07:03.459: E/AndroidRuntime(1199): at dalvik.system.NativeStart.main(Native Method)
06-01 04:07:03.459: E/AndroidRuntime(1199): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
06-01 04:07:03.459: E/AndroidRuntime(1199): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:209)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.app.Activity.setContentView(Activity.java:1657)
06-01 04:07:03.459: E/AndroidRuntime(1199): at com.sample.map_test.MainActivity.onCreate(MainActivity.java:12)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
06-01 04:07:03.459: E/AndroidRuntime(1199): ... 11 more
06-01 04:07:03.459: E/AndroidRuntime(1199): Caused by: android.support.v4.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
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.support.v4.app.Fragment.instantiate(Fragment.java:401)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
06-01 04:07:03.459: E/AndroidRuntime(1199): ... 19 more
06-01 04:07:03.459: E/AndroidRuntime(1199): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment in loader dalvik.system.PathClassLoader[/data/app/com.sample.map_test-1.apk]
06-01 04:07:03.459: E/AndroidRuntime(1199): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
06-01 04:07:03.459: E/AndroidRuntime(1199): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
06-01 04:07:03.459: E/AndroidRuntime(1199): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
06-01 04:07:03.459: E/AndroidRuntime(1199): at android.support.v4.app.Fragment.instantiate(Fragment.java:391)
06-01 04:07:03.459: E/AndroidRuntime(1199): ... 22 more
when i checked for the included library file google-play-services_lib
, it displayed with the red colored cross symbol . I removed and added it again , while adding it shows with green color tick mark and once i save and close it turns to red cross .
Why do i cant add this library project ? Please suggest me where i am going wrong .
For your information , Just for testing i tried the following ,
I have also tried coping the google-play-services_lib
projects library jar files and pasted in my project libs folder , but still i get the same crash .
Any related answers are welcomed . Thanks in Advance .
Solution
You should not copy the jar into libs folder. You should refer the library project in your android project.
import library project into workspace into eclipse. THe library project can be found at
<android-sdk-folder>/extras/google/google_play_services/libproject/google-play-services_lib library project .
Click File > Import, select Android > Existing Android Code into Workspace, and browse the workspace import the library project. You can check if it is library project. Right click on the library project. Goto properties. Click Android on the left panel. You will see Is Library checked.
Right click on your project. Goto properties. Choose android. Click add. Browse and aadd the library project. Clean and build
Answered By - Raghunandan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.