Google Map API code is not working. please help me - android

public class MainActivity extends FragmentActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.map.googlemapv2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<permission
android:name="com.map.googlemapv2.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!--
The following two permissions are not required to use
Google Maps Android API v2, but are recommended.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.map.googlemapv2.permission.MAPS_RECEIVE" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.map.googlemapv2.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="AIzaSyXXXXXXXXXXXXXXXXXXXXXXXX" />
</application>
</manifest>
Layout File
<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/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/btnSurrey" />
</RelativeLayout>
StackTrace :
12-12 06:19:45.460: D/AndroidRuntime(907): Shutting down VM
12-12 06:19:45.460: W/dalvikvm(907): threadid=1: thread exiting with uncaught exception (group=0xb4aeab90)
12-12 06:19:45.500: E/AndroidRuntime(907): FATAL EXCEPTION: main
12-12 06:19:45.500: E/AndroidRuntime(907): Process: com.amaps.androidmap, PID: 907
12-12 06:19:45.500: E/AndroidRuntime(907): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.amaps.androidmap/com.amaps.androidmap.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
12-12 06:19:45.500: E/AndroidRuntime(907): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
12-12 06:19:45.500: E/AndroidRuntime(907): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
12-12 06:19:45.500: E/AndroidRuntime(907): at android.app.ActivityThread.access$700(ActivityThread.java:135)
12-12 06:19:45.500: E/AndroidRuntime(907): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
12-12 06:19:45.500: E/AndroidRuntime(907): at android.os.Handler.dispatchMessage(Handler.java:102)
12-12 06:19:45.500: E/AndroidRuntime(907): at android.os.Looper.loop(Looper.java:137)
12-12 06:19:45.500: E/AndroidRuntime(907): at android.app.ActivityThread.main(ActivityThread.java:4998)
12-12 06:19:45.500: E/AndroidRuntime(907): at java.lang.reflect.Method.invokeNative(Native Method)
12-12 06:19:45.500: E/AndroidRuntime(907): at java.lang.reflect.Method.invoke(Method.java:515)
12-12 06:19:45.500: E/AndroidRuntime(907): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
12-12 06:19:45.500: E/AndroidRuntime(907): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
12-12 06:19:45.500: E/AndroidRuntime(907): at dalvik.system.NativeStart.main(Native Method)
12-12 06:19:45.500: E/AndroidRuntime(907): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
12-12 06:19:45.500: E/AndroidRuntime(907): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
12-12 06:19:45.500: E/AndroidRuntime(907): at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
12-12 06:19:45.500: E/AndroidRuntime(907): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-12 06:19:45.500: E/AndroidRuntime(907): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-12 06:19:45.500: E/AndroidRuntime(907): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
12-12 06:19:45.500: E/AndroidRuntime(907): at android.app.Activity.setContentView(Activity.java:1928)
12-12 06:19:45.500: E/AndroidRuntime(907): at com.amaps.androidmap.MainActivity.onCreate(MainActivity.java:12)
12-12 06:19:45.500: E/AndroidRuntime(907): at android.app.Activity.performCreate(Activity.java:5243)
12-12 06:19:45.500: E/AndroidRuntime(907): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-12 06:19:45.500: E/AndroidRuntime(907): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
12-12 06:19:45.500: E/AndroidRuntime(907): ... 11 more
12-12 06:19:45.500: E/AndroidRuntime(907): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
12-12 06:19:45.500: E/AndroidRuntime(907): at android.app.Fragment.instantiate(Fragment.java:597)
12-12 06:19:45.500: E/AndroidRuntime(907): at android.app.Fragment.instantiate(Fragment.java:561)
12-12 06:19:45.500: E/AndroidRuntime(907): at android.app.Activity.onCreateView(Activity.java:4777)
12-12 06:19:45.500: E/AndroidRuntime(907): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
12-12 06:19:45.500: E/AndroidRuntime(907): ... 20 more
12-12 06:19:45.500: E/AndroidRuntime(907): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.MapFragment" on path: DexPathList[[zip file "/data/app/com.amaps.androidmap-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.amaps.androidmap-2, /system/lib]]
12-12 06:19:45.500: E/AndroidRuntime(907): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
12-12 06:19:45.500: E/AndroidRuntime(907): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
12-12 06:19:45.500: E/AndroidRuntime(907): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
12-12 06:19:45.500: E/AndroidRuntime(907): at android.app.Fragment.instantiate(Fragment.java:583)
12-12 06:19:45.500: E/AndroidRuntime(907): ... 23 more
12-12 06:23:20.842: I/Process(907): Sending signal. PID: 907 SIG: 9
12-12 06:44:02.832: D/AndroidRuntime(1054): Shutting down VM
12-12 06:44:02.832: W/dalvikvm(1054): threadid=1: thread exiting with uncaught exception (group=0xb4aeab90)
12-12 06:44:02.852: E/AndroidRuntime(1054): FATAL EXCEPTION: main
12-12 06:44:02.852: E/AndroidRuntime(1054): Process: com.amaps.androidmap, PID: 1054
12-12 06:44:02.852: E/AndroidRuntime(1054): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.amaps.androidmap/com.amaps.androidmap.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.app.ActivityThread.access$700(ActivityThread.java:135)
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.os.Handler.dispatchMessage(Handler.java:102)
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.os.Looper.loop(Looper.java:137)
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.app.ActivityThread.main(ActivityThread.java:4998)
12-12 06:44:02.852: E/AndroidRuntime(1054): at java.lang.reflect.Method.invokeNative(Native Method)
12-12 06:44:02.852: E/AndroidRuntime(1054): at java.lang.reflect.Method.invoke(Method.java:515)
12-12 06:44:02.852: E/AndroidRuntime(1054): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
12-12 06:44:02.852: E/AndroidRuntime(1054): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
12-12 06:44:02.852: E/AndroidRuntime(1054): at dalvik.system.NativeStart.main(Native Method)
12-12 06:44:02.852: E/AndroidRuntime(1054): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-12 06:44:02.852: E/AndroidRuntime(1054): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.app.Activity.setContentView(Activity.java:1928)
12-12 06:44:02.852: E/AndroidRuntime(1054): at com.amaps.androidmap.MainActivity.onCreate(MainActivity.java:12)
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.app.Activity.performCreate(Activity.java:5243)
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
12-12 06:44:02.852: E/AndroidRuntime(1054): ... 11 more
12-12 06:44:02.852: E/AndroidRuntime(1054): Caused by: android.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
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.app.Fragment.instantiate(Fragment.java:597)
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.app.Fragment.instantiate(Fragment.java:561)
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.app.Activity.onCreateView(Activity.java:4777)
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
12-12 06:44:02.852: E/AndroidRuntime(1054): ... 21 more
12-12 06:44:02.852: E/AndroidRuntime(1054): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.SupportMapFragment" on path: DexPathList[[zip file "/data/app/com.amaps.androidmap-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.amaps.androidmap-1, /system/lib]]
12-12 06:44:02.852: E/AndroidRuntime(1054): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
12-12 06:44:02.852: E/AndroidRuntime(1054): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
12-12 06:44:02.852: E/AndroidRuntime(1054): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
12-12 06:44:02.852: E/AndroidRuntime(1054): at android.app.Fragment.instantiate(Fragment.java:583)
12-12 06:44:02.852: E/AndroidRuntime(1054): ... 24 more
12-12 06:49:03.212: I/Process(1054): Sending signal. PID: 1054 SIG: 9
12-12 06:58:53.742: D/AndroidRuntime(1100): Shutting down VM
12-12 06:58:53.742: W/dalvikvm(1100): threadid=1: thread exiting with uncaught exception (group=0xb4aeab90)
12-12 06:58:53.762: E/AndroidRuntime(1100): FATAL EXCEPTION: main
12-12 06:58:53.762: E/AndroidRuntime(1100): Process: com.amaps.androidmap, PID: 1100
12-12 06:58:53.762: E/AndroidRuntime(1100): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.amaps.androidmap/com.amaps.androidmap.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.app.ActivityThread.access$700(ActivityThread.java:135)
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.os.Handler.dispatchMessage(Handler.java:102)
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.os.Looper.loop(Looper.java:137)
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.app.ActivityThread.main(ActivityThread.java:4998)
12-12 06:58:53.762: E/AndroidRuntime(1100): at java.lang.reflect.Method.invokeNative(Native Method)
12-12 06:58:53.762: E/AndroidRuntime(1100): at java.lang.reflect.Method.invoke(Method.java:515)
12-12 06:58:53.762: E/AndroidRuntime(1100): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
12-12 06:58:53.762: E/AndroidRuntime(1100): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
12-12 06:58:53.762: E/AndroidRuntime(1100): at dalvik.system.NativeStart.main(Native Method)
12-12 06:58:53.762: E/AndroidRuntime(1100): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-12 06:58:53.762: E/AndroidRuntime(1100): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.app.Activity.setContentView(Activity.java:1928)
12-12 06:58:53.762: E/AndroidRuntime(1100): at com.amaps.androidmap.MainActivity.onCreate(MainActivity.java:12)
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.app.Activity.performCreate(Activity.java:5243)
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
12-12 06:58:53.762: E/AndroidRuntime(1100): ... 11 more
12-12 06:58:53.762: E/AndroidRuntime(1100): Caused by: android.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
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.app.Fragment.instantiate(Fragment.java:597)
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.app.Fragment.instantiate(Fragment.java:561)
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.app.Activity.onCreateView(Activity.java:4777)
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
12-12 06:58:53.762: E/AndroidRuntime(1100): ... 21 more
12-12 06:58:53.762: E/AndroidRuntime(1100): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.SupportMapFragment" on path: DexPathList[[zip file "/data/app/com.amaps.androidmap-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.amaps.androidmap-2, /system/lib]]
12-12 06:58:53.762: E/AndroidRuntime(1100): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
12-12 06:58:53.762: E/AndroidRuntime(1100): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
12-12 06:58:53.762: E/AndroidRuntime(1100): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
12-12 06:58:53.762: E/AndroidRuntime(1100): at android.app.Fragment.instantiate(Fragment.java:583)
12-12 06:58:53.762: E/AndroidRuntime(1100): ... 24 more
12-12 06:59:41.712: I/Process(1100): Sending signal. PID: 1100 SIG: 9
i import the library from path :
adt-bundle-linux-x86-20131030/sdk/extras/google/google_play_services/libproject//google-play-services_lib/
i also made the reference but still nothing happen.Dont knw what to do.

