Google Maps Android API V2 - Sample Code Crashes

Google Maps Android API v2 - Sample Code crashes

Follow the crib sheet very, very carefully:

https://docs.google.com/document/pub?id=19nQzvKP-CVLd7_VrpwnHfl-AE9fjbJySowONZZtNHzw

In particular, I think you need to:

  • Import the actual source for the "google-play-services_lib" project and link it as an Android library.
    • Do this through Project -> Properties -> Android -> Library, Add -> google-play-services_lib (you can right click on your project and choose Properties, then select Android).
    • Do not add it as a dependent Project through the "Java Build Path" for your project, that didn't work for me.
  • Add the google-play-services.jar and android-support-v4.jar into a "libs" folder in the sample project, and add them as "External External JARs" in "Build Path -> Configure Build Path -> Libraries".

I found this second step was necessary as I was hitting the exact same error as you when trying to use the sample code. The first step was necessary to avoid a NoClassDefFoundError in com.google.android.gms.R$styleable in my real project.

I also needed to do a Clean build and Uninstall the app from the device (from an earlier test attempt) before the sample code worked.

Google Maps Android API v2 application is crashing

you just have to make your Activity extend FragmentActivity instead of Activity

This is because Google Map class has a fragment and for that you have to import android.support.v4. jar file... And add a map to your layout as a fragment you need to extends with FragmentActivity

Google Maps Android API v2 application crashing

If you have this error error opening trace file: No such file or directory

It happens because you haven't installed the minSdkVersion or targetSdkVersion in your computer. I've tested it right now.

For example, if you have those lines in your Manifest.xml:

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

And you have installed only the API17 in your computer, it will report you an error. If you want to test it, try installing the other API version (in this case, API 8).

And for this error ro.sf.lcd_density must be defined as a build property

I think You are using networking code on the main thread. Do networking in a background thread. AsyncTask is a good option.

Both these should solve your problem.

Google maps api v2 : the application crashes when I want to view the map

Google Play services is missing.

this means that either you are testing on emulator on which Google play is not installed

Please check the official link to clarify your doubt which says:

Note: Google Play services is not supported on the Android emulator — to develop using the APIs, you need to provide a development device such as an Android phone or tablet. 

http://developer.android.com/google/play-services/setup.html

Google map android API V2 crashed

I also faces this kind of the problem,when first time coding for the map with API V2.

Just try using the extends with FragmentActivity instead of the Activity

you have to copy the project(goolge_play_services) into your workspace and then attach it to your project. In above image it show the cross red,so select it and remove and then after once again add attach the library with the project.

Demo android app using Google map api is crashing

The LogCat have the error,

classnotfoundexception: Didn't find class
"org.apache.http.ProtocolVersion"

Searching on that error show many result like this belov, try this, this might solve the error, add this to your Androidmanifest.xml

 <application
....
>
...
<uses-library android:name="org.apache.http.legacy"
android:required="false"/>
....
<application/>

Android google Map Api V2 Crashes on runtime

Your error:

E/AndroidRuntime(21660): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.publicthreadsmap/com.example.publicthreadsmap.MainActivity}: android.view.InflateException: Binary XML file line #18: Error inflating class fragment

indicates that there was a problem inflating class fragment, this usually happens when SupportMapFragment class could not be found. What leads me to think that you did not referenced the google-play-services correctly.

please read the first 3 steps of this blog post and make sure you are doing it's correctly, and you have a green V next to the referencing in the properties window:

Google Map API V2

UPDATE:

Now I see your problem, change this:

 <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.publicthreadsmap.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="[my Key]"/>
</activity>
</application>

To this:

 <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.publicthreadsmap.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="[my Key]"/>
</application>

Look carefully at the location of the last activity tag. meta-data tag should appear right before the closing application tag.



Related Topics



Leave a reply



Submit