While retriveing Data from data base shows NUll POINTER EXCEPTION - android

Since , I am new in android world so , please help me. When i am working with Android SQLite for retrieving data from data-base by these codes-
Cursor cursor;
DatabaseConnector dbConnector = new DatabaseConnector(this);
private ListAdapter conAdapter;
String[] from_for_text_in_list = {"name"};
int[] to_for_text_in_list = {R.id.title_info_txt_v}
cursor = dbConnector.getAllContacts();
conAdapter = new SimpleCursorAdapter(Infoclass.this, R.layout.listview_layout, null, from_for_text_in_list, to_for_text_in_list);
setListAdapter(conAdapter);
Now i declare getAllmethod() as-
public Cursor getAllContacts()
{
return database.rawQuery("SELECT _id, name FROM tcc_info_table ", new String[]{"_id", "name"});
}
"name" is just a column name of database in my App.
While I am running my App it shows NULL POINTER Exception in getAllContact() method . Even i check my database through SQLite Browser and i found that data insertion going on successfully . But data not retrieve from database to list view . My logCat error is as below-
11-14 12:01:21.694: E/Trace(30607): error opening trace file: No such file or directory (2)
11-14 12:01:22.475: D/AndroidRuntime(30607): Shutting down VM
11-14 12:01:22.475: W/dalvikvm(30607): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
11-14 12:01:22.495: E/AndroidRuntime(30607): FATAL EXCEPTION: main
11-14 12:01:22.495: E/AndroidRuntime(30607): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kt.narendramodi/com.kt.narendramodi.ModiForIndia}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kt.narendramodi/com.kt.narendramodi.InfoNarendraModi}: java.lang.IllegalArgumentException: Cannot bind argument at index 2 because the index is out of range. The statement has 0 parameters.
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.ActivityThread.access$600(ActivityThread.java:130)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.os.Looper.loop(Looper.java:137)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.ActivityThread.main(ActivityThread.java:4745)
11-14 12:01:22.495: E/AndroidRuntime(30607): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 12:01:22.495: E/AndroidRuntime(30607): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 12:01:22.495: E/AndroidRuntime(30607): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-14 12:01:22.495: E/AndroidRuntime(30607): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-14 12:01:22.495: E/AndroidRuntime(30607): at dalvik.system.NativeStart.main(Native Method)
11-14 12:01:22.495: E/AndroidRuntime(30607): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kt.narendramodi/com.kt.narendramodi.InfoNarendraModi}: java.lang.IllegalArgumentException: Cannot bind argument at index 2 because the index is out of range. The statement has 0 parameters.
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.ActivityThread.startActivityNow(ActivityThread.java:1900)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:135)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:347)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:694)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.widget.TabHost.setCurrentTab(TabHost.java:358)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.widget.TabHost.addTab(TabHost.java:236)
11-14 12:01:22.495: E/AndroidRuntime(30607): at com.kt.narendramodi.ModiForIndia.onCreate(ModiForIndia.java:41)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.Activity.performCreate(Activity.java:5008)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
11-14 12:01:22.495: E/AndroidRuntime(30607): ... 11 more
11-14 12:01:22.495: E/AndroidRuntime(30607): Caused by: java.lang.IllegalArgumentException: Cannot bind argument at index 2 because the index is out of range. The statement has 0 parameters.
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.database.sqlite.SQLiteProgram.bind(SQLiteProgram.java:212)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.database.sqlite.SQLiteProgram.bindString(SQLiteProgram.java:166)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.database.sqlite.SQLiteProgram.bindAllArgsAsStrings(SQLiteProgram.java:200)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:47)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1253)
11-14 12:01:22.495: E/AndroidRuntime(30607): at com.kt.nanrendramodi.databasehelper.DatabaseConnector.getAllContacts(DatabaseConnector.java:60)
11-14 12:01:22.495: E/AndroidRuntime(30607): at com.kt.narendramodi.InfoNarendraModi.onCreate(InfoNarendraModi.java:94)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.Activity.performCreate(Activity.java:5008)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
11-14 12:01:22.495: E/AndroidRuntime(30607): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
11-14 12:01:22.495: E/AndroidRuntime(30607): ... 21 more