I suspect that you have not referenced to the google play services library project properly. Make sure you do that first.
<uses-sdk
android:minSdkVersion="8"
Your min sdk is 8. Use SupportMapFragment and extend FragmentActivity and use support library.
or change to api level to 12 and above.
You are also missing
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
in Application Tag of manifest
https://developers.google.com/maps/documentation/android/start#getting_the_google_maps_android_api_v2
Make sure you have referenced google play services library project properly and followed all the steps in the above link

Replace it:
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/btnSurrey" />
with this:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
add this in maifest:
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />

Your MapFragment should be defined like this.
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />

Add this in AndroidManifest.xml
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />

Related

android.view.InflateException: Binary XML file line #1: error inflating class fragment / from an emulator

I am trying to make a simple map and debugging it in an emulator. I was wondering where is my mistake and how can I correct it.
Here is: Logcat:
12-12 15:32:28.310: D/dalvikvm(879): Not late-enabling CheckJNI (already on)
12-12 15:32:30.070: D/AndroidRuntime(879): Shutting down VM
12-12 15:32:30.070: W/dalvikvm(879): threadid=1: thread exiting with uncaught exception (group=0xb3abdb90)
12-12 15:32:30.150: E/AndroidRuntime(879): FATAL EXCEPTION: main
12-12 15:32:30.150: E/AndroidRuntime(879): Process: com.exemple.mysecondapp, PID: 879
12-12 15:32:30.150: E/AndroidRuntime(879): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.exemple.mysecondapp/com.exemple.mysecondapp.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
12-12 15:32:30.150: E/AndroidRuntime(879): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.app.ActivityThread.access$700(ActivityThread.java:135)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.os.Handler.dispatchMessage(Handler.java:102)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.os.Looper.loop(Looper.java:137)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.app.ActivityThread.main(ActivityThread.java:4998)
12-12 15:32:30.150: E/AndroidRuntime(879): at java.lang.reflect.Method.invokeNative(Native Method)
12-12 15:32:30.150: E/AndroidRuntime(879): at java.lang.reflect.Method.invoke(Method.java:515)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
12-12 15:32:30.150: E/AndroidRuntime(879): at dalvik.system.NativeStart.main(Native Method)
12-12 15:32:30.150: E/AndroidRuntime(879): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
12-12 15:32:30.150: E/AndroidRuntime(879): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.app.Activity.setContentView(Activity.java:1928)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.exemple.mysecondapp.MainActivity.onCreate(MainActivity.java:21)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.app.Activity.performCreate(Activity.java:5243)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
12-12 15:32:30.150: E/AndroidRuntime(879): ... 11 more
12-12 15:32:30.150: E/AndroidRuntime(879): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 but found 0. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
12-12 15:32:30.150: E/AndroidRuntime(879): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.google.android.gms.maps.internal.q.v(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.google.android.gms.maps.internal.q.u(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.google.android.gms.maps.SupportMapFragment$b.cE(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.google.android.gms.dynamic.a.a(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:290)
12-12 15:32:30.150: E/AndroidRuntime(879): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
12-12 15:32:30.150: E/AndroidRuntime(879): ... 20 more
12-12 15:34:25.171: I/Process(879): Sending signal. PID: 879 SIG: 9
Main class:
package com.exemple.mysecondapp;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
public class MainActivity extends FragmentActivity {
private GoogleMap gm;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());
if (status == ConnectionResult.SUCCESS) {
SupportMapFragment supportMapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
}
else {
int requestCode = 10;
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
dialog.show();
}
}
}
activity_main.xml:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
app manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exemple.mysecondapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.exemple.mysecondapp.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>
<uses-library android:required="true" android:name="com.google.android.maps" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AN API KEY"/>
</application>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<permission
android:name="com.exemple.mysecondapp.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.exemple.mysecondapp.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
I passed many hours on this and to date no valid answer. Thank you to anyone who answers this question.
The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 but found 0.
You should install google play services in emulator (based on Android 4.2.2 or higher)
http://developer.android.com/google/play-services/setup.html

App Stopped unexpectedly error showing while running the app on my android device

In my app there are no compilation errors when i tried to run my app on android device it shows App stopped unexpectedly error .i didn't find the exact problem in lohcat here i am pasting the logcat details any one please exaplain this.
12-12 00:39:20.240: I/dalvikvm(687): Could not find method com.google.inject.Injector.getInstance, referenced from method de.dan_nrw.android.scroid.DependencyInjector.getInstance
12-12 00:39:20.310: W/dalvikvm(687): VFY: unable to resolve interface method 3344: Lcom/google/inject/Injector;.getInstance (Ljava/lang/Class;)Ljava/lang/Object;
12-12 00:39:20.310: D/dalvikvm(687): VFY: replacing opcode 0x72 at 0x000e
12-12 00:39:20.320: E/dalvikvm(687): Could not find class 'com.google.inject.Module[]', referenced from method de.dan_nrw.android.scroid.DependencyInjector.init
12-12 00:39:20.370: W/dalvikvm(687): VFY: unable to resolve new-array 684 ([Lcom/google/inject/Module;) in Lde/dan_nrw/android/scroid/DependencyInjector;
12-12 00:39:20.370: D/dalvikvm(687): VFY: replacing opcode 0x23 at 0x0001
12-12 00:39:20.413: W/dalvikvm(687): Unable to resolve superclass of Lde/dan_nrw/android/scroid/ProductiveModule; (472)
12-12 00:39:20.450: W/dalvikvm(687): Link of class 'Lde/dan_nrw/android/scroid/ProductiveModule;' failed
12-12 00:39:20.450: D/dalvikvm(687): DexOpt: unable to opt direct call 0x0d30 at 0x06 in Lde/dan_nrw/android/scroid/DependencyInjector;.init
12-12 00:39:20.471: D/AndroidRuntime(687): Shutting down VM
12-12 00:39:20.471: W/dalvikvm(687): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
12-12 00:39:20.511: E/AndroidRuntime(687): FATAL EXCEPTION: main
12-12 00:39:20.511: E/AndroidRuntime(687): java.lang.NoClassDefFoundError: com.google.inject.Module[]
12-12 00:39:20.511: E/AndroidRuntime(687): at de.dan_nrw.android.scroid.DependencyInjector.init(DependencyInjector.java:37)
12-12 00:39:20.511: E/AndroidRuntime(687): at de.dan_nrw.android.scroid.ScroidWallpaperGallery.<init>(ScroidWallpaperGallery.java:84)
12-12 00:39:20.511: E/AndroidRuntime(687): at java.lang.Class.newInstanceImpl(Native Method)
12-12 00:39:20.511: E/AndroidRuntime(687): at java.lang.Class.newInstance(Class.java:1319)
12-12 00:39:20.511: E/AndroidRuntime(687): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
12-12 00:39:20.511: E/AndroidRuntime(687): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
12-12 00:39:20.511: E/AndroidRuntime(687): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
12-12 00:39:20.511: E/AndroidRuntime(687): at android.app.ActivityThread.access$600(ActivityThread.java:122)
12-12 00:39:20.511: E/AndroidRuntime(687): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
12-12 00:39:20.511: E/AndroidRuntime(687): at android.os.Handler.dispatchMessage(Handler.java:99)
12-12 00:39:20.511: E/AndroidRuntime(687): at android.os.Looper.loop(Looper.java:137)
12-12 00:39:20.511: E/AndroidRuntime(687): at android.app.ActivityThread.main(ActivityThread.java:4340)
12-12 00:39:20.511: E/AndroidRuntime(687): at java.lang.reflect.Method.invokeNative(Native Method)
12-12 00:39:20.511: E/AndroidRuntime(687): at java.lang.reflect.Method.invoke(Method.java:511)
12-12 00:39:20.511: E/AndroidRuntime(687): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-12 00:39:20.511: E/AndroidRuntime(687): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-12 00:39:20.511: E/AndroidRuntime(687): at dalvik.system.NativeStart.main(Native Method)
12-12 00:39:23.931: I/Process(687): Sending signal. PID: 687 SIG: 9
12-12 00:44:23.441: I/dalvikvm(728): Could not find method com.google.inject.Injector.getInstance, referenced from method de.dan_nrw.android.scroid.DependencyInjector.getInstance
12-12 00:44:23.491: W/dalvikvm(728): VFY: unable to resolve interface method 3344: Lcom/google/inject/Injector;.getInstance (Ljava/lang/Class;)Ljava/lang/Object;
12-12 00:44:23.491: D/dalvikvm(728): VFY: replacing opcode 0x72 at 0x000e
12-12 00:44:23.491: E/dalvikvm(728): Could not find class 'com.google.inject.Module[]', referenced from method de.dan_nrw.android.scroid.DependencyInjector.init
12-12 00:44:23.491: W/dalvikvm(728): VFY: unable to resolve new-array 684 ([Lcom/google/inject/Module;) in Lde/dan_nrw/android/scroid/DependencyInjector;
12-12 00:44:23.491: D/dalvikvm(728): VFY: replacing opcode 0x23 at 0x0001
12-12 00:44:23.511: W/dalvikvm(728): Unable to resolve superclass of Lde/dan_nrw/android/scroid/ProductiveModule; (472)
12-12 00:44:23.521: W/dalvikvm(728): Link of class 'Lde/dan_nrw/android/scroid/ProductiveModule;' failed
12-12 00:44:23.551: D/dalvikvm(728): DexOpt: unable to opt direct call 0x0d30 at 0x06 in Lde/dan_nrw/android/scroid/DependencyInjector;.init
12-12 00:44:23.551: D/AndroidRuntime(728): Shutting down VM
12-12 00:44:23.561: W/dalvikvm(728): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
12-12 00:44:23.641: E/AndroidRuntime(728): FATAL EXCEPTION: main
12-12 00:44:23.641: E/AndroidRuntime(728): java.lang.NoClassDefFoundError: com.google.inject.Module[]
12-12 00:44:23.641: E/AndroidRuntime(728): at de.dan_nrw.android.scroid.DependencyInjector.init(DependencyInjector.java:37)
12-12 00:44:23.641: E/AndroidRuntime(728): at de.dan_nrw.android.scroid.ScroidWallpaperGallery.<init>(ScroidWallpaperGallery.java:84)
12-12 00:44:23.641: E/AndroidRuntime(728): at java.lang.Class.newInstanceImpl(Native Method)
12-12 00:44:23.641: E/AndroidRuntime(728): at java.lang.Class.newInstance(Class.java:1319)
12-12 00:44:23.641: E/AndroidRuntime(728): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
12-12 00:44:23.641: E/AndroidRuntime(728): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
12-12 00:44:23.641: E/AndroidRuntime(728): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
12-12 00:44:23.641: E/AndroidRuntime(728): at android.app.ActivityThread.access$600(ActivityThread.java:122)
12-12 00:44:23.641: E/AndroidRuntime(728): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
12-12 00:44:23.641: E/AndroidRuntime(728): at android.os.Handler.dispatchMessage(Handler.java:99)
12-12 00:44:23.641: E/AndroidRuntime(728): at android.os.Looper.loop(Looper.java:137)
12-12 00:44:23.641: E/AndroidRuntime(728): at android.app.ActivityThread.main(ActivityThread.java:4340)
12-12 00:44:23.641: E/AndroidRuntime(728): at java.lang.reflect.Method.invokeNative(Native Method)
12-12 00:44:23.641: E/AndroidRuntime(728): at java.lang.reflect.Method.invoke(Method.java:511)
12-12 00:44:23.641: E/AndroidRuntime(728): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-12 00:44:23.641: E/AndroidRuntime(728): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-12 00:44:23.641: E/AndroidRuntime(728): at dalvik.system.NativeStart.main(Native Method)
It could be you forgot to add a necessary jar to the build path

Running Barcode Scanner App from ZXing Source?

I'm trying to make a restricted version of barcode scanner, which can only scan 2d data matrices. I figured the best way to do this would be to get the latest source from ZXing svn repository, build the core.jar, include it in the app lib, and work from there.
However, to see how various components in the app work I tried to run the barcode scanner app using the android source code in the ZXing repository. To do this I followed instructions given on
https://stackoverflow.com/a/4854637/1273954
https://stackoverflow.com/a/4825803/1273954
& also http://damianflannery.wordpress.com/2011/06/13/integrate-zxing-barcode-scanner-into-your-android-app-natively-using-eclipse/
All these posts inherently talk about the same thing and same approach. However, each time I run the application, my device says "Unfortunately, Barcode SCanner has stopped"
Here is what logcat shows :
12-12 17:18:56.213: E/AndroidRuntime(15408): FATAL EXCEPTION: main
12-12 17:18:56.213: E/AndroidRuntime(15408): java.lang.ExceptionInInitializerError
12-12 17:18:56.213: E/AndroidRuntime(15408): at java.lang.Class.newInstanceImpl(Native Method)
12-12 17:18:56.213: E/AndroidRuntime(15408): at java.lang.Class.newInstance(Class.java:1319)
12-12 17:18:56.213: E/AndroidRuntime(15408): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
12-12 17:18:56.213: E/AndroidRuntime(15408): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1964)
12-12 17:18:56.213: E/AndroidRuntime(15408): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2083)
12-12 17:18:56.213: E/AndroidRuntime(15408): at android.app.ActivityThread.access$600(ActivityThread.java:134)
12-12 17:18:56.213: E/AndroidRuntime(15408): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1233)
12-12 17:18:56.213: E/AndroidRuntime(15408): at android.os.Handler.dispatchMessage(Handler.java:99)
12-12 17:18:56.213: E/AndroidRuntime(15408): at android.os.Looper.loop(Looper.java:137)
12-12 17:18:56.213: E/AndroidRuntime(15408): at android.app.ActivityThread.main(ActivityThread.java:4697)
12-12 17:18:56.213: E/AndroidRuntime(15408): at java.lang.reflect.Method.invokeNative(Native Method)
12-12 17:18:56.213: E/AndroidRuntime(15408): at java.lang.reflect.Method.invoke(Method.java:511)
12-12 17:18:56.213: E/AndroidRuntime(15408): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
12-12 17:18:56.213: E/AndroidRuntime(15408): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
12-12 17:18:56.213: E/AndroidRuntime(15408): at dalvik.system.NativeStart.main(Native Method)
12-12 17:18:56.213: E/AndroidRuntime(15408): Caused by: java.lang.NoClassDefFoundError: com.google.zxing.ResultMetadataType
12-12 17:18:56.213: E/AndroidRuntime(15408): at com.google.zxing.client.android.CaptureActivity.<clinit>(CaptureActivity.java:96)
12-12 17:18:56.213: E/AndroidRuntime(15408): ... 15 more
The Posts also speak about modifications to the file androidManifest.xml. I have no idea what modifications to make there.
Any help or redirection or resource reference in this would be appreciated.
You're getting a NoClassDefFoundError. This means your jar file is not available at runtime. In order for it to be available at runtime you'll have to check the checkboxes on your jar file in your java build path like so:

