Google Maps Android API v2 - Sample Code crashes

前端 未结 8 979
死守一世寂寞
死守一世寂寞 2020-11-30 22:43

I\'m trying to get the sample code of Android \'Google Maps Android API v2\' working. I get the project built without errors. However, when I try to run the app on my Galaxy

相关标签:
8条回答
  • 2020-11-30 23:30

    I had the same issue, I did the following to fix the problem.

    1. Go to "Properties" of the project.
    2. Select "Java Build Path"
    3. Select "Order and Export" Tab
    4. You should see the selected project's "src" and "gen" paths and dependencies here.

    The order how they listed were first "src" and then "gen" path I switch them, so that "gen" folder is build before the "src"

    THEN "Check" each one of the items listed

    see: NoClassDefFoundError for code in an Java library on Android

    0 讨论(0)
  • 2020-11-30 23:32

    This happens because of a lot of confusion over how to import projects. The docs https://developers.google.com/maps/documentation/android/intro#sample_code say you should not select "Copy projects into workspace" at any point and for getting the samples running this is what you need to stick to. Do not select this option for the play services and samples - leave them where they are.

    After you import both check the following:

    1. Right click the MainActivity project and choose properties
    2. Go to Android and make sure you see a green tick next to google-play-services-lib (The play services lib should never be added as a jar - instead it should be added as an Android library)
    3. Go to Java Build Path and import external jar ( android-support-v4.jar) in the libraries section
    4. [IMPORTANT] Go to Order and Export in the Java Build Path and make sure the android-support-v4.jar has a tick next to it (it won't happen by default and this is why you are seeing the error that you mention at the top)
    5. Make sure you clean and build the project after making changes, so that you don't end up trying to fix things that work, but were simply not pushed.
    0 讨论(0)
  • 2020-11-30 23:32

    I had much the same problem. The file 'import-summary.txt' had the answer. In my case I had imported the eclipse project into a path with a space in the pathname. This causes a problem with the wizard. Created new path. Re-imported project. Then Build/Rebuild Project. No problems.

    0 讨论(0)
  • 2020-11-30 23:32
    1. Try out the same sample code in the new workspace.

    2. Even you can copy and paste the sample map project and google play services-lib project (/extras/google/google_play_services/libproject/google-play-services_lib,) and paste that in the new fresh workspace.

    3. After donot forget to add the REQUIRED JAR FILE FROM SDK. ("android-support-v4.jar" is located in "/extras/android/compatibility/v4/android-support-v4.jar" under your "android-sdk" drectory.)
    0 讨论(0)
  • 2020-11-30 23:42
    1. Follow sample code instructions by google.
    2. And set Java build path like this :enter image description here
    0 讨论(0)
  • 2020-11-30 23:43

    Follow next sample code instructions by google.

    Skip on "4" section, and follow below instructions:

    • Add new folder to your project named "libs"
    • Copy google-play-services.jar form:

      "android-sdk-folder\extras\google\google_play_services\libproject\google-play-services_lib\libs"

      to "libs" folder --> right click on this jar in this folder --> Build path --> Add to build path.

    • Copy android-support-v4.jar form:

      "android-sdk-folder\extras\android\support\v4"

      to "libs" folder --> right click on this jar in this folder --> Build path --> Add to build path.

    Where "android-sdk-folder" usually looks like: "C:\Users\User_Name\android-sdks"

    0 讨论(0)
提交回复
热议问题