You'll have to check 2 things:
Your database should be initialized to a read/write-able database.
database = yourDbHelper.getReadableDatabase();
You don't need those selection arguments if you've filled the SQL query fully.
database.rawQuery("SELECT _id, name FROM tcc_info_table ", null);

Related

AVD crashes saying 'Unfortunately, libcocos2dx has crashed'

I just loaded my app created by cocos2dx-3.10 and when I open with it an AVD (again I haven't done any modifications to the app) the app crashes and gives the error: Unfortunately, libcocos2dx has crashed.
here is what I get in my android Monitor:
03-05 18:34:56.668 1435-1435/? D/dalvikvm: Not late-enabling CheckJNI (already on)
03-05 18:34:56.989 1435-1435/com.trying.name E/Trace: error opening trace file: No such file or directory (2)
03-05 18:34:57.419 1435-1435/com.trying.name D/AndroidRuntime: Shutting down VM
03-05 18:34:57.419 1435-1435/com.trying.name W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xb2f2b288)
03-05 18:34:57.518 1435-1435/com.trying.name E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.UnsatisfiedLinkError: Couldn't load cocos2dcpp: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:535)
at org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries(Cocos2dxActivity.java:248)
at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:263)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
03-05 18:35:11.559 1435-1435/? I/Process: Sending signal. PID: 1435 SIG: 9

Could not find appcompat_v7.apk and android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)

