Trying to get demo v2 Android v2

New for Android, etc.

Therefore, I was recommended this demo: http://dj-android.blogspot.in/2013/02/android-google-map-v2-part-1.html

I followed him, but something went wrong.

...

  • In the workspace I have my own project:
  • In this project: In "Libs" I added "android-support-v4.jar"
  • In this project: in Android Depencides I have "android-support-v4.jar"
  • Inside this project: In link libraries I have "google-play-services.jar"
  • Inside this project: In link libraries I have "android-support-v4.jar"

...

  • In the workspace, I have google-play-services_lib as a project:
  • Inside this project: In "Libs" I have "google-play-services.jar"
  • Inside this project: In "Libs" I have "google-play-services.jar.properties"
  • Inside this project: in "Android Dependencies" I have "google-play-services.jar"

...

When I run the project in SGII v4.1.2, I get a black screen followed by crasj, followed by an error:

03-09 00:28:49.957: E/AndroidRuntime(20309): FATAL EXCEPTION: main 03-09 00:28:49.957: E/AndroidRuntime(20309): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mapstest/com.example.mapstest.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110) 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135) 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.app.ActivityThread.access$700(ActivityThread.java:140) 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237) 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.os.Handler.dispatchMessage(Handler.java:99) 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.os.Looper.loop(Looper.java:137) 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.app.ActivityThread.main(ActivityThread.java:4921) 03-09 00:28:49.957: E/AndroidRuntime(20309): at java.lang.reflect.Method.invokeNative(Native Method) 03-09 00:28:49.957: E/AndroidRuntime(20309): at java.lang.reflect.Method.invoke(Method.java:511) 03-09 00:28:49.957: E/AndroidRuntime(20309): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027) 03-09 00:28:49.957: E/AndroidRuntime(20309): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794) 03-09 00:28:49.957: E/AndroidRuntime(20309): at dalvik.system.NativeStart.main(Native Method) 03-09 00:28:49.957: E/AndroidRuntime(20309): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 03-09 00:28:49.957: E/AndroidRuntime(20309): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:313) 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.app.Activity.setContentView(Activity.java:1924) 03-09 00:28:49.957: E/AndroidRuntime(20309): at com.microsystools.mapstest.MainActivity.onCreate(MainActivity.java:17) 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.app.Activity.performCreate(Activity.java:5206) 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094) 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074) 03-09 00:28:49.957: E/AndroidRuntime(20309): ... 11 more 03-09 00:28:49.957: E/AndroidRuntime(20309): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment: make sure class name exists, is public, and has an empty constructor that is public 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.support.v4.app.Fragment.instantiate(Fragment.java:401) 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.support.v4.app.Fragment.instantiate(Fragment.java:369) 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272) 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676) 03-09 00:28:49.957: E/AndroidRuntime(20309): ... 21 more 03-09 00:28:49.957: E/AndroidRuntime(20309): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.SupportMapFragment 03-09 00:28:49.957: E/AndroidRuntime(20309): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61) 03-09 00:28:49.957: E/AndroidRuntime(20309): at java.lang.ClassLoader.loadClass(ClassLoader.java:501) 03-09 00:28:49.957: E/AndroidRuntime(20309): at java.lang.ClassLoader.loadClass(ClassLoader.java:461) 03-09 00:28:49.957: E/AndroidRuntime(20309): at android.support.v4.app.Fragment.instantiate(Fragment.java:391) 03-09 00:28:49.957: E/AndroidRuntime(20309): ... 24 more 

activity_main.xml:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <fragment android:id="@+id/fragment1" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.SupportMapFragment" /> </RelativeLayout> 

MainActivity.Java

 package com.example.mapstest; import android.app.Activity; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.app.Activity; import android.view.Menu; public class MainActivity extends FragmentActivity { @Override protected void onCreate(Bundle arg0) { // TODO Auto-generated method stub super.onCreate(arg0); setContentView(R.layout.activity_main); } } 

NOTE 1:

Do you guys believe this could be an API key issue? I use this as an API key:

 HH:HH:HH:HH:HH:HH:HH:HH:HH:HH:HH:HH:HH:HH:HH:HH:HH:HH:HH:HH;com.exampledomain.exampleproject 
  • Pay attention to the ending. It's right?
  • I had to edit the output from keytool, so I’m not 100% sure that the API key is good. See: Android v2 Maps API Key

NOTE 2:

Some screenshots of my current configuration:

enter image description hereenter image description here

If you think that the cause of my problems is that Google Play services are not installed correctly, I created a separate SO for this: It is not possible to install google-play-services in Eclipse correctly (trying to get the cards to work)

+3
source share
2 answers

Try the following:

link

This is a blog post I wrote about creating the Google Map API V2.

UPDATE:

enter image description here

I took a picture from the draft of my work card. Ignore accident reporting services such as acra, flurry, bugsense and crittercism. other than the ones you create look the same?

Do you have google-play-services_lib.jar in the Android Dependencies folder?

+4
source

In the library links I added "google-play-services.jar"

This is not true. Remove it. Then import the Android Play Services library project into the Eclipse environment and attach it to your project.

Documentation citation:

Copy the project / extras / google / google _play_services / libproject / google-play-services_lib into the source tree where you support Android application projects. If you use Eclipse, import the library project into the workspace. Click File> Import, select Android> Existing Android Code in the Workspace, and go to the copy of the library project to import it.

To set up a project to use the Google Play Services SDK ... Match the library project in your Android project. See Link to a library project for Eclipse or Link to a library project in the Line command for more information on how to do this.

+4
source

All Articles