android database leak found IllegalStateException - android

04-20 16:53:39.010: ERROR/Database(419): Leak found
04-20 16:53:39.010: ERROR/Database(419): java.lang.IllegalStateException: mPrograms size 1
04-20 16:53:39.010: ERROR/Database(419): at android.database.sqlite.SQLiteDatabase.finalize(SQLiteDatabase.java:1668)
04-20 16:53:39.010: ERROR/Database(419): at dalvik.system.NativeStart.run(Native Method)
04-20 16:53:39.010: ERROR/Database(419): Caused by: java.lang.IllegalStateException: /data/data/com.example.search/databases/rlite.db SQLiteDatabase created and never closed
04-20 16:53:39.010: ERROR/Database(419): at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1694)
04-20 16:53:39.010: ERROR/Database(419): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:738)
04-20 16:53:39.010: ERROR/Database(419): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:760)
04-20 16:53:39.010: ERROR/Database(419): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:753)
04-20 16:53:39.010: ERROR/Database(419): at android.app.ApplicationContext.openOrCreateDatabase(ApplicationContext.java:473)
04-20 16:53:39.010: ERROR/Database(419): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:193)
04-20 16:53:39.010: ERROR/Database(419): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:98)
04-20 16:53:39.010: ERROR/Database(419): at com.example.search.Database.<init>(Database.java:33)
04-20 16:53:39.010: ERROR/Database(419): at com.example.search.JobDetails.applyJob(JobDetails.java:120)
04-20 16:53:39.010: ERROR/Database(419): at com.example.search.JobDetails.jobdetailsAction(JobDetails.java:98)
04-20 16:53:39.010: ERROR/Database(419): at java.lang.reflect.Method.invokeNative(Native Method)
04-20 16:53:39.010: ERROR/Database(419): at java.lang.reflect.Method.invoke(Method.java:521)
04-20 16:53:39.010: ERROR/Database(419): at android.view.View$1.onClick(View.java:2026)
04-20 16:53:39.010: ERROR/Database(419): at android.view.View.performClick(View.java:2364)
04-20 16:53:39.010: ERROR/Database(419): at android.view.View.onTouchEvent(View.java:4179)
04-20 16:53:39.010: ERROR/Database(419): at android.widget.TextView.onTouchEvent(TextView.java:6540)
04-20 16:53:39.010: ERROR/Database(419): at android.view.View.dispatchTouchEvent(View.java:3709)
04-20 16:53:39.010: ERROR/Database(419): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-20 16:53:39.010: ERROR/Database(419): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-20 16:53:39.010: ERROR/Database(419): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-20 16:53:39.010: ERROR/Database(419): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-20 16:53:39.010: ERROR/Database(419): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
04-20 16:53:39.010: ERROR/Database(419): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
04-20 16:53:39.010: ERROR/Database(419): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
04-20 16:53:39.010: ERROR/Database(419): at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
04-20 16:53:39.010: ERROR/Database(419): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
04-20 16:53:39.010: ERROR/Database(419): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
04-20 16:53:39.010: ERROR/Database(419): at android.os.Handler.dispatchMessage(Handler.java:99)
04-20 16:53:39.010: ERROR/Database(419): at android.os.Looper.loop(Looper.java:123)
04-20 16:53:39.010: ERROR/Database(419): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-20 16:53:39.010: ERROR/Database(419): at java.lang.reflect.Method.invokeNative(Native Method)
04-20 16:53:39.010: ERROR/Database(419): at java.lang.reflect.Method.invoke(Method.java:521)
04-20 16:53:39.010: ERROR/Database(419): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-20 16:53:39.010: ERROR/Database(419): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-20 16:53:39.010: ERROR/Database(419): at dalvik.system.NativeStart.main(Native Method)
when i read the database show error like this. please do reply me