i have problem. when run and i debug program i have
[2014-11-14 03:57:23 - Traffic] Android Launch!
[2014-11-14 03:57:23 - Traffic] adb is running normally.
[2014-11-14 03:57:23 - Traffic] Performing com.fuad.traffic.MainActivity activity launch
[2014-11-14 03:57:26 - Traffic] Uploading Traffic.apk onto device 'YT910DUTNU'
[2014-11-14 03:57:26 - Traffic] Installing Traffic.apk...
[2014-11-14 03:57:33 - Traffic] Success!
[2014-11-14 03:57:33 - appcompat_v7] Could not find appcompat_v7.apk!
[2014-11-14 03:57:33 - Traffic] Starting activity com.fuad.traffic.MainActivity on device YT910DUTNU
that is my problem, and when i running in phone this i have problem again like this my problem
11-14 19:10:02.090: W/dalvikvm(28725): Unable to resolve superclass of Lcom/fuad/traffic/MainActivity; (83)
11-14 19:10:02.090: W/dalvikvm(28725): Link of class 'Lcom/fuad/traffic/MainActivity;' failed
11-14 19:10:02.090: W/dalvikvm(28725): threadid=1: thread exiting with uncaught exception (group=0x40b019f0)
11-14 19:10:02.100: E/AndroidRuntime(28725): FATAL EXCEPTION: main
11-14 19:10:02.100: E/AndroidRuntime(28725): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.fuad.traffic/com.fuad.traffic.MainActivity}: java.lang.ClassNotFoundException: com.fuad.traffic.MainActivity
11-14 19:10:02.100: E/AndroidRuntime(28725): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
11-14 19:10:02.100: E/AndroidRuntime(28725): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
11-14 19:10:02.100: E/AndroidRuntime(28725): at android.app.ActivityThread.access$600(ActivityThread.java:123)
11-14 19:10:02.100: E/AndroidRuntime(28725): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
11-14 19:10:02.100: E/AndroidRuntime(28725): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 19:10:02.100: E/AndroidRuntime(28725): at android.os.Looper.loop(Looper.java:137)
11-14 19:10:02.100: E/AndroidRuntime(28725): at android.app.ActivityThread.main(ActivityThread.java:4424)
11-14 19:10:02.100: E/AndroidRuntime(28725): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 19:10:02.100: E/AndroidRuntime(28725): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 19:10:02.100: E/AndroidRuntime(28725): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
11-14 19:10:02.100: E/AndroidRuntime(28725): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
11-14 19:10:02.100: E/AndroidRuntime(28725): at dalvik.system.NativeStart.main(Native Method)
11-14 19:10:02.100: E/AndroidRuntime(28725): Caused by: java.lang.ClassNotFoundException: com.fuad.traffic.MainActivity
11-14 19:10:02.100: E/AndroidRuntime(28725): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
11-14 19:10:02.100: E/AndroidRuntime(28725): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
11-14 19:10:02.100: E/AndroidRuntime(28725): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
11-14 19:10:02.100: E/AndroidRuntime(28725): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
11-14 19:10:02.100: E/AndroidRuntime(28725): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
11-14 19:10:02.100: E/AndroidRuntime(28725): ... 11 more
thanx for master in stackoverflow.com :D
after importing appcompat_v7 check its properties android section and be sure that Is Library is checked! and then add appcompat_v7 project to your project in your project > properties > android and then clean and rebuild your project!
Try:
Right Click on Package Explorer
Import
Android > Existing Android Code into Workspace > Next
Browse > ~/sdk/extras/android/support/v7/appcompat
Select the package. Checkbox "Copy projects into workspace" > Finish
Right Click in YOUR PROJECT > Properties > Android
In the section of Library > Add > appcompat > OK
Finally go to Project (in the menu of eclipse) > Clean ..
Tell us if you tried something and what happened
for #mohammad, i have found the problem, in properties>java build path>project, the problem is there are have folder appcompat. and it's must delete. and when i delete it it's work. but the next problem when i run the program is like this
'11-14 19:24:44.379: W/dalvikvm(29518): VFY: unable to resolve virtual method 292: Landroid/app/Notification$Builder;.setPriority (I)Landroid/app/Notification$Builder;
11-14 19:24:44.379: W/dalvikvm(29518): threadid=1: thread exiting with uncaught exception (group=0x40b019f0)
11-14 19:24:44.389: E/AndroidRuntime(29518): FATAL EXCEPTION: main
11-14 19:24:44.389: E/AndroidRuntime(29518): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fuad.traffic/com.fuad.traffic.MainActivity}: android.view.InflateException: Binary XML file line #15: Error inflating class fragment
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.app.ActivityThread.access$600(ActivityThread.java:123)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.os.Looper.loop(Looper.java:137)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.app.ActivityThread.main(ActivityThread.java:4424)
11-14 19:24:44.389: E/AndroidRuntime(29518): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 19:24:44.389: E/AndroidRuntime(29518): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
11-14 19:24:44.389: E/AndroidRuntime(29518): at dalvik.system.NativeStart.main(Native Method)
11-14 19:24:44.389: E/AndroidRuntime(29518): Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class fragment
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:268)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.app.Activity.setContentView(Activity.java:1837)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.fuad.traffic.MainActivity.onCreate(MainActivity.java:15)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.app.Activity.performCreate(Activity.java:4470)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
11-14 19:24:44.389: E/AndroidRuntime(29518): ... 11 more
11-14 19:24:44.389: E/AndroidRuntime(29518): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 6111000 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" />
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.google.android.gms.common.GooglePlayServicesUtil.E(Unknown Source)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.google.android.gms.maps.internal.u.S(Unknown Source)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.google.android.gms.maps.internal.u.R(Unknown Source)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.google.android.gms.maps.SupportMapFragment$b.my(Unknown Source)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.google.android.gms.dynamic.a.a(Unknown Source)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
11-14 19:24:44.389: E/AndroidRuntime(29518): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2158)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:297)
11-14 19:24:44.389: E/AndroidRuntime(29518): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
11-14 19:24:44.389: E/AndroidRuntime(29518): ... 21 more
'

EmPubLite app crashing on Tutorial #13