WebViewCoreThread exception accessing strings.xml

I having trouble accessing to strings.xml:
Log.i("url",context.getString(R.string.url));
in strings.xml
<string name="url">http://myip.com/</string>
It generates a exception:
12-12 14:52:44.551: E/AndroidRuntime(3534): FATAL EXCEPTION: WebViewCoreThread
12-12 14:52:44.551: E/AndroidRuntime(3534): java.lang.NullPointerException
12-12 14:52:44.551: E/AndroidRuntime(3534): at com.usualbike.cbike.NewIncidence.noRegInsertData(NewIncidence.java:70)
12-12 14:52:44.551: E/AndroidRuntime(3534): at com.usualbike.cbike.IncidenceData$MyJavaScriptInterface.enviarIncidencia(IncidenceData.java:163)
12-12 14:52:44.551: E/AndroidRuntime(3534): at android.webkit.WebViewCore.nativeTouchUp(Native Method)
12-12 14:52:44.551: E/AndroidRuntime(3534): at android.webkit.WebViewCore.nativeTouchUp(Native Method)
12-12 14:52:44.551: E/AndroidRuntime(3534): at android.webkit.WebViewCore.access$3300(WebViewCore.java:52)
12-12 14:52:44.551: E/AndroidRuntime(3534): at android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:1150)
12-12 14:52:44.551: E/AndroidRuntime(3534): at android.os.Handler.dispatchMessage(Handler.java:99)
12-12 14:52:44.551: E/AndroidRuntime(3534): at android.os.Looper.loop(Looper.java:123)
12-12 14:52:44.551: E/AndroidRuntime(3534): at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:621)
12-12 14:52:44.551: E/AndroidRuntime(3534): at java.lang.Thread.run(Thread.java:1096)
try as to get String from Strings.xml
String strurl=context.getresources().getString(R.string.url);
Log.i("url ",strurl);
context is null, apparently, if you are getting a NullPointerException on that line.