The important line is...
... Caused by: java.lang.IllegalStateException: /data/data/com.example.search/databases/rlite.db SQLiteDatabase created and never closed
Chances are you are allowing your activity to be stopped/exited before you are closing the database. (This can happen if you are not implementing all the (onXXX() methods) in the lifecycle. They can be triggered unexpectedly eg if you rotate the device.
Either write your db access routines as
db.open()
db.dosomething()
db.close()
or make sure you close the database when you get an onSuspend() (I think.. possibly one of the others) and re-open it when you are started again.
Hope this helps
Peter

Related

Genymotion is crashing when I search my current location but when I run the same app in my mobile it is sucessfully running

04-20 07:50:39.793: E/AndroidRuntime(1983): FATAL EXCEPTION: main
04-20 07:50:39.793: E/AndroidRuntime(1983): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.googlemap/com.example.googlemap.LocationSearch}: java.lang.NullPointerException
04-20 07:50:39.793: E/AndroidRuntime(1983): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
04-20 07:50:39.793: E/AndroidRuntime(1983): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
04-20 07:50:39.793: E/AndroidRuntime(1983): at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-20 07:50:39.793: E/AndroidRuntime(1983): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
04-20 07:50:39.793: E/AndroidRuntime(1983): at android.os.Handler.dispatchMessage(Handler.java:99)
04-20 07:50:39.793: E/AndroidRuntime(1983): at android.os.Looper.loop(Looper.java:137)
04-20 07:50:39.793: E/AndroidRuntime(1983): at android.app.ActivityThread.main(ActivityThread.java:5103)
04-20 07:50:39.793: E/AndroidRuntime(1983): at java.lang.reflect.Method.invokeNative(Native Method)
04-20 07:50:39.793: E/AndroidRuntime(1983): at java.lang.reflect.Method.invoke(Method.java:525)
04-20 07:50:39.793: E/AndroidRuntime(1983): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
04-20 07:50:39.793: E/AndroidRuntime(1983): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
04-20 07:50:39.793: E/AndroidRuntime(1983): at dalvik.system.NativeStart.main(Native Method)
04-20 07:50:39.793: E/AndroidRuntime(1983): Caused by: java.lang.NullPointerException
04-20 07:50:39.793: E/AndroidRuntime(1983): at com.example.googlemap.LocationSearch.onCreate(LocationSearch.java:95)
04-20 07:50:39.793: E/AndroidRuntime(1983): at android.app.Activity.performCreate(Activity.java:5133)
04-20 07:50:39.793: E/AndroidRuntime(1983): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-20 07:50:39.793: E/AndroidRuntime(1983): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
04-20 07:50:39.793: E/AndroidRuntime(1983): ... 11 more
and Genymotion is showing error on:
googleMap.setMyLocationEnabled(true);
Even my Genymotion GPS location is ON and set on my current location
and it is running fine on my mobile device.
Your problem is that you are using Google Location Services but you don't have Gapps inside the Genymotion emulator!
Try to follow this tutorial in order to flash'em inside the Genymotion ROM.
Its best practice if you use real device for camera or location based apps.As real devices have different camera features that you can not access on emulator.Same is the case with location based apps that you can not have real locations on emulator and more of that Google keep updating map apis for real devices.

Adding a button to Google Maps fragment layout [duplicate]

