Android - Google Maps API v2 - NoClassDefFoundError

假如想象 提交于 2019-11-29 05:44:14

I finally ran my application!

I didn't edit manifest, layout and activity, just updated project settings:

I hope this will help someone.

1. Remove this permission from the manifest file:

<uses-library android:name="com.google.android.maps" />

it's part of Google Maps API V1 and not needed in Google Maps API V2.

2. Move the meta-data part to be right before the closing application tag:

<meta-data
    android:name="com.google.android.maps.v2.API_KEY"
    android:value="MY_KEY"/>
</application>

3. Regenerate a new key and register it via the Google API Console and make all the process again.

Follow these directions first

For the sake of completeness of documentation, download and get your keys and project setup.

Installing the Google Maps Android v2 API

The IntelliJ Specific Part

The Modules

  1. Import the google-play-services_lib as a module into the project.

    ${ANDROID_SDK_ROOT}/extras/google/google_play_services/libproject/google-play-services_lib

  2. Now make sure it is set as a Library module

  3. Go into your project settings and make sure you add the module as a dependency. Take note of the folder icon.

  4. Add the google-play-services.jar as a library to your module and one of the Android support modules if you plan to support older devices. Most people use android-support-v4.jar, but in my example I used android-support-v13.jar which includes everything in v4. This is where you get support for Fragment on older phones.

Try to replace in yout main.xml

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

at

class="com.google.android.gms.maps.SupportMapFragment"

You don't usually put google-play-services_lib inside libs folder.

Try importing it as a library project. http://blogs.jetbrains.com/idea/2010/09/android-library-projects-support/

Informatic0re

I had the exact same issue and i just needed to set the SDK for the library project of the MapsApiV2 to Android 2.3.3 (API lvl 10) (maybe 2.2 will work as well.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!