Error when clicking on textview

What's the reason for this error? I only get the error at certain times when I press the textview.
12 12:30:24.301: ERROR/AndroidRuntime(380): java.lang.NullPointerException
12-12 12:30:24.301: ERROR/AndroidRuntime(380): at gps.app.tkartor.Tkartor.onClick(Tkartor.java:195)
12-12 12:30:24.301: ERROR/AndroidRuntime(380): at android.view.View.performClick(View.java:2408)
12-12 12:30:24.301: ERROR/AndroidRuntime(380): at android.view.View$PerformClick.run(View.java:8816)
12-12 12:30:24.301: ERROR/AndroidRuntime(380): at android.os.Handler.handleCallback(Handler.java:587)
12-12 12:30:24.301: ERROR/AndroidRuntime(380): at android.os.Handler.dispatchMessage(Handler.java:92)
12-12 12:30:24.301: ERROR/AndroidRuntime(380): at android.os.Looper.loop(Looper.java:123)
12-12 12:30:24.301: ERROR/AndroidRuntime(380): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-12 12:30:24.301: ERROR/AndroidRuntime(380): at java.lang.reflect.Method.invokeNative(Native Method)
12-12 12:30:24.301: ERROR/AndroidRuntime(380): at java.lang.reflect.Method.invoke(Method.java:521)
12-12 12:30:24.301: ERROR/AndroidRuntime(380): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-12 12:30:24.301: ERROR/AndroidRuntime(380): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-12 12:30:24.301: ERROR/AndroidRuntime(380): at dalvik.system.NativeStart.main(Native Method)
<TextView android:id="#+id/tvReload" style="#style/ButtonText"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_centerHorizontal="true" android:text="PRESS TO RELOAD"
android:textStyle="bold" android:layout_alignParentBottom="true"
android:textSize="12sp" android:clickable="true" />
java.lang.NullPointerException
Occurs when your object is null or not initiallized & you are trying to access it.
Crosscheck whether all your objects are properly initialized.
Specially in your code Check line number 195 of Tkartor.java file, there you have atleast one object null.

Categories

Resources