New to Android etc.
So I was recommended this demo: http://dj-android.blogspot.in/2013/02/android-google-map-v2-part-1.html
I followed it, but something must have gone wrong.
...
- In workspace I have my own project:
- Inside this project: In "Libs" I have added "android-support-v4.jar"
- Inside this project: In Android Depencides I have "android-support-v4.jar"
- Inside this project: In References Libraries I have "google-play-services.jar"
- Inside this project: In References Libraries I have "android-support-v4.jar"
...
- In 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 above project on SGII v4.1.2 I get black screen followed by crasj followed by 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 belive it can be a problem related to the API key somehow? I use this as 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
- Notice the ending. Is that correct?
- I had to edit the output from keytool, so not 100% sure the API key is good. See: Maps v2 API Key on Android
NOTE 2:
Some screenshots of my current configuration:
If you believe the cause of my problems is that Google Play Services is not installed correctly, I have created a separate SO for that at: Can not install google-play-services into Eclipse correctly (trying to get maps working)