So, I am going through the Tutorial #12 and everything is working fine. I then try to go onto Tutorial #13 for Saving/Restoring Last-Read Position and the app crashes:
04-10 15:59:26.510: E/Trace(704): error opening trace file: No such file or directory (2)
04-10 15:59:27.491: D/AndroidRuntime(704): Shutting down VM
04-10 15:59:27.491: W/dalvikvm(704): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
04-10 15:59:27.500: E/AndroidRuntime(704): FATAL EXCEPTION: main
04-10 15:59:27.500: E/AndroidRuntime(704): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.commonsware.empublite/com.commonsware.empublite.EmPubLiteActivity}: java.lang.NullPointerException
04-10 15:59:27.500: E/AndroidRuntime(704): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.app.ActivityThread.access$600(ActivityThread.java:130)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.os.Handler.dispatchMessage(Handler.java:99)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.os.Looper.loop(Looper.java:137)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.app.ActivityThread.main(ActivityThread.java:4745)
04-10 15:59:27.500: E/AndroidRuntime(704): at java.lang.reflect.Method.invokeNative(Native Method)
04-10 15:59:27.500: E/AndroidRuntime(704): at java.lang.reflect.Method.invoke(Method.java:511)
04-10 15:59:27.500: E/AndroidRuntime(704): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
04-10 15:59:27.500: E/AndroidRuntime(704): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-10 15:59:27.500: E/AndroidRuntime(704): at dalvik.system.NativeStart.main(Native Method)
04-10 15:59:27.500: E/AndroidRuntime(704): Caused by: java.lang.NullPointerException
04-10 15:59:27.500: E/AndroidRuntime(704): at com.commonsware.empublite.ModelFragment.executeAsyncTask(ModelFragment.java:51)
04-10 15:59:27.500: E/AndroidRuntime(704): at com.commonsware.empublite.ModelFragment.deliverModel(ModelFragment.java:38)
04-10 15:59:27.500: E/AndroidRuntime(704): at com.commonsware.empublite.ModelFragment.onActivityCreated(ModelFragment.java:29)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:891)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1080)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:622)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:505)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.app.Activity.performStart(Activity.java:5018)
04-10 15:59:27.500: E/AndroidRuntime(704): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032)
04-10 15:59:27.500: E/AndroidRuntime(704): ... 11 more
I tried to comment out the code I did until the last point that it was working, but that didn't seem to work. I am not really sure how to read this stack trace either. What should I be looking at to fix this problem?
Thanks.
I am not really sure how to read this stack trace either. What should I be looking at to fix this problem?
Line 51 of ModelFragment.java, in the executeAsyncTask() method is where you are crashing (see last stack trace stanza, starting with Caused by: java.lang.NullPointerException).
Your line numbers and those in the answers are not completely lining up. However, the only way executeAsyncTask() could have a NullPointerException is if the AsyncTask you are passing in is null, and that should not be possible as you define those tasks immediately before calling executeAsyncTask() in the deliverModel() method. Perhaps you missed a line in deliverModel().

Android httpget does not work properly

