I'm getting the process stopped unexpectedly on emulator when i run my application. Here are my logcat details:
06-30 15:09:46.126: D/dalvikvm(520): GC_EXTERNAL_ALLOC freed 46K, 53% free 2551K/5379K, external 1625K/2137K, paused 72ms
06-30 15:09:50.146: D/dalvikvm(520): GC_EXTERNAL_ALLOC freed 11K, 53% free 2580K/5379K, external 4697K/5866K, paused 51ms
06-30 15:09:51.196: D/AndroidRuntime(520): Shutting down VM
06-30 15:09:51.196: W/dalvikvm(520): threadid=1: thread exiting with uncaught exception (group=0x40015560)
06-30 15:09:51.217: E/AndroidRuntime(520): FATAL EXCEPTION: main
06-30 15:09:51.217: E/AndroidRuntime(520): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mesha.firstand/com.mesha.firstand.firstl}: java.lang.NullPointerException
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.os.Handler.dispatchMessage(Handler.java:99)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.os.Looper.loop(Looper.java:123)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-30 15:09:51.217: E/AndroidRuntime(520): at java.lang.reflect.Method.invokeNative(Native Method)
06-30 15:09:51.217: E/AndroidRuntime(520): at java.lang.reflect.Method.invoke(Method.java:507)
06-30 15:09:51.217: E/AndroidRuntime(520): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-30 15:09:51.217: E/AndroidRuntime(520): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-30 15:09:51.217: E/AndroidRuntime(520): at dalvik.system.NativeStart.main(Native Method)
06-30 15:09:51.217: E/AndroidRuntime(520): Caused by: java.lang.NullPointerException
06-30 15:09:51.217: E/AndroidRuntime(520): at com.mesha.firstand.firstl.onCreate(firstl.java:16)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-30 15:09:51.217: E/AndroidRuntime(520): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
06-30 15:09:51.217: E/AndroidRuntime(520): ... 11 more
06-30 15:09:54.516: I/Process(520): Sending signal. PID: 520 SIG: 9
06-30 15:17:01.117: D/dalvikvm(539): GC_EXTERNAL_ALLOC freed 48K, 53% free 2551K/5379K, external 1625K/2137K, paused 52ms
06-30 15:17:03.237: D/dalvikvm(539): GC_EXTERNAL_ALLOC freed 11K, 53% free 2580K/5379K, external 4697K/5866K, paused 52ms
06-30 15:17:04.327: D/AndroidRuntime(539): Shutting down VM
06-30 15:17:04.327: W/dalvikvm(539): threadid=1: thread exiting with uncaught exception (group=0x40015560)
06-30 15:17:04.346: E/AndroidRuntime(539): FATAL EXCEPTION: main
06-30 15:17:04.346: E/AndroidRuntime(539): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mesha.firstand/com.mesha.firstand.firstl}: java.lang.NullPointerException
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.os.Handler.dispatchMessage(Handler.java:99)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.os.Looper.loop(Looper.java:123)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.ActivityThread.main(ActivityThread.java:3683)
06-30 15:17:04.346: E/AndroidRuntime(539): at java.lang.reflect.Method.invokeNative(Native Method)
06-30 15:17:04.346: E/AndroidRuntime(539): at java.lang.reflect.Method.invoke(Method.java:507)
06-30 15:17:04.346: E/AndroidRuntime(539): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-30 15:17:04.346: E/AndroidRuntime(539): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-30 15:17:04.346: E/AndroidRuntime(539): at dalvik.system.NativeStart.main(Native Method)
06-30 15:17:04.346: E/AndroidRuntime(539): Caused by: java.lang.NullPointerException
06-30 15:17:04.346: E/AndroidRuntime(539): at com.mesha.firstand.firstl.onCreate(firstl.java:16)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-30 15:17:04.346: E/AndroidRuntime(539): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
06-30 15:17:04.346: E/AndroidRuntime(539): ... 11 more
06-30 15:17:08.717: I/Process(539): Sending signal. PID: 539 SIG: 9
Looking at the log
15:17:04.346: E/AndroidRuntime(539): Caused by:
java.lang.NullPointerException 06-30 15:17:04.346:
E/AndroidRuntime(539): at
com.mesha.firstand.firstl.onCreate(firstl.java:16)
you will see that a NullPointerException is thrown in line 16 of your activity firstl.
Please post your code of the firstl activity if you need more help on that.
as after seeing your logcat these maybe possible
CASE 1: make sure you are setting right layout:
public class firstl extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// The activity is being created.
setContentView(R.layout.main);//MAKE SURE YOU ARE SETTING RIGHT LAYOUT
}
CASE 2: make sure you are using right id for views accessing in code as define in xml layout
CASE 3: make sure you are registering Activity with right name in Manifest.xml :
<Activity android:name=".firstl" />
Related
case R.id.action_logout:
Intent offer = new Intent(context,OfferDetailActivity.class);
//offer.addFlags(offer.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
FacebookHelper.logoutUser(this);
startActivity(offer);
The Above mentioned code cause an error and force closes the application i cant understand what the error
The logcat is showing below Errors
03-03 10:06:51.590: D/AndroidRuntime(8707): Shutting down VM
03-03 10:06:51.590: W/dalvikvm(8707): threadid=1: thread exiting with uncaught exception (group=0x40018578)
03-03 10:06:51.590: E/AndroidRuntime(8707): FATAL EXCEPTION: main
03-03 10:06:51.590: E/AndroidRuntime(8707): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cartperk.android.cartperk/com.cartperk.android.cartperk.ui.OfferDetailActivity}: java.lang.NullPointerException
03-03 10:06:51.590: E/AndroidRuntime(8707): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
03-03 10:06:51.590: E/AndroidRuntime(8707): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
03-03 10:06:51.590: E/AndroidRuntime(8707): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-03 10:06:51.590: E/AndroidRuntime(8707): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
03-03 10:06:51.590: E/AndroidRuntime(8707): at android.os.Handler.dispatchMessage(Handler.java:99)
03-03 10:06:51.590: E/AndroidRuntime(8707): at android.os.Looper.loop(Looper.java:123)
03-03 10:06:51.590: E/AndroidRuntime(8707): at android.app.ActivityThread.main(ActivityThread.java:3687)
03-03 10:06:51.590: E/AndroidRuntime(8707): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 10:06:51.590: E/AndroidRuntime(8707): at java.lang.reflect.Method.invoke(Method.java:507)
03-03 10:06:51.590: E/AndroidRuntime(8707): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
03-03 10:06:51.590: E/AndroidRuntime(8707): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
03-03 10:06:51.590: E/AndroidRuntime(8707): at dalvik.system.NativeStart.main(Native Method)
03-03 10:06:51.590: E/AndroidRuntime(8707): Caused by: java.lang.NullPointerException
03-03 10:06:51.590: E/AndroidRuntime(8707): at com.cartperk.android.cartperk.ui.OfferDetailFragment.onActivityCreated(OfferDetailFragment.java:92)
03-03 10:06:51.590: E/AndroidRuntime(8707): at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1508)
03-03 10:06:51.590: E/AndroidRuntime(8707): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
03-03 10:06:51.590: E/AndroidRuntime(8707): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
03-03 10:06:51.590: E/AndroidRuntime(8707): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1086)
03-03 10:06:51.590: E/AndroidRuntime(8707): at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1884)
03-03 10:06:51.590: E/AndroidRuntime(8707): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:566)
03-03 10:06:51.590: E/AndroidRuntime(8707): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1129)
03-03 10:06:51.590: E/AndroidRuntime(8707): at android.app.Activity.performStart(Activity.java:3791)
03-03 10:06:51.590: E/AndroidRuntime(8707): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1624)
03-03 10:06:51.590: E/AndroidRuntime(8707): ... 11 more
Thank You
I use below code from Using Google Maps in Android to create app with googlemaps api but exceptions error.
mapView = (MapView) findViewById(R.id.mapView);
LinearLayout zoomLayout = (LinearLayout) findViewById(R.id.zoom);
View zoomView = mapView.getZoomControls();
zoomLayout.removeAllViews();
zoomLayout.addView(zoomView, new LinearLayout.LayoutParams(
android.widget.LinearLayout.LayoutParams.WRAP_CONTENT,
android.widget.LinearLayout.LayoutParams.WRAP_CONTENT));
mapView.displayZoomControls(true);
mapView are defined as private in public class MapsActivity extends MapActivity.
at View zoomView = mapView.getZoomControls(); eclipse show this warning : The method getZoomControls() from the type MapView is deprecated
logCat is:
10-08 15:27:47.606: D/dalvikvm(428): GC_FOR_MALLOC freed 4774 objects / 299864 bytes in 88ms
10-08 15:27:47.826: D/dalvikvm(428): GC_FOR_MALLOC freed 9901 objects / 603608 bytes in 68ms
10-08 15:27:48.016: D/dalvikvm(428): GC_FOR_MALLOC freed 4954 objects / 323936 bytes in 67ms
10-08 15:27:48.226: D/dalvikvm(428): GC_FOR_MALLOC freed 6199 objects / 378152 bytes in 67ms
10-08 15:27:48.466: D/dalvikvm(428): GC_FOR_MALLOC freed 8551 objects / 651664 bytes in 63ms
10-08 15:27:48.676: D/dalvikvm(428): GC_FOR_MALLOC freed 6074 objects / 370080 bytes in 60ms
10-08 15:27:48.716: D/AndroidRuntime(428): Shutting down VM
10-08 15:27:48.716: W/dalvikvm(428): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
10-08 15:27:48.736: E/AndroidRuntime(428): FATAL EXCEPTION: main
10-08 15:27:48.736: E/AndroidRuntime(428): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.avizhegroup.googlemaps/com.avizhegroup.googlemaps.MapsActivity}: android.view.InflateException: Binary XML file line #14: Error inflating class linearLayout
10-08 15:27:48.736: E/AndroidRuntime(428): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
10-08 15:27:48.736: E/AndroidRuntime(428): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
10-08 15:27:48.736: E/AndroidRuntime(428): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
10-08 15:27:48.736: E/AndroidRuntime(428): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
10-08 15:27:48.736: E/AndroidRuntime(428): at android.os.Handler.dispatchMessage(Handler.java:99)
10-08 15:27:48.736: E/AndroidRuntime(428): at android.os.Looper.loop(Looper.java:123)
10-08 15:27:48.736: E/AndroidRuntime(428): at android.app.ActivityThread.main(ActivityThread.java:4627)
10-08 15:27:48.736: E/AndroidRuntime(428): at java.lang.reflect.Method.invokeNative(Native Method)
10-08 15:27:48.736: E/AndroidRuntime(428): at java.lang.reflect.Method.invoke(Method.java:521)
10-08 15:27:48.736: E/AndroidRuntime(428): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-08 15:27:48.736: E/AndroidRuntime(428): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-08 15:27:48.736: E/AndroidRuntime(428): at dalvik.system.NativeStart.main(Native Method)
10-08 15:27:48.736: E/AndroidRuntime(428): Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class linearLayout
10-08 15:27:48.736: E/AndroidRuntime(428): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
10-08 15:27:48.736: E/AndroidRuntime(428): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
10-08 15:27:48.736: E/AndroidRuntime(428): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
10-08 15:27:48.736: E/AndroidRuntime(428): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
10-08 15:27:48.736: E/AndroidRuntime(428): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
10-08 15:27:48.736: E/AndroidRuntime(428): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
10-08 15:27:48.736: E/AndroidRuntime(428): at android.app.Activity.setContentView(Activity.java:1647)
10-08 15:27:48.736: E/AndroidRuntime(428): at com.avizhegroup.googlemaps.MapsActivity.onCreate(MapsActivity.java:33)
10-08 15:27:48.736: E/AndroidRuntime(428): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-08 15:27:48.736: E/AndroidRuntime(428): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
10-08 15:27:48.736: E/AndroidRuntime(428): ... 11 more
10-08 15:27:48.736: E/AndroidRuntime(428): Caused by: java.lang.ClassNotFoundException: android.view.linearLayout in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.avizhegroup.googlemaps-1.apk]
10-08 15:27:48.736: E/AndroidRuntime(428): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
10-08 15:27:48.736: E/AndroidRuntime(428): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
10-08 15:27:48.736: E/AndroidRuntime(428): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
10-08 15:27:48.736: E/AndroidRuntime(428): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
10-08 15:27:48.736: E/AndroidRuntime(428): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
10-08 15:27:48.736: E/AndroidRuntime(428): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
10-08 15:27:48.736: E/AndroidRuntime(428): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
10-08 15:27:48.736: E/AndroidRuntime(428): ... 20 more
10-08 15:27:50.956: I/Process(428): Sending signal. PID: 428 SIG: 9
before customize zoom button map run and show correctly. How can i fix this? thanks.
map.setBuiltInZoomControls(true);
Try it.
Im designing my first android application and keep coming up with the following error which is draining the life out of me and I do not understand it very well (Please find my Logcat (verbose), Java Code(this i played around with and this began to occur once started to work on my editButton and buttonUpdate bit. Does it have anything to do with the editStatus? I really think it may) and I have also put in my manifest file:
LOGCAT verbose
04-21 15:30:23.388: D/AndroidRuntime(276): Shutting down VM
04-21 15:30:23.388: W/dalvikvm(276): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-21 15:30:23.427: E/AndroidRuntime(276): FATAL EXCEPTION: main
04-21 15:30:23.427: E/AndroidRuntime(276): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.locator.demo/com.locator.demo.LocatorDemoActivity}: java.lang.ClassCastException: android.widget.TextView
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.os.Handler.dispatchMessage(Handler.java:99)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.os.Looper.loop(Looper.java:123)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-21 15:30:23.427: E/AndroidRuntime(276): at java.lang.reflect.Method.invokeNative(Native Method)
04-21 15:30:23.427: E/AndroidRuntime(276): at java.lang.reflect.Method.invoke(Method.java:521)
04-21 15:30:23.427: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-21 15:30:23.427: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-21 15:30:23.427: E/AndroidRuntime(276): at dalvik.system.NativeStart.main(Native Method)
04-21 15:30:23.427: E/AndroidRuntime(276): Caused by: java.lang.ClassCastException: android.widget.TextView
04-21 15:30:23.427: E/AndroidRuntime(276): at com.locator.demo.LocatorDemoActivity.onCreate(LocatorDemoActivity.java:21)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-21 15:30:23.427: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-21 15:30:23.427: E/AndroidRuntime(276): ... 11 more
04-21 15:35:23.607: I/Process(276): Sending signal. PID: 276 SIG: 9
04-21 15:50:32.127: D/AndroidRuntime(301): Shutting down VM
04-21 15:50:32.127: W/dalvikvm(301): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-21 15:50:32.147: E/AndroidRuntime(301): FATAL EXCEPTION: main
04-21 15:50:32.147: E/AndroidRuntime(301): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.locator.demo/com.locator.demo.LocatorDemoActivity}: java.lang.ClassCastException: android.widget.TextView
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.os.Handler.dispatchMessage(Handler.java:99)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.os.Looper.loop(Looper.java:123)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-21 15:50:32.147: E/AndroidRuntime(301): at java.lang.reflect.Method.invokeNative(Native Method)
04-21 15:50:32.147: E/AndroidRuntime(301): at java.lang.reflect.Method.invoke(Method.java:521)
04-21 15:50:32.147: E/AndroidRuntime(301): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-21 15:50:32.147: E/AndroidRuntime(301): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-21 15:50:32.147: E/AndroidRuntime(301): at dalvik.system.NativeStart.main(Native Method)
04-21 15:50:32.147: E/AndroidRuntime(301): Caused by: java.lang.ClassCastException: android.widget.TextView
04-21 15:50:32.147: E/AndroidRuntime(301): at com.locator.demo.LocatorDemoActivity.onCreate(LocatorDemoActivity.java:21)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-21 15:50:32.147: E/AndroidRuntime(301): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-21 15:50:32.147: E/AndroidRuntime(301): ... 11 more
CODE:
package com.locator.demo;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class LocatorDemoActivity extends Activity implements OnClickListener {
EditText editStatus;
Button buttonUpdate;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.locationstatus);
editStatus = (EditText)findViewById(R.id.edit_status);
buttonUpdate = (Button)findViewById(R.id.button_update);
buttonUpdate.setOnClickListener(this);
//have button 'listen' for click
}
public void onClick(View arg0) {
// TODO Auto-generated method stub
}
}
ANDROID Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.locator.demo"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_main" >
<activity
android:name=".LocatorDemoActivity"
android:label="#string/app_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I have;
attempted to do adb kill-server and adb start-server and run it with an without an emulator as suggested in another post. Please be slightly understanding as my knowledge of eclipse and Java is pretty low and im learning.
Please help
As seen from this error:
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.locator.demo/com.locator.demo.LocatorDemoActivity}:
java.lang.ClassCastException: android.widget.TextView
And this one:
Caused by: java.lang.ClassCastException: android.widget.TextView
You are trying to cast a TextView to EditText ( in this line: editStatus = (EditText)findViewById(R.id.edit_status);).
Go to locationstatus.xml, and change the TextView with the id edit_status to EditText.
When I run my android application it gives an error "The application has stopped working,please try again". Please help me to solve this problem. i have created a method which gets called when the button gets clicked. When I include the code for calling another class in this method it shows the above error & when I remove that code it neither shows the error nor goes ahead when listview etc. gets clicked. Can you please check my code and help me please.
CODE:
public void myClickHandler(View view)
{
//Toast.makeText(this, "yesss",Toast.LENGTH_LONG).show();
setContentView(R.layout.screen1);
ListAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, city);
ListView FirstProjectActivity = (ListView) findViewById(R.id.mylist1);
FirstProjectActivity.setAdapter(adapter);
Intent myIntent = new Intent(FirstProjectActivity.this,
City.class);
FirstProjectActivity.this.startActivity(myIntent);
//startActivity(new Intent(FirstProjectActivity.this, City.class));
}
LOGCAT is as follows:
03-02 18:56:28.136: D/AndroidRuntime(316): Shutting down VM
03-02 18:56:28.136: W/dalvikvm(316): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-02 18:56:28.226: E/AndroidRuntime(316): FATAL EXCEPTION: main
03-02 18:56:28.226: E/AndroidRuntime(316): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.FirstProject/com.example.FirstProject.FirstProjectActivity}: java.lang.NullPointerException
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.os.Handler.dispatchMessage(Handler.java:99)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.os.Looper.loop(Looper.java:123)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-02 18:56:28.226: E/AndroidRuntime(316): at java.lang.reflect.Method.invokeNative(Native Method)
03-02 18:56:28.226: E/AndroidRuntime(316): at java.lang.reflect.Method.invoke(Method.java:521)
03-02 18:56:28.226: E/AndroidRuntime(316): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-02 18:56:28.226: E/AndroidRuntime(316): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-02 18:56:28.226: E/AndroidRuntime(316): at dalvik.system.NativeStart.main(Native Method)
03-02 18:56:28.226: E/AndroidRuntime(316): Caused by: java.lang.NullPointerException
03-02 18:56:28.226: E/AndroidRuntime(316): at com.example.FirstProject.FirstProjectActivity.onCreate(FirstProjectActivity.java:37)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-02 18:56:28.226: E/AndroidRuntime(316): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-02 18:56:28.226: E/AndroidRuntime(316): ... 11 more
03-02 18:56:35.396: I/Process(316): Sending signal. PID: 316 SIG: 9
03-02 19:02:51.836: D/AndroidRuntime(351): Shutting down VM
03-02 19:02:51.836: W/dalvikvm(351): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-02 19:02:51.866: E/AndroidRuntime(351): FATAL EXCEPTION: main
03-02 19:02:51.866: E/AndroidRuntime(351): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.FirstProject/com.example.FirstProject.FirstProjectActivity}: java.lang.NullPointerException
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.os.Handler.dispatchMessage(Handler.java:99)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.os.Looper.loop(Looper.java:123)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-02 19:02:51.866: E/AndroidRuntime(351): at java.lang.reflect.Method.invokeNative(Native Method)
03-02 19:02:51.866: E/AndroidRuntime(351): at java.lang.reflect.Method.invoke(Method.java:521)
03-02 19:02:51.866: E/AndroidRuntime(351): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-02 19:02:51.866: E/AndroidRuntime(351): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-02 19:02:51.866: E/AndroidRuntime(351): at dalvik.system.NativeStart.main(Native Method)
03-02 19:02:51.866: E/AndroidRuntime(351): Caused by: java.lang.NullPointerException
03-02 19:02:51.866: E/AndroidRuntime(351): at com.example.FirstProject.FirstProjectActivity.onCreate(FirstProjectActivity.java:37)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-02 19:02:51.866: E/AndroidRuntime(351): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-02 19:02:51.866: E/AndroidRuntime(351): ... 11 more
03-02 19:03:03.647: I/Process(351): Sending signal. PID: 351 SIG: 9
03-02 20:11:17.722: W/KeyCharacterMap(379): No keyboard for id 0
03-02 20:11:17.926: W/KeyCharacterMap(379): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
03-02 20:11:28.441: D/dalvikvm(379): GC_EXPLICIT freed 3121 objects / 172672 bytes in 1696ms
03-03 01:03:02.696: W/KeyCharacterMap(406): No keyboard for id 0
03-03 01:03:02.696: W/KeyCharacterMap(406): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
03-03 01:03:08.566: D/dalvikvm(406): GC_EXPLICIT freed 2874 objects / 162408 bytes in 192ms
03-03 01:33:06.566: D/AndroidRuntime(432): Shutting down VM
03-03 01:33:06.566: W/dalvikvm(432): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-03 01:33:06.726: E/AndroidRuntime(432): FATAL EXCEPTION: main
03-03 01:33:06.726: E/AndroidRuntime(432): java.lang.IllegalStateException: Could not execute method of the activity
03-03 01:33:06.726: E/AndroidRuntime(432): at android.view.View$1.onClick(View.java:2072)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.view.View.performClick(View.java:2408)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.view.View$PerformClick.run(View.java:8816)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.os.Handler.handleCallback(Handler.java:587)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.os.Handler.dispatchMessage(Handler.java:92)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.os.Looper.loop(Looper.java:123)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-03 01:33:06.726: E/AndroidRuntime(432): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:33:06.726: E/AndroidRuntime(432): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:33:06.726: E/AndroidRuntime(432): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-03 01:33:06.726: E/AndroidRuntime(432): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-03 01:33:06.726: E/AndroidRuntime(432): at dalvik.system.NativeStart.main(Native Method)
03-03 01:33:06.726: E/AndroidRuntime(432): Caused by: java.lang.reflect.InvocationTargetException
03-03 01:33:06.726: E/AndroidRuntime(432): at com.example.FirstProject.FirstProjectActivity.myClickHandler(FirstProjectActivity.java:69)
03-03 01:33:06.726: E/AndroidRuntime(432): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:33:06.726: E/AndroidRuntime(432): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.view.View$1.onClick(View.java:2067)
03-03 01:33:06.726: E/AndroidRuntime(432): ... 11 more
03-03 01:33:06.726: E/AndroidRuntime(432): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.FirstProject/com.example.FirstProject.City}; have you declared this activity in your AndroidManifest.xml?
03-03 01:33:06.726: E/AndroidRuntime(432): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.app.Activity.startActivityForResult(Activity.java:2817)
03-03 01:33:06.726: E/AndroidRuntime(432): at android.app.Activity.startActivity(Activity.java:2923)
03-03 01:33:06.726: E/AndroidRuntime(432): ... 15 more
03-03 01:33:08.956: I/Process(432): Sending signal. PID: 432 SIG: 9
03-03 01:34:05.387: D/AndroidRuntime(460): Shutting down VM
03-03 01:34:05.387: W/dalvikvm(460): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-03 01:34:05.417: E/AndroidRuntime(460): FATAL EXCEPTION: main
03-03 01:34:05.417: E/AndroidRuntime(460): java.lang.IllegalStateException: Could not execute method of the activity
03-03 01:34:05.417: E/AndroidRuntime(460): at android.view.View$1.onClick(View.java:2072)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.view.View.performClick(View.java:2408)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.view.View$PerformClick.run(View.java:8816)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.os.Handler.handleCallback(Handler.java:587)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.os.Handler.dispatchMessage(Handler.java:92)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.os.Looper.loop(Looper.java:123)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-03 01:34:05.417: E/AndroidRuntime(460): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:34:05.417: E/AndroidRuntime(460): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:34:05.417: E/AndroidRuntime(460): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-03 01:34:05.417: E/AndroidRuntime(460): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-03 01:34:05.417: E/AndroidRuntime(460): at dalvik.system.NativeStart.main(Native Method)
03-03 01:34:05.417: E/AndroidRuntime(460): Caused by: java.lang.reflect.InvocationTargetException
03-03 01:34:05.417: E/AndroidRuntime(460): at com.example.FirstProject.FirstProjectActivity.myClickHandler(FirstProjectActivity.java:70)
03-03 01:34:05.417: E/AndroidRuntime(460): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:34:05.417: E/AndroidRuntime(460): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.view.View$1.onClick(View.java:2067)
03-03 01:34:05.417: E/AndroidRuntime(460): ... 11 more
03-03 01:34:05.417: E/AndroidRuntime(460): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.FirstProject/com.example.FirstProject.City}; have you declared this activity in your AndroidManifest.xml?
03-03 01:34:05.417: E/AndroidRuntime(460): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.app.Activity.startActivityForResult(Activity.java:2817)
03-03 01:34:05.417: E/AndroidRuntime(460): at android.app.Activity.startActivity(Activity.java:2923)
03-03 01:34:05.417: E/AndroidRuntime(460): ... 15 more
03-03 01:34:11.016: I/Process(460): Sending signal. PID: 460 SIG: 9
03-03 01:35:33.547: D/AndroidRuntime(490): Shutting down VM
03-03 01:35:33.557: W/dalvikvm(490): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-03 01:35:33.577: E/AndroidRuntime(490): FATAL EXCEPTION: main
03-03 01:35:33.577: E/AndroidRuntime(490): java.lang.IllegalStateException: Could not execute method of the activity
03-03 01:35:33.577: E/AndroidRuntime(490): at android.view.View$1.onClick(View.java:2072)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.view.View.performClick(View.java:2408)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.view.View$PerformClick.run(View.java:8816)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.os.Handler.handleCallback(Handler.java:587)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.os.Handler.dispatchMessage(Handler.java:92)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.os.Looper.loop(Looper.java:123)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-03 01:35:33.577: E/AndroidRuntime(490): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:35:33.577: E/AndroidRuntime(490): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:35:33.577: E/AndroidRuntime(490): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-03 01:35:33.577: E/AndroidRuntime(490): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-03 01:35:33.577: E/AndroidRuntime(490): at dalvik.system.NativeStart.main(Native Method)
03-03 01:35:33.577: E/AndroidRuntime(490): Caused by: java.lang.reflect.InvocationTargetException
03-03 01:35:33.577: E/AndroidRuntime(490): at com.example.FirstProject.FirstProjectActivity.myClickHandler(FirstProjectActivity.java:70)
03-03 01:35:33.577: E/AndroidRuntime(490): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:35:33.577: E/AndroidRuntime(490): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.view.View$1.onClick(View.java:2067)
03-03 01:35:33.577: E/AndroidRuntime(490): ... 11 more
03-03 01:35:33.577: E/AndroidRuntime(490): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.FirstProject/com.example.FirstProject.City}; have you declared this activity in your AndroidManifest.xml?
03-03 01:35:33.577: E/AndroidRuntime(490): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.app.Activity.startActivityForResult(Activity.java:2817)
03-03 01:35:33.577: E/AndroidRuntime(490): at android.app.Activity.startActivity(Activity.java:2923)
03-03 01:35:33.577: E/AndroidRuntime(490): ... 15 more
03-03 01:35:39.176: I/Process(490): Sending signal. PID: 490 SIG: 9
03-03 01:36:06.947: D/AndroidRuntime(517): Shutting down VM
03-03 01:36:06.947: W/dalvikvm(517): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-03 01:36:06.967: E/AndroidRuntime(517): FATAL EXCEPTION: main
03-03 01:36:06.967: E/AndroidRuntime(517): java.lang.IllegalStateException: Could not execute method of the activity
03-03 01:36:06.967: E/AndroidRuntime(517): at android.view.View$1.onClick(View.java:2072)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.view.View.performClick(View.java:2408)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.view.View$PerformClick.run(View.java:8816)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.os.Handler.handleCallback(Handler.java:587)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.os.Handler.dispatchMessage(Handler.java:92)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.os.Looper.loop(Looper.java:123)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-03 01:36:06.967: E/AndroidRuntime(517): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:36:06.967: E/AndroidRuntime(517): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:36:06.967: E/AndroidRuntime(517): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-03 01:36:06.967: E/AndroidRuntime(517): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-03 01:36:06.967: E/AndroidRuntime(517): at dalvik.system.NativeStart.main(Native Method)
03-03 01:36:06.967: E/AndroidRuntime(517): Caused by: java.lang.reflect.InvocationTargetException
03-03 01:36:06.967: E/AndroidRuntime(517): at com.example.FirstProject.FirstProjectActivity.myClickHandler(FirstProjectActivity.java:70)
03-03 01:36:06.967: E/AndroidRuntime(517): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 01:36:06.967: E/AndroidRuntime(517): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.view.View$1.onClick(View.java:2067)
03-03 01:36:06.967: E/AndroidRuntime(517): ... 11 more
03-03 01:36:06.967: E/AndroidRuntime(517): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.FirstProject/com.example.FirstProject.City}; have you declared this activity in your AndroidManifest.xml?
03-03 01:36:06.967: E/AndroidRuntime(517): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.app.Activity.startActivityForResult(Activity.java:2817)
03-03 01:36:06.967: E/AndroidRuntime(517): at android.app.Activity.startActivity(Activity.java:2923)
03-03 01:36:06.967: E/AndroidRuntime(517): ... 15 more
03-03 01:36:13.306: I/Process(517): Sending signal. PID: 517 SIG: 9
When you want to detect if you click on an item you need to implement the onItemClickedListener i will give you an example below like i would do it:
listView.setOnItemClickListener(new MyOnitemClickListener());
//no i make my own class that impelemnts the onitemclicklistener
public class MyOnitemClickListener implements OnItemClickListener {
private int position = 0;
public void onItemClick(AdapterView<?> parent, View view, int pos,
long lat) {
// clicked on parent.getid()
if (parent.getId() == R.id.listView) {
//do something
}
}
}
after a crash, try looking for the first couple of red lines the LOGCAT spews to you as they usually explain what happened.
the following line :
java.lang.NullPointerException
(in line 5) showed up on you log, it usually means your trying to use an uninitialized object.
refer to:
What is a NullPointerException, and how do I fix it?
Here is my code to display the google map in my android emulator using google AVD....
How to fix this problem?anybody can know this?
Map.java:
public class MapsActivity extends MapActivity
{
private MapView mapView;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.mapView);
mapView.setBuiltInZoomControls(true);
}
#Override
protected boolean isRouteDisplayed() {
return false;
}
Xml File:
<com.google.android.maps.MapView
android:id="#+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="0l4sCTTyRmXTNo7k8DREHvEaLar2UmHGwnhZVHQ"
>
</com.google.android.maps.MapView>
Manifost File:
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-library android:name="com.google.android.maps" />
Output:
In my emulator map activity has stopped unexpexctly..
i got the runtime exception
01-04 10:36:24.540: D/dalvikvm(641): Not late-enabling CheckJNI (already on)
01-04 10:36:25.290: W/dalvikvm(641): Unable to resolve superclass of Lcom/example/MapsActivity; (10)
01-04 10:36:25.290: W/dalvikvm(641): Link of class 'Lcom/example/MapsActivity;' failed
01-04 10:36:25.290: D/AndroidRuntime(641): Shutting down VM
01-04 10:36:25.290: W/dalvikvm(641): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
01-04 10:36:25.430: E/AndroidRuntime(641): FATAL EXCEPTION: main
01-04 10:36:25.430: E/AndroidRuntime(641): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example/com.example.MapsActivity}: java.lang.ClassNotFoundException: com.example.MapsActivity
01-04 10:36:25.430: E/AndroidRuntime(641): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
01-04 10:36:25.430: E/AndroidRuntime(641): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
01-04 10:36:25.430: E/AndroidRuntime(641): at android.app.ActivityThread.access$600(ActivityThread.java:123)
01-04 10:36:25.430: E/AndroidRuntime(641): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
01-04 10:36:25.430: E/AndroidRuntime(641): at android.os.Handler.dispatchMessage(Handler.java:99)
01-04 10:36:25.430: E/AndroidRuntime(641): at android.os.Looper.loop(Looper.java:137)
01-04 10:36:25.430: E/AndroidRuntime(641): at android.app.ActivityThread.main(ActivityThread.java:4424)
01-04 10:36:25.430: E/AndroidRuntime(641): at java.lang.reflect.Method.invokeNative(Native Method)
01-04 10:36:25.430: E/AndroidRuntime(641): at java.lang.reflect.Method.invoke(Method.java:511)
01-04 10:36:25.430: E/AndroidRuntime(641): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-04 10:36:25.430: E/AndroidRuntime(641): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-04 10:36:25.430: E/AndroidRuntime(641): at dalvik.system.NativeStart.main(Native Method)
01-04 10:36:25.430: E/AndroidRuntime(641): Caused by: java.lang.ClassNotFoundException: com.example.MapsActivity
01-04 10:36:25.430: E/AndroidRuntime(641): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
01-04 10:36:25.430: E/AndroidRuntime(641): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
01-04 10:36:25.430: E/AndroidRuntime(641): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
01-04 10:36:25.430: E/AndroidRuntime(641): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
01-04 10:36:25.430: E/AndroidRuntime(641): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
01-04 10:36:25.430: E/AndroidRuntime(641): ... 11 more
01-04 10:36:31.140: W/dalvikvm(679): Unable to resolve superclass of Lcom/example/MapsActivity; (10)
01-04 10:36:31.160: W/dalvikvm(679): Link of class 'Lcom/example/MapsActivity;' failed
01-04 10:36:31.160: D/AndroidRuntime(679): Shutting down VM
01-04 10:36:31.180: W/dalvikvm(679): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
01-04 10:36:31.240: E/AndroidRuntime(679): FATAL EXCEPTION: main
01-04 10:36:31.240: E/AndroidRuntime(679): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example/com.example.MapsActivity}: java.lang.ClassNotFoundException: com.example.MapsActivity
01-04 10:36:31.240: E/AndroidRuntime(679): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
01-04 10:36:31.240: E/AndroidRuntime(679): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
01-04 10:36:31.240: E/AndroidRuntime(679): at android.app.ActivityThread.access$600(ActivityThread.java:123)
01-04 10:36:31.240: E/AndroidRuntime(679): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
01-04 10:36:31.240: E/AndroidRuntime(679): at android.os.Handler.dispatchMessage(Handler.java:99)
01-04 10:36:31.240: E/AndroidRuntime(679): at android.os.Looper.loop(Looper.java:137)
01-04 10:36:31.240: E/AndroidRuntime(679): at android.app.ActivityThread.main(ActivityThread.java:4424)
01-04 10:36:31.240: E/AndroidRuntime(679): at java.lang.reflect.Method.invokeNative(Native Method)
01-04 10:36:31.240: E/AndroidRuntime(679): at java.lang.reflect.Method.invoke(Method.java:511)
01-04 10:36:31.240: E/AndroidRuntime(679): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-04 10:36:31.240: E/AndroidRuntime(679): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-04 10:36:31.240: E/AndroidRuntime(679): at dalvik.system.NativeStart.main(Native Method)
01-04 10:36:31.240: E/AndroidRuntime(679): Caused by: java.lang.ClassNotFoundException: com.example.MapsActivity
01-04 10:36:31.240: E/AndroidRuntime(679): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
01-04 10:36:31.240: E/AndroidRuntime(679): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
01-04 10:36:31.240: E/AndroidRuntime(679): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
01-04 10:36:31.240: E/AndroidRuntime(679): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
01-04 10:36:31.240: E/AndroidRuntime(679): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
01-04 10:36:31.240: E/AndroidRuntime(679): ... 11 more
01-04 10:37:23.619: W/dalvikvm(720): Unable to resolve superclass of Lcom/example/MapsActivity; (10)
01-04 10:37:23.659: W/dalvikvm(720): Link of class 'Lcom/example/MapsActivity;' failed
01-04 10:37:23.659: D/AndroidRuntime(720): Shutting down VM
01-04 10:37:23.669: W/dalvikvm(720): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
01-04 10:37:23.699: E/AndroidRuntime(720): FATAL EXCEPTION: main
01-04 10:37:23.699: E/AndroidRuntime(720): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example/com.example.MapsActivity}: java.lang.ClassNotFoundException: com.example.MapsActivity
01-04 10:37:23.699: E/AndroidRuntime(720): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
01-04 10:37:23.699: E/AndroidRuntime(720): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
01-04 10:37:23.699: E/AndroidRuntime(720): at android.app.ActivityThread.access$600(ActivityThread.java:123)
01-04 10:37:23.699: E/AndroidRuntime(720): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
01-04 10:37:23.699: E/AndroidRuntime(720): at android.os.Handler.dispatchMessage(Handler.java:99)
01-04 10:37:23.699: E/AndroidRuntime(720): at android.os.Looper.loop(Looper.java:137)
01-04 10:37:23.699: E/AndroidRuntime(720): at android.app.ActivityThread.main(ActivityThread.java:4424)
01-04 10:37:23.699: E/AndroidRuntime(720): at java.lang.reflect.Method.invokeNative(Native Method)
01-04 10:37:23.699: E/AndroidRuntime(720): at java.lang.reflect.Method.invoke(Method.java:511)
01-04 10:37:23.699: E/AndroidRuntime(720): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-04 10:37:23.699: E/AndroidRuntime(720): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-04 10:37:23.699: E/AndroidRuntime(720): at dalvik.system.NativeStart.main(Native Method)
01-04 10:37:23.699: E/AndroidRuntime(720): Caused by: java.lang.ClassNotFoundException: com.example.MapsActivity
01-04 10:37:23.699: E/AndroidRuntime(720): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
01-04 10:37:23.699: E/AndroidRuntime(720): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
01-04 10:37:23.699: E/AndroidRuntime(720): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
01-04 10:37:23.699: E/AndroidRuntime(720): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
01-04 10:37:23.699: E/AndroidRuntime(720): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
01-04 10:37:23.699: E/AndroidRuntime(720): ... 11 more
Output screen:
google map view screen shot
I think problem with your API key only. Any how check the link below you will get an idea.
Displaying Google maps in Android Emulator
I found one thing in your manifest, you written
<uses-library android:name="com.google.android.maps" />
after </application> i think it may wrong
In manifest file write as below and try once
<application
<uses-library android:name="com.google.android.maps" />
New Answer
Please check this link, it may help you.
Enable internet for Android Emulator
Your mentioned code is right But i have two doubt is that
1. Google MAP API
Ans .To get Google MAP API Here
2. Check Emulator's Internet.
Ans . Open CMD
D:\SOFTWARE\Android-SDK\android-sdk-2.2>emulator -avd avdname -dns-server 8.8.8.8
add google maps library in your manifest and it should work
Move :
<uses-library android:name="com.google.android.maps" />
within the application tag. You have written outside the application tag in manifest file.
For your second problem:
I am sure you have copied the map key from some where else. This is causing only blank screen on emulator. Try to generate your own Map Key following:
http://code.google.com/android/add-ons/google-apis/mapkey.html
the error class not found exception is when actitvity is not declared in manifest
if you have declared it and then also error comes please please check you may have
included a jar file twice in your project