This question already has answers here:
How to add buttons at top of map fragment API v2 layout
(4 answers)
Closed 8 years ago.
I want to add a button at the top left corner of the map.
This is my layout:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"
/>
I have tried putting the fragment inside a relative layout, but the app crashes.
I have also seen other proposals, but i am not able to make work any of them.
I only need to put a button on the map.
EDITED:
Text for the exception:
04-20 23:35:18.468: E/AndroidRuntime(7462): FATAL EXCEPTION: main
04-20 23:35:18.468: E/AndroidRuntime(7462): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.solinpromex.vivegrancanaria/com.solinpromex.vivegrancanaria.Empresas_Mapa}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
04-20 23:35:18.468: E/AndroidRuntime(7462): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
04-20 23:35:18.468: E/AndroidRuntime(7462): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
04-20 23:35:18.468: E/AndroidRuntime(7462): at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-20 23:35:18.468: E/AndroidRuntime(7462): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
04-20 23:35:18.468: E/AndroidRuntime(7462): at android.os.Handler.dispatchMessage(Handler.java:99)
04-20 23:35:18.468: E/AndroidRuntime(7462): at android.os.Looper.loop(Looper.java:137)
04-20 23:35:18.468: E/AndroidRuntime(7462): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-20 23:35:18.468: E/AndroidRuntime(7462): at java.lang.reflect.Method.invokeNative(Native Method)
04-20 23:35:18.468: E/AndroidRuntime(7462): at java.lang.reflect.Method.invoke(Method.java:511)
04-20 23:35:18.468: E/AndroidRuntime(7462): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-20 23:35:18.468: E/AndroidRuntime(7462): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-20 23:35:18.468: E/AndroidRuntime(7462): at dalvik.system.NativeStart.main(Native Method)
04-20 23:35:18.468: E/AndroidRuntime(7462): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
04-20 23:35:18.468: E/AndroidRuntime(7462): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
04-20 23:35:18.468: E/AndroidRuntime(7462): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
04-20 23:35:18.468: E/AndroidRuntime(7462): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
04-20 23:35:18.468: E/AndroidRuntime(7462): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-20 23:35:18.468: E/AndroidRuntime(7462): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-20 23:35:18.468: E/AndroidRuntime(7462): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
04-20 23:35:18.468: E/AndroidRuntime(7462): at android.app.Activity.setContentView(Activity.java:1881)
04-20 23:35:18.468: E/AndroidRuntime(7462): at com.solinpromex.vivegrancanaria.Empresas_Mapa.onCreate(Empresas_Mapa.java:47)
04-20 23:35:18.468: E/AndroidRuntime(7462): at android.app.Activity.performCreate(Activity.java:5104)
04-20 23:35:18.468: E/AndroidRuntime(7462): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
04-20 23:35:18.468: E/AndroidRuntime(7462): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
04-20 23:35:18.468: E/AndroidRuntime(7462): ... 11 more
04-20 23:35:18.468: E/AndroidRuntime(7462): Caused by: java.lang.ClassCastException: com.google.android.gms.maps.SupportMapFragment cannot be cast to android.app.Fragment
04-20 23:35:18.468: E/AndroidRuntime(7462): at android.app.Fragment.instantiate(Fragment.java:585)
04-20 23:35:18.468: E/AndroidRuntime(7462): at android.app.Fragment.instantiate(Fragment.java:560)
04-20 23:35:18.468: E/AndroidRuntime(7462): at android.app.Activity.onCreateView(Activity.java:4709)
04-20 23:35:18.468: E/AndroidRuntime(7462): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
04-20 23:35:18.468: E/AndroidRuntime(7462): ... 21 more
I bet here is your problem:
Caused by: java.lang.ClassCastException: com.google.android.gms.maps.SupportMapFragment cannot be cast to android.app.Fragment
Try declaring SupportMapFragment in your xml instead of MapFragment. And also check that your Activity class extends FragmentActivity

java.lang.SecurityException: Destination must be on external storage

in android TV, U disk mount /mnt/usb/sdb4, use android DownloadManage,
File pathyr = new File("/mnt/usb/sdb4");
Uri downloadUri = Uri.parse(DOWNLOAD_FILE);
DownloadManager.Request request = new DownloadManager.Request(downloadUri);
request.setDestinationUri(Uri.fromFile(new File( pathyr,"100mb.jpg") ));
04-20 10:54:05.593: W/dalvikvm(2315): threadid=1: thread exiting with uncaught exception (group=0x40f771f8)
04-20 10:54:05.665: E/AndroidRuntime(2315): FATAL EXCEPTION: main
04-20 10:54:05.665: E/AndroidRuntime(2315): java.lang.SecurityException: Destination must be on external storage: file:///mnt/usb/sdb4/100mb.test.test
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.os.Parcel.readException(Parcel.java:1327)
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:181)
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.content.ContentProviderProxy.insert(ContentProviderNative.java:415)
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.content.ContentResolver.insert(ContentResolver.java:730)
04-20 10:54:05.665: E/AndroidRuntime(2315): at com.exercise.download.DownloadManager.enqueue(DownloadManager.java:750)
04-20 10:54:05.665: E/AndroidRuntime(2315): at com.exercise.AndroidDownloadManager.AndroidDownloadManagerActivity$1.onClick(AndroidDownloadManagerActivity.java:71)
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.view.View.performClick(View.java:3511)
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.view.View.onKeyUp(View.java:6073)
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.widget.TextView.onKeyUp(TextView.java:5595)
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.view.KeyEvent.dispatch(KeyEvent.java:3010)
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.view.View.dispatchKeyEvent(View.java:5500)
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1246)
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1246)
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1246)
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1246)
04-20 10:54:05.665: E/AndroidRuntime(2315): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:1879)
04-20 10:54:05.665: E/AndroidRuntime(2315): at com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1361)
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.app.Activity.dispatchKeyEvent(Activity.java:2325)
04-20 10:54:05.665: E/AndroidRuntime(2315): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1806)
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3327)
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.view.ViewRootImpl.handleFinishedEvent(ViewRootImpl.java:3300)
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2460)
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.os.Handler.dispatchMessage(Handler.java:99)
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.os.Looper.loop(Looper.java:137)
04-20 10:54:05.665: E/AndroidRuntime(2315): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-20 10:54:05.665: E/AndroidRuntime(2315): at java.lang.reflect.Method.invokeNative(Native Method)
04-20 10:54:05.665: E/AndroidRuntime(2315): at java.lang.reflect.Method.invoke(Method.java:511)
04-20 10:54:05.665: E/AndroidRuntime(2315): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:853)
04-20 10:54:05.665: E/AndroidRuntime(2315): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:579)
04-20 10:54:05.665: E/AndroidRuntime(2315): at dalvik.system.NativeStart.main(Native Method)
At the moment, a DownloadManager request accepts only paths on the "standard" external storage, as retrieved by Environment.getExternalStoragePublicDirectory(yourDirOfChoice) or Environment.getExternalStorageDirectory(); otherwise, it throws this exception.
For more info, see this StackOverflow question.
This will not work for Android Pie.
you need to call
.setDestinationInExternalFilesDir()
//Pasing in the getFilesDir().absolutePath, your file