I am having a problem executing an url via httpget in android.
try
{
DefaultHttpClient client = new DefaultHttpClient();
HttpGet getURL = new HttpGet("http://www.example.com/index.php?text=x");
client.execute(getURL);
Toast.makeText(this.getBaseContext(), "I'm here", Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(this.getBaseContext(), "Code Failed:" + e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
}
For some Reason my app wil show a Toeast with the message: "Code Failed: Null".
I just want to execute an URL. When the URL is called my php file will update a record in the database. I just want to update/insert databases in my mysql database. So parsing json/xml/other response is not necessary.
If I show my exceptions in the logcat, this is what I see:
11-14 13:56:39.255: E/MYAPP(19638): exception
11-14 13:56:39.255: E/MYAPP(19638): android.os.NetworkOnMainThreadException
11-14 13:56:39.255: E/MYAPP(19638): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118)
11-14 13:56:39.255: E/MYAPP(19638): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
11-14 13:56:39.255: E/MYAPP(19638): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
11-14 13:56:39.255: E/MYAPP(19638): at java.net.InetAddress.getAllByName(InetAddress.java:214)
11-14 13:56:39.255: E/MYAPP(19638): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
11-14 13:56:39.255: E/MYAPP(19638): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
11-14 13:56:39.255: E/MYAPP(19638): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
11-14 13:56:39.255: E/MYAPP(19638): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
11-14 13:56:39.255: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:670)
11-14 13:56:39.255: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:509)
11-14 13:56:39.255: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
11-14 13:56:39.255: E/MYAPP(19638): at com.thepl.shopapp.MainActivity.onCreate(MainActivity.java:156)
11-14 13:56:39.255: E/MYAPP(19638): at android.app.Activity.performCreate(Activity.java:5184)
11-14 13:56:39.255: E/MYAPP(19638): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
11-14 13:56:39.255: E/MYAPP(19638): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
11-14 13:56:39.255: E/MYAPP(19638): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
11-14 13:56:39.255: E/MYAPP(19638): at android.app.ActivityThread.access$600(ActivityThread.java:140)
11-14 13:56:39.255: E/MYAPP(19638): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
11-14 13:56:39.255: E/MYAPP(19638): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 13:56:39.255: E/MYAPP(19638): at android.os.Looper.loop(Looper.java:137)
11-14 13:56:39.255: E/MYAPP(19638): at android.app.ActivityThread.main(ActivityThread.java:4898)
11-14 13:56:39.255: E/MYAPP(19638): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 13:56:39.255: E/MYAPP(19638): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 13:56:39.255: E/MYAPP(19638): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
11-14 13:56:39.255: E/MYAPP(19638): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
11-14 13:56:39.255: E/MYAPP(19638): at dalvik.system.NativeStart.main(Native Method)
11-14 13:56:58.205: E/MYAPP(19638): exception
11-14 13:56:58.205: E/MYAPP(19638): android.os.NetworkOnMainThreadException
11-14 13:56:58.205: E/MYAPP(19638): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118)
11-14 13:56:58.205: E/MYAPP(19638): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
11-14 13:56:58.205: E/MYAPP(19638): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
11-14 13:56:58.205: E/MYAPP(19638): at java.net.InetAddress.getAllByName(InetAddress.java:214)
11-14 13:56:58.205: E/MYAPP(19638): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
11-14 13:56:58.205: E/MYAPP(19638): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
11-14 13:56:58.205: E/MYAPP(19638): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
11-14 13:56:58.205: E/MYAPP(19638): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
11-14 13:56:58.205: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:670)
11-14 13:56:58.205: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:509)
11-14 13:56:58.205: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
11-14 13:56:58.205: E/MYAPP(19638): at com.thepl.shopapp.MainActivity.onCreate(MainActivity.java:156)
11-14 13:56:58.205: E/MYAPP(19638): at android.app.Activity.performCreate(Activity.java:5184)
11-14 13:56:58.205: E/MYAPP(19638): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
11-14 13:56:58.205: E/MYAPP(19638): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
11-14 13:56:58.205: E/MYAPP(19638): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
11-14 13:56:58.205: E/MYAPP(19638): at android.app.ActivityThread.access$600(ActivityThread.java:140)
11-14 13:56:58.205: E/MYAPP(19638): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
11-14 13:56:58.205: E/MYAPP(19638): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 13:56:58.205: E/MYAPP(19638): at android.os.Looper.loop(Looper.java:137)
11-14 13:56:58.205: E/MYAPP(19638): at android.app.ActivityThread.main(ActivityThread.java:4898)
11-14 13:56:58.205: E/MYAPP(19638): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 13:56:58.205: E/MYAPP(19638): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 13:56:58.205: E/MYAPP(19638): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
11-14 13:56:58.205: E/MYAPP(19638): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
11-14 13:56:58.205: E/MYAPP(19638): at dalvik.system.NativeStart.main(Native Method)
11-14 13:56:59.100: E/MYAPP(19638): exception
11-14 13:56:59.100: E/MYAPP(19638): android.os.NetworkOnMainThreadException
11-14 13:56:59.100: E/MYAPP(19638): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118)
11-14 13:56:59.100: E/MYAPP(19638): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
11-14 13:56:59.100: E/MYAPP(19638): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
11-14 13:56:59.100: E/MYAPP(19638): at java.net.InetAddress.getAllByName(InetAddress.java:214)
11-14 13:56:59.100: E/MYAPP(19638): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
11-14 13:56:59.100: E/MYAPP(19638): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
11-14 13:56:59.100: E/MYAPP(19638): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
11-14 13:56:59.100: E/MYAPP(19638): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
11-14 13:56:59.100: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:670)
11-14 13:56:59.100: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:509)
11-14 13:56:59.100: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
11-14 13:56:59.100: E/MYAPP(19638): at com.thepl.shopapp.MainActivity.onCreate(MainActivity.java:156)
11-14 13:56:59.100: E/MYAPP(19638): at android.app.Activity.performCreate(Activity.java:5184)
11-14 13:56:59.100: E/MYAPP(19638): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
11-14 13:56:59.100: E/MYAPP(19638): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
11-14 13:56:59.100: E/MYAPP(19638): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
11-14 13:56:59.100: E/MYAPP(19638): at android.app.ActivityThread.access$600(ActivityThread.java:140)
11-14 13:56:59.100: E/MYAPP(19638): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
11-14 13:56:59.100: E/MYAPP(19638): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 13:56:59.100: E/MYAPP(19638): at android.os.Looper.loop(Looper.java:137)
11-14 13:56:59.100: E/MYAPP(19638): at android.app.ActivityThread.main(ActivityThread.java:4898)
11-14 13:56:59.100: E/MYAPP(19638): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 13:56:59.100: E/MYAPP(19638): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 13:56:59.100: E/MYAPP(19638): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
11-14 13:56:59.100: E/MYAPP(19638): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
11-14 13:56:59.100: E/MYAPP(19638): at dalvik.system.NativeStart.main(Native Method)
11-14 13:57:21.185: E/MYAPP(19638): exception
11-14 13:57:21.185: E/MYAPP(19638): android.os.NetworkOnMainThreadException
11-14 13:57:21.185: E/MYAPP(19638): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118)
11-14 13:57:21.185: E/MYAPP(19638): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
11-14 13:57:21.185: E/MYAPP(19638): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
11-14 13:57:21.185: E/MYAPP(19638): at java.net.InetAddress.getAllByName(InetAddress.java:214)
11-14 13:57:21.185: E/MYAPP(19638): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
11-14 13:57:21.185: E/MYAPP(19638): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
11-14 13:57:21.185: E/MYAPP(19638): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
11-14 13:57:21.185: E/MYAPP(19638): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
11-14 13:57:21.185: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:670)
11-14 13:57:21.185: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:509)
11-14 13:57:21.185: E/MYAPP(19638): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
11-14 13:57:21.185: E/MYAPP(19638): at com.thepl.shopapp.MainActivity.onCreate(MainActivity.java:156)
11-14 13:57:21.185: E/MYAPP(19638): at android.app.Activity.performCreate(Activity.java:5184)
11-14 13:57:21.185: E/MYAPP(19638): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
11-14 13:57:21.185: E/MYAPP(19638): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
11-14 13:57:21.185: E/MYAPP(19638): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
11-14 13:57:21.185: E/MYAPP(19638): at android.app.ActivityThread.access$600(ActivityThread.java:140)
11-14 13:57:21.185: E/MYAPP(19638): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
11-14 13:57:21.185: E/MYAPP(19638): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 13:57:21.185: E/MYAPP(19638): at android.os.Looper.loop(Looper.java:137)
11-14 13:57:21.185: E/MYAPP(19638): at android.app.ActivityThread.main(ActivityThread.java:4898)
11-14 13:57:21.185: E/MYAPP(19638): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 13:57:21.185: E/MYAPP(19638): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 13:57:21.185: E/MYAPP(19638): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
11-14 13:57:21.185: E/MYAPP(19638): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
11-14 13:57:21.185: E/MYAPP(19638): at dalvik.system.NativeStart.main(Native Method)
you should make network call on main UI thread. following is the definition of the exception:
The exception that is thrown when an application attempts to perform a
networking operation on its main thread.
This is only thrown for applications targeting the Honeycomb SDK or
higher. Applications targeting earlier SDK versions are allowed to do
networking on their main event loop threads, but it's heavily
discouraged.
check out my answer on following post for solution:
Can java.util.zip.GZIPInputStream.close cause android.os.NetworkOnMainThreadException
Seems like the stacktrace is pretty useful. Strictmode is on which will throw an exception if you try doing long-running work on the main (UI) thread.
There are two rules to the Android threading model:
Don't do long work on the main thread
Don't update the UI from outside of the UI thread
You have violated the first of these rules.

How To Display Google Map in android emulator?I tried this program in google AVD in android

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

Categories

Resources