LogCat. How to trace a bug?

I am new to Android debugging. i read about logCat and DDMS on the functions both have and on filtering.
But, i dont understand how to debug my code with logCat. i classified my logcat by Error. and i got 30 errors relating to all kind of issues, ranging from sound issues to battery issues to main issues...
04-20 06:31:09.982: ERROR/Zygote(33): setreuid() failed. errno: 2
04-20 06:31:16.872: ERROR/Zygote(33): setreuid() failed. errno: 17
04-20 06:31:18.064: ERROR/BatteryService(60): usbOnlinePath not found
04-20 06:31:18.064: ERROR/BatteryService(60): batteryVoltagePath not found
04-20 06:31:18.064: ERROR/BatteryService(60): batteryTemperaturePath not found
04-20 06:31:18.082: ERROR/SurfaceFlinger(60): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
04-20 06:31:23.482: ERROR/EventHub(60): could not get driver version for /dev/input/mouse0, Not a typewriter
04-20 06:31:23.482: ERROR/EventHub(60): could not get driver version for /dev/input/mice, Not a typewriter
04-20 06:31:23.692: ERROR/System(60): Failure starting core service
04-20 06:31:23.692: ERROR/System(60): java.lang.SecurityException
04-20 06:31:23.692: ERROR/System(60): at android.os.BinderProxy.transact(Native Method)
04-20 06:31:23.692: ERROR/System(60): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
04-20 06:31:23.692: ERROR/System(60): at android.os.ServiceManager.addService(ServiceManager.java:72)
04-20 06:31:23.692: ERROR/System(60): at com.android.server.ServerThread.run(SystemServer.java:184)
04-20 06:31:24.602: ERROR/SoundPool(60): error loading /system/media/audio/ui/Effect_Tick.ogg
04-20 06:31:24.602: ERROR/SoundPool(60): error loading /system/media/audio/ui/KeypressStandard.ogg
04-20 06:31:24.602: ERROR/SoundPool(60): error loading /system/media/audio/ui/KeypressSpacebar.ogg
04-20 06:31:24.612: ERROR/SoundPool(60): error loading /system/media/audio/ui/KeypressDelete.ogg
04-20 06:31:24.622: ERROR/SoundPool(60): error loading /system/media/audio/ui/KeypressReturn.ogg
04-20 06:31:26.411: ERROR/ThrottleService(60): Could not open GPS configuration file /etc/gps.conf
04-20 06:31:27.751: ERROR/logwrapper(149): executing /system/bin/tc failed: No such file or directory
04-20 06:31:27.792: ERROR/logwrapper(150): executing /system/bin/tc failed: No such file or directory
04-20 06:31:27.823: ERROR/logwrapper(151): executing /system/bin/tc failed: No such file or directory
04-20 06:31:37.841: ERROR/HierarchicalStateMachine(60): TetherMaster - unhandledMessage: msg.what=3
04-20 06:31:58.767: ERROR/AndroidRuntime(277): FATAL EXCEPTION: main
04-20 06:31:58.767: ERROR/AndroidRuntime(277): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.markana.yamba/com.markana.yamba.StatusActivity1}: java.lang.ClassNotFoundException: com.markana.yamba.StatusActivity1 in loader dalvik.system.PathClassLoader[/data/app/com.markana.yamba-2.apk]
04-20 06:31:58.767: ERROR/AndroidRuntime(277): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
04-20 06:31:58.767: ERROR/AndroidRuntime(277): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-20 06:31:58.767: ERROR/AndroidRuntime(277): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-20 06:31:58.767: ERROR/AndroidRuntime(277): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-20 06:31:58.767: ERROR/AndroidRuntime(277): at android.os.Handler.dispatchMessage(Handler.java:99)
04-20 06:31:58.767: ERROR/AndroidRuntime(277): at android.os.Looper.loop(Looper.java:123)
04-20 06:31:58.767: ERROR/AndroidRuntime(277): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-20 06:31:58.767: ERROR/AndroidRuntime(277): at java.lang.reflect.Method.invokeNative(Native Method)
04-20 06:31:58.767: ERROR/AndroidRuntime(277): at java.lang.reflect.Method.invoke(Method.java:521)
04-20 06:31:58.767: ERROR/AndroidRuntime(277): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-20 06:31:58.767: ERROR/AndroidRuntime(277): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-20 06:31:58.767: ERROR/AndroidRuntime(277): at dalvik.system.NativeStart.main(Native Method)
04-20 06:31:58.767: ERROR/AndroidRuntime(277): Caused by: java.lang.ClassNotFoundException: com.markana.yamba.StatusActivity1 in loader dalvik.system.PathClassLoader[/data/app/com.markana.yamba-2.apk]
04-20 06:31:58.767: ERROR/AndroidRuntime(277): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-20 06:31:58.767: ERROR/AndroidRuntime(277): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-20 06:31:58.767: ERROR/AndroidRuntime(277): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-20 06:31:58.767: ERROR/AndroidRuntime(277): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-20 06:31:58.767: ERROR/AndroidRuntime(277): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
04-20 06:31:58.767: ERROR/AndroidRuntime(277): ... 11 more
04-20 07:30:54.993: ERROR/Zygote(33): setreuid() failed. errno: 2
04-20 07:31:02.125: ERROR/Zygote(33): setreuid() failed. errno: 17
04-20 07:31:03.243: ERROR/BatteryService(59): usbOnlinePath not found
04-20 07:31:03.243: ERROR/BatteryService(59): batteryVoltagePath not found
04-20 07:31:03.243: ERROR/BatteryService(59): batteryTemperaturePath not found
04-20 07:31:03.273: ERROR/SurfaceFlinger(59): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
04-20 07:31:09.004: ERROR/EventHub(59): could not get driver version for /dev/input/mouse0, Not a typewriter
04-20 07:31:09.004: ERROR/EventHub(59): could not get driver version for /dev/input/mice, Not a typewriter
04-20 07:31:09.265: ERROR/System(59): Failure starting core service
04-20 07:31:09.265: ERROR/System(59): java.lang.SecurityException
04-20 07:31:09.265: ERROR/System(59): at android.os.BinderProxy.transact(Native Method)
04-20 07:31:09.265: ERROR/System(59): at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
04-20 07:31:09.265: ERROR/System(59): at android.os.ServiceManager.addService(ServiceManager.java:72)
04-20 07:31:09.265: ERROR/System(59): at com.android.server.ServerThread.run(SystemServer.java:184)
04-20 07:31:10.843: ERROR/SoundPool(59): error loading /system/media/audio/ui/Effect_Tick.ogg
04-20 07:31:10.865: ERROR/SoundPool(59): error loading /system/media/audio/ui/KeypressStandard.ogg
04-20 07:31:10.865: ERROR/SoundPool(59): error loading /system/media/audio/ui/KeypressSpacebar.ogg
04-20 07:31:10.873: ERROR/SoundPool(59): error loading /system/media/audio/ui/KeypressDelete.ogg
04-20 07:31:10.884: ERROR/SoundPool(59): error loading /system/media/audio/ui/KeypressReturn.ogg
04-20 07:31:12.824: ERROR/ThrottleService(59): Could not open GPS configuration file /etc/gps.conf
04-20 07:31:14.294: ERROR/logwrapper(149): executing /system/bin/tc failed: No such file or directory
04-20 07:31:14.364: ERROR/logwrapper(150): executing /system/bin/tc failed: No such file or directory
04-20 07:31:14.403: ERROR/logwrapper(152): executing /system/bin/tc failed: No such file or directory
04-20 07:31:26.859: ERROR/HierarchicalStateMachine(59): TetherMaster - unhandledMessage: msg.what=3
04-20 07:31:49.188: ERROR/AndroidRuntime(298): FATAL EXCEPTION: main
04-20 07:31:49.188: ERROR/AndroidRuntime(298): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.markana.yamba/com.markana.yamba.StatusActivity1}: java.lang.ClassNotFoundException: com.markana.yamba.StatusActivity1 in loader dalvik.system.PathClassLoader[/data/app/com.markana.yamba-1.apk]
04-20 07:31:49.188: ERROR/AndroidRuntime(298): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
04-20 07:31:49.188: ERROR/AndroidRuntime(298): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-20 07:31:49.188: ERROR/AndroidRuntime(298): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-20 07:31:49.188: ERROR/AndroidRuntime(298): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-20 07:31:49.188: ERROR/AndroidRuntime(298): at android.os.Handler.dispatchMessage(Handler.java:99)
04-20 07:31:49.188: ERROR/AndroidRuntime(298): at android.os.Looper.loop(Looper.java:123)
04-20 07:31:49.188: ERROR/AndroidRuntime(298): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-20 07:31:49.188: ERROR/AndroidRuntime(298): at java.lang.reflect.Method.invokeNative(Native Method)
04-20 07:31:49.188: ERROR/AndroidRuntime(298): at java.lang.reflect.Method.invoke(Method.java:521)
04-20 07:31:49.188: ERROR/AndroidRuntime(298): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-20 07:31:49.188: ERROR/AndroidRuntime(298): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-20 07:31:49.188: ERROR/AndroidRuntime(298): at dalvik.system.NativeStart.main(Native Method)
04-20 07:31:49.188: ERROR/AndroidRuntime(298): Caused by: java.lang.ClassNotFoundException: com.markana.yamba.StatusActivity1 in loader dalvik.system.PathClassLoader[/data/app/com.markana.yamba-1.apk]
04-20 07:31:49.188: ERROR/AndroidRuntime(298): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-20 07:31:49.188: ERROR/AndroidRuntime(298): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-20 07:31:49.188: ERROR/AndroidRuntime(298): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-20 07:31:49.188: ERROR/AndroidRuntime(298): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-20 07:31:49.188: ERROR/AndroidRuntime(298): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
04-20 07:31:49.188: ERROR/AndroidRuntime(298): ... 11 more
04-20 07:33:45.057: ERROR/AndroidRuntime(369): FATAL EXCEPTION: main
04-20 07:33:45.057: ERROR/AndroidRuntime(369): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.markana.yamba/com.markana.yamba.StatusActivity1}: java.lang.ClassNotFoundException: com.markana.yamba.StatusActivity1 in loader dalvik.system.PathClassLoader[/data/app/com.markana.yamba-1.apk]
04-20 07:33:45.057: ERROR/AndroidRuntime(369): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
04-20 07:33:45.057: ERROR/AndroidRuntime(369): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-20 07:33:45.057: ERROR/AndroidRuntime(369): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-20 07:33:45.057: ERROR/AndroidRuntime(369): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-20 07:33:45.057: ERROR/AndroidRuntime(369): at android.os.Handler.dispatchMessage(Handler.java:99)
04-20 07:33:45.057: ERROR/AndroidRuntime(369): at android.os.Looper.loop(Looper.java:123)
04-20 07:33:45.057: ERROR/AndroidRuntime(369): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-20 07:33:45.057: ERROR/AndroidRuntime(369): at java.lang.reflect.Method.invokeNative(Native Method)
04-20 07:33:45.057: ERROR/AndroidRuntime(369): at java.lang.reflect.Method.invoke(Method.java:521)
04-20 07:33:45.057: ERROR/AndroidRuntime(369): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-20 07:33:45.057: ERROR/AndroidRuntime(369): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-20 07:33:45.057: ERROR/AndroidRuntime(369): at dalvik.system.NativeStart.main(Native Method)
04-20 07:33:45.057: ERROR/AndroidRuntime(369): Caused by: java.lang.ClassNotFoundException: com.markana.yamba.StatusActivity1 in loader dalvik.system.PathClassLoader[/data/app/com.markana.yamba-1.apk]
04-20 07:33:45.057: ERROR/AndroidRuntime(369): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-20 07:33:45.057: ERROR/AndroidRuntime(369): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-20 07:33:45.057: ERROR/AndroidRuntime(369): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-20 07:33:45.057: ERROR/AndroidRuntime(369): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-20 07:33:45.057: ERROR/AndroidRuntime(369): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
04-20 07:33:45.057: ERROR/AndroidRuntime(369): ... 11 more
04-20 07:33:58.677: ERROR/AndroidRuntime(412): FATAL EXCEPTION: main
04-20 07:33:58.677: ERROR/AndroidRuntime(412): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.markana.yamba/com.markana.yamba.StatusActivity1}: java.lang.ClassNotFoundException: com.markana.yamba.StatusActivity1 in loader dalvik.system.PathClassLoader[/data/app/com.markana.yamba-2.apk]
04-20 07:33:58.677: ERROR/AndroidRuntime(412): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
04-20 07:33:58.677: ERROR/AndroidRuntime(412): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-20 07:33:58.677: ERROR/AndroidRuntime(412): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-20 07:33:58.677: ERROR/AndroidRuntime(412): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-20 07:33:58.677: ERROR/AndroidRuntime(412): at android.os.Handler.dispatchMessage(Handler.java:99)
04-20 07:33:58.677: ERROR/AndroidRuntime(412): at android.os.Looper.loop(Looper.java:123)
04-20 07:33:58.677: ERROR/AndroidRuntime(412): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-20 07:33:58.677: ERROR/AndroidRuntime(412): at java.lang.reflect.Method.invokeNative(Native Method)
04-20 07:33:58.677: ERROR/AndroidRuntime(412): at java.lang.reflect.Method.invoke(Method.java:521)
04-20 07:33:58.677: ERROR/AndroidRuntime(412): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-20 07:33:58.677: ERROR/AndroidRuntime(412): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-20 07:33:58.677: ERROR/AndroidRuntime(412): at dalvik.system.NativeStart.main(Native Method)
04-20 07:33:58.677: ERROR/AndroidRuntime(412): Caused by: java.lang.ClassNotFoundException: com.markana.yamba.StatusActivity1 in loader dalvik.system.PathClassLoader[/data/app/com.markana.yamba-2.apk]
04-20 07:33:58.677: ERROR/AndroidRuntime(412): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-20 07:33:58.677: ERROR/AndroidRuntime(412): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-20 07:33:58.677: ERROR/AndroidRuntime(412): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-20 07:33:58.677: ERROR/AndroidRuntime(412): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-20 07:33:58.677: ERROR/AndroidRuntime(412): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
04-20 07:33:58.677: ERROR/AndroidRuntime(412): ... 11 more
My code in the class is quite simple, i did what the example in Android Orielly book did:
package com.markana.yamba;
import winterwell.jtwitter.Twitter;
import winterwell.jtwitter.TwitterException;
import android.app.Activity;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class StatusActivity2 extends Activity implements OnClickListener{
private static final String TAG= "StatusActivity";
EditText editText;
Button updateButton;
TextView textCount;
Twitter twitter;
/** Called when the activity is first created. */
#SuppressWarnings("deprecation")
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.status);
//Finds views
editText =(EditText) findViewById(R.id.editText);
updateButton=(Button) findViewById(R.id.buttonUpdate);
updateButton.setOnClickListener(this);
textCount= (TextView) findViewById(R.id.editText);
textCount.setText(Integer.toString(40));
textCount.setTextColor(Color.GREEN);
// editText.addTextChangedListener(this);
twitter=new Twitter("student","password");
twitter.setAPIRootUrl(("http://yamba.marakana.com/api"));
//added by me
AsyncTask<String, ?, ?> asyn=new PostToTwitter();
asyn.execute("deliver this to twitter");
}
class PostToTwitter extends AsyncTask<String,Integer, String>
{
#Override
protected String doInBackground(String... statuses) {
try{
Twitter.Status status=twitter.updateStatus(statuses[0]);
return status.text;
}
catch(TwitterException e)
{
Log.e(TAG,e.toString());
e.printStackTrace();
return "Failed to post";
}
}
protected void onProgressUpdate(Integer...values)
{
super.onProgressUpdate(values);
}
protected void onPostExecute(String result)
{
Toast.makeText(StatusActivity2.this,result,Toast.LENGTH_LONG).show();
}
}
public void onClick(View arg0) {
// TODO Auto-generated method stub
String status=editText.getText().toString();
new PostToTwitter().execute(status);
Log.d(TAG, "onClick");
}
}
i have no red error marks, nor here nor in the main.xml , string.xml files
How do i trace my bug?
You just read through the output to find
Caused by: java.lang.ClassNotFoundException: com.markana.yamba.StatusActivity1
Which means that this class is missing in the .apk that you've deployed to the device.
Note that your activity is named StatusActivity2 - double check the manifest if that has still StatusActivity1.

android RestClientException: no suitable HttpMessageConverter found

I am using spring android rest template and trying to convert a JSON response into a java class as shown here.
Here is my snippet trying to do the work:
RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(new MappingJacksonHttpMessageConverter());
//I have already tried to manually setting converters with no luck
//List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
//messageConverters.add(new MappingJacksonHttpMessageConverter());
//messageConverters.add(new FormHttpMessageConverter());
//messageConverters.add(new StringHttpMessageConverter());
//restTemplate.setMessageConverters(messageConverters);
Result result = restTemplate.getForObject(url, Result.class);
I think I have done everything required as it is told in the document:
I have following jars in my classpath
jackson-all-1.7.6.jar
spring-android-rest-template-1.0.0.M2.jar
the url really returns a JSON object.
My Result class is a POJO with all the required fields
Basically having the Jackson dependencies in my classpath must be enough to get it work as it says:
The MappingJacksonHttpMessageConverter is conditionally loaded when you create a new RestTemplate instance. If the Jackson dependencies are found in your classpath, the message converter will be automatically added and available for use in REST operations.
So what I am missing here, what I am doing wrong?
Thanks
Full exception can be found here:
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): FATAL EXCEPTION: main
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): java.lang.IllegalStateException: Could not execute method of the activity
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): at android.view.View$1.onClick(View.java:2083)
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): at android.view.View.performClick(View.java:2421)
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): at android.view.View$PerformClick.run(View.java:8869)
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): at android.os.Handler.handleCallback(Handler.java:587)
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): at android.os.Handler.dispatchMessage(Handler.java:92)
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): at android.os.Looper.loop(Looper.java:143)
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): at android.app.ActivityThread.main(ActivityThread.java:5068)
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): at java.lang.reflect.Method.invokeNative(Native Method)
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): at java.lang.reflect.Method.invoke(Method.java:521)
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): at dalvik.system.NativeStart.main(Native Method)
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): Caused by: java.lang.reflect.InvocationTargetException
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): at xxx.SamplePageActivity.doRest(SamplePageActivity.java:83)
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): at java.lang.reflect.Method.invokeNative(Native Method)
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): at java.lang.reflect.Method.invoke(Method.java:521)
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): at android.view.View$1.onClick(View.java:2078)
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): ... 11 more
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): Caused by: org.springframework.web.client.RestClientException: Could not extract response: no suitable HttpMessageConverter found for response type [[Lxxx.SamplePageActivity$Result;] and content type [application/json;charset=UTF-8]
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:77)
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:449)
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:404)
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:202)
04-20 04:25:52.706: ERROR/AndroidRuntime(9638): ... 15 more
I've never done anything on Android but I know converts are picky with Content-Type. For Jackson to work the message body needs to have 'Content-Type: application/json'. Try to check all headers on the response.
I've met the same exception and fixed it now.
Root cause
At the server, I was setting the response like this:
response.setContentType("text/html;charset=utf-8");
Solution
I updated the contentType like this:
response.setContentType("application/json;charset=utf-8");
For me, this error was thrown for a class that would use an enum type instead of a String for a certain property.
The other cause could also be that you are using Jackson 2. You should then change to MappingJackson2HttpMessageConverter (instead of MappingJacksonHttpMessageConverter).
Here's what worked for me in a similar situation:
HttpHeaders requestHeaders = new HttpHeaders(); // Sending
multipart/form-data
requestHeaders.setContentType(MediaType.MULTIPART_FORM_DATA);
// Populate the MultiValueMap being serialized and headers in an
HttpEntity object to use for the request
HttpEntity> requestEntity = new
HttpEntity>( parts, requestHeaders);
RestTemplate restTemplate = getRestTemplate();
restTemplate.getMessageConverters().add(new
FormHttpMessageConverter());
restTemplate.getMessageConverters().add(new
MappingJackson2HttpMessageConverter());
return restTemplate.postForObject(URI, requestEntity,
APIResponseUpload.class);

Categories

Resources