OutOFMemory error in volley library - android

This is what I am doing, Firstly into the constructor of Customadapter, I have initilize image cache and image loader
imageCache = new BitmapLruCache();
mImageLoader = new ImageLoader(newRequestQueue(context), imageCache);
then into the getView() method I have done...
String url = imgs[position];
image.setImageUrl(url, mImageLoader);
image.setDefaultImageResId(R.drawable.no_image);
image.setErrorImageResId(R.drawable.error_image);
Where imgs is the array for bitmaps url and image is the object of NetworkImageView. When I execute it, I got error of OutOfMemory. This is my logcat o/p :-
02-24 12:08:08.845: E/dalvikvm-heap(6288): Out of memory on a 144636048-byte allocation.
02-24 12:08:08.845: I/dalvikvm(6288): "main" prio=5 tid=1 RUNNABLE
02-24 12:08:08.845: I/dalvikvm(6288): | group="main" sCount=0 dsCount=0 obj=0x41767b50 self=0x417571d0
02-24 12:08:08.845: I/dalvikvm(6288): | sysTid=6288 nice=0 sched=0/0 cgrp=apps handle=1075191004
02-24 12:08:08.845: I/dalvikvm(6288): | state=R schedstat=( 0 0 0 ) utm=116 stm=35 core=1
02-24 12:08:08.845: I/dalvikvm(6288): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-24 12:08:08.855: I/dalvikvm(6288): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
02-24 12:08:08.855: I/dalvikvm(6288): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
02-24 12:08:08.855: I/dalvikvm(6288): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:815)
02-24 12:08:08.855: I/dalvikvm(6288): at android.content.res.Resources.loadDrawable(Resources.java:1992)
02-24 12:08:08.855: I/dalvikvm(6288): at android.content.res.Resources.getDrawable(Resources.java:666)
02-24 12:08:08.855: I/dalvikvm(6288): at android.widget.ImageView.resolveUri(ImageView.java:616)
02-24 12:08:08.855: I/dalvikvm(6288): at android.widget.ImageView.setImageResource(ImageView.java:349)
02-24 12:08:08.855: I/dalvikvm(6288): at com.android.volley.toolbox.NetworkImageView$1.onResponse(NetworkImageView.java:177)
02-24 12:08:08.855: I/dalvikvm(6288): at com.android.volley.toolbox.NetworkImageView$1$1.run(NetworkImageView.java:168)
02-24 12:08:08.855: I/dalvikvm(6288): at android.os.Handler.handleCallback(Handler.java:725)
02-24 12:08:08.855: I/dalvikvm(6288): at android.os.Handler.dispatchMessage(Handler.java:92)
02-24 12:08:08.855: I/dalvikvm(6288): at android.os.Looper.loop(Looper.java:137)
02-24 12:08:08.855: I/dalvikvm(6288): at android.app.ActivityThread.main(ActivityThread.java:5099)
02-24 12:08:08.855: I/dalvikvm(6288): at java.lang.reflect.Method.invokeNative(Native Method)
02-24 12:08:08.865: I/dalvikvm(6288): at java.lang.reflect.Method.invoke(Method.java:511)
02-24 12:08:08.865: I/dalvikvm(6288): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:803)
02-24 12:08:08.865: I/dalvikvm(6288): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:570)
02-24 12:08:08.865: I/dalvikvm(6288): at dalvik.system.NativeStart.main(Native Method)
02-24 12:08:08.865: D/skia(6288): --- decoder->decode returned false
02-24 12:08:08.865: D/AndroidRuntime(6288): Shutting down VM
02-24 12:08:08.865: W/dalvikvm(6288): threadid=1: thread exiting with uncaught exception (group=0x41766ae0)
02-24 12:08:08.875: E/AndroidRuntime(6288): FATAL EXCEPTION: main
02-24 12:08:08.875: E/AndroidRuntime(6288): java.lang.OutOfMemoryError
02-24 12:08:08.875: E/AndroidRuntime(6288): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-24 12:08:08.875: E/AndroidRuntime(6288): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
02-24 12:08:08.875: E/AndroidRuntime(6288): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
02-24 12:08:08.875: E/AndroidRuntime(6288): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:815)
02-24 12:08:08.875: E/AndroidRuntime(6288): at android.content.res.Resources.loadDrawable(Resources.java:1992)
02-24 12:08:08.875: E/AndroidRuntime(6288): at android.content.res.Resources.getDrawable(Resources.java:666)
02-24 12:08:08.875: E/AndroidRuntime(6288): at android.widget.ImageView.resolveUri(ImageView.java:616)
02-24 12:08:08.875: E/AndroidRuntime(6288): at android.widget.ImageView.setImageResource(ImageView.java:349)
02-24 12:08:08.875: E/AndroidRuntime(6288): at com.android.volley.toolbox.NetworkImageView$1.onResponse(NetworkImageView.java:177)
02-24 12:08:08.875: E/AndroidRuntime(6288): at com.android.volley.toolbox.NetworkImageView$1$1.run(NetworkImageView.java:168)
02-24 12:08:08.875: E/AndroidRuntime(6288): at android.os.Handler.handleCallback(Handler.java:725)
02-24 12:08:08.875: E/AndroidRuntime(6288): at android.os.Handler.dispatchMessage(Handler.java:92)
02-24 12:08:08.875: E/AndroidRuntime(6288): at android.os.Looper.loop(Looper.java:137)
02-24 12:08:08.875: E/AndroidRuntime(6288): at android.app.ActivityThread.main(ActivityThread.java:5099)
02-24 12:08:08.875: E/AndroidRuntime(6288): at java.lang.reflect.Method.invokeNative(Native Method)
02-24 12:08:08.875: E/AndroidRuntime(6288): at java.lang.reflect.Method.invoke(Method.java:511)
02-24 12:08:08.875: E/AndroidRuntime(6288): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:803)
02-24 12:08:08.875: E/AndroidRuntime(6288): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:570)
02-24 12:08:08.875: E/AndroidRuntime(6288): at dalvik.system.NativeStart.main(Native Method)
I cant find any solution that will work for me, So What should I do...

Thanks to Mr. Itai Hanski,
After your suggestion about OOM that OOM doesn't have to do with the network components, I had looked out on any other cause, Finally I found solution :
It was from layout file of listview item, I had set the android:src="" into the Imageview.
When I remove this xml attribute from ImageView, The OOM problem resolve out.
But one thing I still not found that when I set a image for error or loading condition the error again comes out, still I cant uderstand what the real cause of it.

Bitmaps are a real issue in android.
First off - I really recommend you read this post on the developer site.
How is your BitmapLruCache implemented? Here are a few pointers (you can use only some of them):
Limit the number of bitmaps the cache can hold.
Limit the size of the cache itself. The Android guys provide a nice algorithm to decide how large to make it in the linked article.
When possible, call bitmap.recycle().
Use weak / soft references to the Bitmaps in your cache instead of strong one.
Check out this SO answer to a similar question (shameless self plug, but relevant).
You probably don't need to implement all of these at the same time. Choose the ones that work for you.

Related

Opencv on android and video record

I'm trying to process camera image on opencv(2.4.8) and record video together on android.
In the middle of just camera preview, video record is done successfully, however, after starting
image process on opencv, there is EXCEPTION like below. It is not functional videowriter API in opnecv on android, so I used MediaRecorder that is android API to record video.
Is there any way I can solve the problems were occurred by when trying to process image and video record at the same time?
Thanks!
02-24 16:38:50.071: E/AndroidRuntime(8117): FATAL EXCEPTION: main
02-24 16:38:50.071: E/AndroidRuntime(8117): java.lang.RuntimeException: Method called after release()
02-24 16:38:50.071: E/AndroidRuntime(8117): at android.hardware.Camera.setHasPreviewCallback(Native Method)
02-24 16:38:50.071: E/AndroidRuntime(8117): at android.hardware.Camera.access$600(Camera.java:133)
02-24 16:38:50.071: E/AndroidRuntime(8117): at android.hardware.Camera$EventHandler.handleMessage(Camera.java:815)
02-24 16:38:50.071: E/AndroidRuntime(8117): at android.os.Handler.dispatchMessage(Handler.java:99)
02-24 16:38:50.071: E/AndroidRuntime(8117): at android.os.Looper.loop(Looper.java:137)
02-24 16:38:50.071: E/AndroidRuntime(8117): at android.app.ActivityThread.main(ActivityThread.java:4961)
02-24 16:38:50.071: E/AndroidRuntime(8117): at java.lang.reflect.Method.invokeNative(Native Method)
02-24 16:38:50.071: E/AndroidRuntime(8117): at java.lang.reflect.Method.invoke(Method.java:511)
02-24 16:38:50.071: E/AndroidRuntime(8117): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
02-24 16:38:50.071: E/AndroidRuntime(8117): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
02-24 16:38:50.071: E/AndroidRuntime(8117): at dalvik.system.NativeStart.main(Native Method)

unfortunately application has stopped

I am getting error message on my AVD for my first android app named "My creativity".
Its showing:
Unfortunately My creativity has stopped
It has a simple text box and a button with background.
I am taking help of google.developers but getting above problem.
How to solve this?
Here's my LogCat:
02-24 10:18:48.624: I/Process(1068): Sending signal. PID: 1068 SIG: 9
02-24 10:18:51.654: W/Trace(1088): Unexpected value from nativeGetEnabledTags: 0
02-24 10:18:51.654: W/Trace(1088): Unexpected value from nativeGetEnabledTags: 0
02-24 10:18:52.194: D/dalvikvm(1088): GC_FOR_ALLOC freed 77K, 8% free 2513K/2708K, paused 52ms, total 56ms
02-24 10:18:52.534: I/dalvikvm-heap(1088): Grow heap (frag case) to 21.787MB for 20155408-byte allocation
02-24 10:18:52.674: D/dalvikvm(1088): GC_FOR_ALLOC freed 1K, 1% free 22194K/22392K, paused 137ms, total 137ms
02-24 10:18:52.784: D/dalvikvm(1088): GC_CONCURRENT freed <1K, 1% free 22194K/22392K, paused 9ms+21ms, total 109ms
02-24 10:18:55.204: D/dalvikvm(1088): GC_FOR_ALLOC freed <1K, 1% free 22194K/22392K, paused 41ms, total 41ms
02-24 10:18:55.204: I/dalvikvm-heap(1088): Forcing collection of SoftReferences for 45349648-byte allocation
02-24 10:18:55.284: D/dalvikvm(1088): GC_BEFORE_OOM freed 9K, 1% free 22184K/22392K, paused 72ms, total 73ms
02-24 10:18:55.284: E/dalvikvm-heap(1088): Out of memory on a 45349648-byte allocation.
02-24 10:18:55.284: I/dalvikvm(1088): "main" prio=5 tid=1 RUNNABLE
02-24 10:18:55.284: I/dalvikvm(1088): | group="main" sCount=0 dsCount=0 obj=0x40a719a0 self=0x2a00bba8
02-24 10:18:55.284: I/dalvikvm(1088): | sysTid=1088 nice=0 sched=0/0 cgrp=apps handle=1073849308
02-24 10:18:55.284: I/dalvikvm(1088): | state=R schedstat=( 3224239902 1154906764 146 ) utm=280 stm=42 core=0
02-24 10:18:55.284: I/dalvikvm(1088): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-24 10:18:55.294: I/dalvikvm(1088): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
02-24 10:18:55.294: I/dalvikvm(1088): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
02-24 10:18:55.294: I/dalvikvm(1088): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
02-24 10:18:55.294: I/dalvikvm(1088): at android.content.res.Resources.loadDrawable(Resources.java:1965)
02-24 10:18:55.304: I/dalvikvm(1088): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
02-24 10:18:55.304: I/dalvikvm(1088): at android.view.View.<init>(View.java:3328)
02-24 10:18:55.304: I/dalvikvm(1088): at android.view.ViewGroup.<init>(ViewGroup.java:431)
02-24 10:18:55.304: I/dalvikvm(1088): at android.widget.LinearLayout.<init>(LinearLayout.java:176)
02-24 10:18:55.304: I/dalvikvm(1088): at android.widget.LinearLayout.<init>(LinearLayout.java:172)
02-24 10:18:55.316: I/dalvikvm(1088): at java.lang.reflect.Constructor.constructNative(Native Method)
02-24 10:18:55.316: I/dalvikvm(1088): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
02-24 10:18:55.316: I/dalvikvm(1088): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
02-24 10:18:55.316: I/dalvikvm(1088): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-24 10:18:55.316: I/dalvikvm(1088): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
02-24 10:18:55.316: I/dalvikvm(1088): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
02-24 10:18:55.316: I/dalvikvm(1088): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
02-24 10:18:55.324: I/dalvikvm(1088): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-24 10:18:55.324: I/dalvikvm(1088): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-24 10:18:55.324: I/dalvikvm(1088): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
02-24 10:18:55.324: I/dalvikvm(1088): at android.app.Activity.setContentView(Activity.java:1881)
02-24 10:18:55.334: I/dalvikvm(1088): at com.example.iamgreat.GreatPiyu.onCreate(GreatPiyu.java:12)
02-24 10:18:55.334: I/dalvikvm(1088): at android.app.Activity.performCreate(Activity.java:5104)
02-24 10:18:55.334: I/dalvikvm(1088): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
02-24 10:18:55.344: I/dalvikvm(1088): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
02-24 10:18:55.344: I/dalvikvm(1088): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
02-24 10:18:55.344: I/dalvikvm(1088): at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-24 10:18:55.344: I/dalvikvm(1088): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
02-24 10:18:55.354: I/dalvikvm(1088): at android.os.Handler.dispatchMessage(Handler.java:99)
02-24 10:18:55.354: I/dalvikvm(1088): at android.os.Looper.loop(Looper.java:137)
02-24 10:18:55.354: I/dalvikvm(1088): at android.app.ActivityThread.main(ActivityThread.java:5039)
02-24 10:18:55.354: I/dalvikvm(1088): at java.lang.reflect.Method.invokeNative(Native Method)
02-24 10:18:55.354: I/dalvikvm(1088): at java.lang.reflect.Method.invoke(Method.java:511)
02-24 10:18:55.354: I/dalvikvm(1088): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-24 10:18:55.354: I/dalvikvm(1088): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-24 10:18:55.354: I/dalvikvm(1088): at dalvik.system.NativeStart.main(Native Method)
02-24 10:18:55.364: D/skia(1088): --- allocation failed for scaled bitmap
02-24 10:18:55.404: D/AndroidRuntime(1088): Shutting down VM
02-24 10:18:55.404: W/dalvikvm(1088): threadid=1: thread exiting with uncaught exception (group=0x40a70930)
02-24 10:18:55.515: E/AndroidRuntime(1088): FATAL EXCEPTION: main
02-24 10:18:55.515: E/AndroidRuntime(1088): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.iamgreat/com.example.iamgreat.GreatPiyu}: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.os.Handler.dispatchMessage(Handler.java:99)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.os.Looper.loop(Looper.java:137)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.app.ActivityThread.main(ActivityThread.java:5039)
02-24 10:18:55.515: E/AndroidRuntime(1088): at java.lang.reflect.Method.invokeNative(Native Method)
02-24 10:18:55.515: E/AndroidRuntime(1088): at java.lang.reflect.Method.invoke(Method.java:511)
02-24 10:18:55.515: E/AndroidRuntime(1088): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-24 10:18:55.515: E/AndroidRuntime(1088): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-24 10:18:55.515: E/AndroidRuntime(1088): at dalvik.system.NativeStart.main(Native Method)
02-24 10:18:55.515: E/AndroidRuntime(1088): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
02-24 10:18:55.515: E/AndroidRuntime(1088): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-24 10:18:55.515: E/AndroidRuntime(1088): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.app.Activity.setContentView(Activity.java:1881)
02-24 10:18:55.515: E/AndroidRuntime(1088): at com.example.iamgreat.GreatPiyu.onCreate(GreatPiyu.java:12)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.app.Activity.performCreate(Activity.java:5104)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
02-24 10:18:55.515: E/AndroidRuntime(1088): ... 11 more
02-24 10:18:55.515: E/AndroidRuntime(1088): Caused by: java.lang.reflect.InvocationTargetException
02-24 10:18:55.515: E/AndroidRuntime(1088): at java.lang.reflect.Constructor.constructNative(Native Method)
02-24 10:18:55.515: E/AndroidRuntime(1088): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
02-24 10:18:55.515: E/AndroidRuntime(1088): ... 23 more
02-24 10:18:55.515: E/AndroidRuntime(1088): Caused by: java.lang.OutOfMemoryError
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.content.res.Resources.loadDrawable(Resources.java:1965)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.view.View.<init>(View.java:3328)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.view.ViewGroup.<init>(ViewGroup.java:431)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.widget.LinearLayout.<init>(LinearLayout.java:176)
02-24 10:18:55.515: E/AndroidRuntime(1088): at android.widget.LinearLayout.<init>(LinearLayout.java:172)
02-24 10:18:55.515: E/AndroidRuntime(1088): ... 26 more
Out of memory on a 45349648-byte allocation
I think you are using lots of images and its not able to inflate it all at once.
Have a look at:
http://developer.android.com/training/displaying-bitmaps/load-bitmap.html

android-opencv sample crash - tutorial2 Advanced

I have a problem running tutorial2 (Advanced - Mix java 9+ native
opencv) sample on HTC incredible S.
Other samples work great.
The app terminates immediately with this message: "The application
Tutorial 2 Advanced - 2. Mix Java + Native OpenCV( process
org.opencv.samples.tutorial4) has expired unexpectedly. Please try
again."
Any help or suggestion?
02-24 22:27:12.083: I/Process(2212): Sending signal. PID: 2212 SIG: 9
02-24 23:15:34.915: I/Sample::Activity(2296): Instantiated new class
org.opencv.samples.tutorial4.Sample4Mixed
02-24 23:15:34.935: I/Sample::Activity(2296): onCreate
02-24 23:15:34.935: W/dalvikvm(2296): Exception Ljava/lang/
UnsatisfiedLinkError; thrown while initializing Lorg/opencv/samples/
tutorial4/Sample4View;
02-24 23:15:34.935: D/AndroidRuntime(2296): Shutting down VM
02-24 23:15:34.935: W/dalvikvm(2296): threadid=1: thread exiting with
uncaught exception (group=0x4001d5a0)
02-24 23:15:34.945: E/AndroidRuntime(2296): FATAL EXCEPTION: main
02-24 23:15:34.945: E/AndroidRuntime(2296):
java.lang.ExceptionInInitializerError
02-24 23:15:34.945: E/AndroidRuntime(2296): at
org.opencv.samples.tutorial4.Sample4Mixed.onCreate(Sample4Mixed.java:
35)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1072)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
1785)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
1842)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
android.app.ActivityThread.access$1500(ActivityThread.java:132)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
android.os.Handler.dispatchMessage(Handler.java:99)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
android.os.Looper.loop(Looper.java:150)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
android.app.ActivityThread.main(ActivityThread.java:4263)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
java.lang.reflect.Method.invokeNative(Native Method)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
java.lang.reflect.Method.invoke(Method.java:507)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
dalvik.system.NativeStart.main(Native Method)
02-24 23:15:34.945: E/AndroidRuntime(2296): Caused by:
java.lang.UnsatisfiedLinkError: Couldn't load mixed_sample:
findLibrary returned null
02-24 23:15:34.945: E/AndroidRuntime(2296): at
java.lang.Runtime.loadLibrary(Runtime.java:429)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
java.lang.System.loadLibrary(System.java:554)
02-24 23:15:34.945: E/AndroidRuntime(2296): at
org.opencv.samples.tutorial4.Sample4View.<clinit>(Sample4View.java:91)
02-24 23:15:34.945: E/AndroidRuntime(2296): ... 14 more
02-24 23:20:35.008: I/Process(2296): Sending signal. PID: 2296 SIG: 9
seems like a linking error due to
02-24 23:15:34.935: W/dalvikvm(2296): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/opencv/samples/tutorial4/Sample4View;
check your project settings for the toolchain for the build settings.
this might bring you more information:
http://opencv.itseez.com/doc/tutorials/introduction/android_binary_package/android_binary_package_using_with_NDK.html

Android http-request causes Error - sitting since 3 days

I am sitting since 3 days, looking everywhere on net but it dosnt work ... every time I try to make a http-request on android: it comes the error: unfourtunately, ... has stopped. here my code:
package sd.s;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class SdsdActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Thread trd = new Thread(new Runnable(){
public void run(){
// Creating HTTP client
HttpClient httpClient = new DefaultHttpClient();
// Creating HTTP Post
HttpPost httpPost = new HttpPost(
"http://www.test.com");
// Building post parameters
// key and value pair
List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>(2);
nameValuePair.add(new BasicNameValuePair("test", "test"));
nameValuePair.add(new BasicNameValuePair("message",
"Hi, trying Android HTTP post!"));
// Url Encoding the POST parameters
try {
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair));
} catch (UnsupportedEncodingException e) {
// writing error to Log
e.printStackTrace();
}
// Making HTTP Request
try {
HttpResponse response = httpClient.execute(httpPost);
// writing response to log
Log.d("Http Response:", response.toString());
} catch (ClientProtocolException e) {
// writing exception to log
e.printStackTrace();
} catch (IOException e) {
// writing exception to log
e.printStackTrace();
}
} });
trd.run();
}
}
here my output on LogCat
02-24 17:53:39.003: D/dalvikvm(516): Not late-enabling CheckJNI (already on)
02-24 17:53:40.293: D/AndroidRuntime(516): Shutting down VM
02-24 17:53:40.304: W/dalvikvm(516): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
02-24 17:53:40.313: E/AndroidRuntime(516): FATAL EXCEPTION: main
02-24 17:53:40.313: E/AndroidRuntime(516): java.lang.RuntimeException: Unable to start activity ComponentInfo{sd.s/sd.s.SdsdActivity}: android.os.NetworkOnMainThreadException
02-24 17:53:40.313: E/AndroidRuntime(516): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
02-24 17:53:40.313: E/AndroidRuntime(516): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
02-24 17:53:40.313: E/AndroidRuntime(516): at android.app.ActivityThread.access$600(ActivityThread.java:123)
02-24 17:53:40.313: E/AndroidRuntime(516): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
02-24 17:53:40.313: E/AndroidRuntime(516): at android.os.Handler.dispatchMessage(Handler.java:99)
02-24 17:53:40.313: E/AndroidRuntime(516): at android.os.Looper.loop(Looper.java:137)
02-24 17:53:40.313: E/AndroidRuntime(516): at android.app.ActivityThread.main(ActivityThread.java:4424)
02-24 17:53:40.313: E/AndroidRuntime(516): at java.lang.reflect.Method.invokeNative(Native Method)
02-24 17:53:40.313: E/AndroidRuntime(516): at java.lang.reflect.Method.invoke(Method.java:511)
02-24 17:53:40.313: E/AndroidRuntime(516): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-24 17:53:40.313: E/AndroidRuntime(516): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-24 17:53:40.313: E/AndroidRuntime(516): at dalvik.system.NativeStart.main(Native Method)
02-24 17:53:40.313: E/AndroidRuntime(516): Caused by: android.os.NetworkOnMainThreadException
02-24 17:53:40.313: E/AndroidRuntime(516): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
02-24 17:53:40.313: E/AndroidRuntime(516): at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
02-24 17:53:40.313: E/AndroidRuntime(516): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
02-24 17:53:40.313: E/AndroidRuntime(516): at java.net.InetAddress.getAllByName(InetAddress.java:220)
02-24 17:53:40.313: E/AndroidRuntime(516): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
02-24 17:53:40.313: E/AndroidRuntime(516): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
02-24 17:53:40.313: E/AndroidRuntime(516): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
02-24 17:53:40.313: E/AndroidRuntime(516): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
02-24 17:53:40.313: E/AndroidRuntime(516): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
02-24 17:53:40.313: E/AndroidRuntime(516): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
02-24 17:53:40.313: E/AndroidRuntime(516): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
02-24 17:53:40.313: E/AndroidRuntime(516): at sd.s.SdsdActivity.onCreate(SdsdActivity.java:52)
02-24 17:53:40.313: E/AndroidRuntime(516): at android.app.Activity.performCreate(Activity.java:4465)
02-24 17:53:40.313: E/AndroidRuntime(516): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
02-24 17:53:40.313: E/AndroidRuntime(516): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
02-24 17:53:40.313: E/AndroidRuntime(516): ... 11 more
02-24 17:59:31.783: D/AndroidRuntime(584): Shutting down VM
02-24 17:59:31.783: W/dalvikvm(584): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
02-24 17:59:31.793: E/AndroidRuntime(584): FATAL EXCEPTION: main
02-24 17:59:31.793: E/AndroidRuntime(584): java.lang.RuntimeException: Unable to start activity ComponentInfo{sd.s/sd.s.SdsdActivity}: android.os.NetworkOnMainThreadException
02-24 17:59:31.793: E/AndroidRuntime(584): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
02-24 17:59:31.793: E/AndroidRuntime(584): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
02-24 17:59:31.793: E/AndroidRuntime(584): at android.app.ActivityThread.access$600(ActivityThread.java:123)
02-24 17:59:31.793: E/AndroidRuntime(584): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
02-24 17:59:31.793: E/AndroidRuntime(584): at android.os.Handler.dispatchMessage(Handler.java:99)
02-24 17:59:31.793: E/AndroidRuntime(584): at android.os.Looper.loop(Looper.java:137)
02-24 17:59:31.793: E/AndroidRuntime(584): at android.app.ActivityThread.main(ActivityThread.java:4424)
02-24 17:59:31.793: E/AndroidRuntime(584): at java.lang.reflect.Method.invokeNative(Native Method)
02-24 17:59:31.793: E/AndroidRuntime(584): at java.lang.reflect.Method.invoke(Method.java:511)
02-24 17:59:31.793: E/AndroidRuntime(584): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-24 17:59:31.793: E/AndroidRuntime(584): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-24 17:59:31.793: E/AndroidRuntime(584): at dalvik.system.NativeStart.main(Native Method)
02-24 17:59:31.793: E/AndroidRuntime(584): Caused by: android.os.NetworkOnMainThreadException
02-24 17:59:31.793: E/AndroidRuntime(584): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
02-24 17:59:31.793: E/AndroidRuntime(584): at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
02-24 17:59:31.793: E/AndroidRuntime(584): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
02-24 17:59:31.793: E/AndroidRuntime(584): at java.net.InetAddress.getAllByName(InetAddress.java:220)
02-24 17:59:31.793: E/AndroidRuntime(584): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
02-24 17:59:31.793: E/AndroidRuntime(584): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
02-24 17:59:31.793: E/AndroidRuntime(584): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
02-24 17:59:31.793: E/AndroidRuntime(584): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
02-24 17:59:31.793: E/AndroidRuntime(584): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
02-24 17:59:31.793: E/AndroidRuntime(584): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
02-24 17:59:31.793: E/AndroidRuntime(584): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
02-24 17:59:31.793: E/AndroidRuntime(584): at sd.s.SdsdActivity$1.run(SdsdActivity.java:53)
02-24 17:59:31.793: E/AndroidRuntime(584): at java.lang.Thread.run(Thread.java:856)
02-24 17:59:31.793: E/AndroidRuntime(584): at sd.s.SdsdActivity.onCreate(SdsdActivity.java:66)
02-24 17:59:31.793: E/AndroidRuntime(584): at android.app.Activity.performCreate(Activity.java:4465)
02-24 17:59:31.793: E/AndroidRuntime(584): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
02-24 17:59:31.793: E/AndroidRuntime(584): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
02-24 17:59:31.793: E/AndroidRuntime(584): ... 11 more
02-24 18:08:12.242: D/AndroidRuntime(626): Shutting down VM
02-24 18:08:12.242: W/dalvikvm(626): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
02-24 18:08:12.262: E/AndroidRuntime(626): FATAL EXCEPTION: main
02-24 18:08:12.262: E/AndroidRuntime(626): java.lang.RuntimeException: Unable to start activity ComponentInfo{sd.s/sd.s.SdsdActivity}: android.os.NetworkOnMainThreadException
02-24 18:08:12.262: E/AndroidRuntime(626): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
02-24 18:08:12.262: E/AndroidRuntime(626): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
02-24 18:08:12.262: E/AndroidRuntime(626): at android.app.ActivityThread.access$600(ActivityThread.java:123)
02-24 18:08:12.262: E/AndroidRuntime(626): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
02-24 18:08:12.262: E/AndroidRuntime(626): at android.os.Handler.dispatchMessage(Handler.java:99)
02-24 18:08:12.262: E/AndroidRuntime(626): at android.os.Looper.loop(Looper.java:137)
02-24 18:08:12.262: E/AndroidRuntime(626): at android.app.ActivityThread.main(ActivityThread.java:4424)
02-24 18:08:12.262: E/AndroidRuntime(626): at java.lang.reflect.Method.invokeNative(Native Method)
02-24 18:08:12.262: E/AndroidRuntime(626): at java.lang.reflect.Method.invoke(Method.java:511)
02-24 18:08:12.262: E/AndroidRuntime(626): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-24 18:08:12.262: E/AndroidRuntime(626): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-24 18:08:12.262: E/AndroidRuntime(626): at dalvik.system.NativeStart.main(Native Method)
02-24 18:08:12.262: E/AndroidRuntime(626): Caused by: android.os.NetworkOnMainThreadException
02-24 18:08:12.262: E/AndroidRuntime(626): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
02-24 18:08:12.262: E/AndroidRuntime(626): at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
02-24 18:08:12.262: E/AndroidRuntime(626): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
02-24 18:08:12.262: E/AndroidRuntime(626): at java.net.InetAddress.getAllByName(InetAddress.java:220)
02-24 18:08:12.262: E/AndroidRuntime(626): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
02-24 18:08:12.262: E/AndroidRuntime(626): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
02-24 18:08:12.262: E/AndroidRuntime(626): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
02-24 18:08:12.262: E/AndroidRuntime(626): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
02-24 18:08:12.262: E/AndroidRuntime(626): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
02-24 18:08:12.262: E/AndroidRuntime(626): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
02-24 18:08:12.262: E/AndroidRuntime(626): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
02-24 18:08:12.262: E/AndroidRuntime(626): at sd.s.SdsdActivity$1.run(SdsdActivity.java:53)
02-24 18:08:12.262: E/AndroidRuntime(626): at java.lang.Thread.run(Thread.java:856)
02-24 18:08:12.262: E/AndroidRuntime(626): at sd.s.SdsdActivity.onCreate(SdsdActivity.java:66)
02-24 18:08:12.262: E/AndroidRuntime(626): at android.app.Activity.performCreate(Activity.java:4465)
02-24 18:08:12.262: E/AndroidRuntime(626): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
02-24 18:08:12.262: E/AndroidRuntime(626): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
02-24 18:08:12.262: E/AndroidRuntime(626): ... 11 more
Maybe I am to stupid but since 3 days I trying to get it running, The Applications starts, but stops after start everytime ...
Permission Internet is done and Firewall is np > WebBrowser in emulator works as well, what is wrong? pls - thank you very much for every answer!
You are executing the run() method of your Thread object on the main thread. Replace this:
trd.run();
with this:
trd.start();
As of Android 3.0, you cannot perform this type of request on the main thread.
NetworkOnMainThreadException
Class Overview
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. See the document Designing for Responsiveness.
Also see StrictMode.
See http://developer.android.com/guide/practices/design/responsiveness.html for guidelines on building responsive applications.
From your log, it looks like the error is android.os.NetworkOnMainThreadException. From http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html, it sounds like the error is that you're trying to do network operations in your main thread. Since this can make your UI unresponsive, it's discouraged. And since you seem to be running in strict mode (http://developer.android.com/reference/android/os/StrictMode.html), it's crashing the app.
Also, you should be calling trd.start() instead of trd.run()

cant delete element in sqlite android

Hello i've been googling a lot today with no luck. The thing is that i'm trying to delete an element from my database but i only get 02-24 14:04:32.635: ERROR/AndroidRuntime(8823): android.database.sqlite.SQLiteException: bind or column index out of range: handle 0x327de0
The table in the database has only one column which is an INTEGER PRIMARY KEY and has a TRIGGER like this
CREATE TRIGGER "FavForeignKey" BEFORE INSERT ON Favorites WHEN (SELECT rowid FROM Sign Where Sign.rowid = NEW.ViewedImage) IS NULL BEGIN SELECT RAISE(ROLLBACK, 'insert on table "Favorites" violates foreign key constraint "Sign.rowid"'); END
i don't know why i'm getting this error, i need some help.
**Here is the query i'm using:**
public void deleteFavorite(int imageId){
m_db.delete(FAVORITE_TABLE, FAVORITES_COLUMN_VIEWED_IMAGE, new String[]{""+imageId});
}
And here's the error stack:
02-24 14:04:32.635: ERROR/AndroidRuntime(8823): android.database.sqlite.SQLiteException: bind or column index out of range: handle 0x327de0
02-24 14:04:32.635: ERROR/AndroidRuntime(8823): at android.database.sqlite.SQLiteProgram.native_bind_string(Native Method)
02-24 14:04:32.635: ERROR/AndroidRuntime(8823): at android.database.sqlite.SQLiteProgram.bindString(SQLiteProgram.java:241)
02-24 14:04:32.635: ERROR/AndroidRuntime(8823): at android.database.DatabaseUtils.bindObjectToProgram(DatabaseUtils.java:191)
02-24 14:04:32.635: ERROR/AndroidRuntime(8823): at android.database.sqlite.SQLiteDatabase.delete(SQLiteDatabase.java:1669)
02-24 14:04:32.635: ERROR/AndroidRuntime(8823): at com.enea.takk.database.DBManager.deleteFavorite(DBManager.java:161)
02-24 14:04:32.635: ERROR/AndroidRuntime(8823): at com.enea.takk.views.ShowImage$1.onClick(ShowImage.java:82)
02-24 14:04:32.635: ERROR/AndroidRuntime(8823): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:158)
02-24 14:04:32.635: ERROR/AndroidRuntime(8823): at android.os.Handler.dispatchMessage(Handler.java:99)
02-24 14:04:32.635: ERROR/AndroidRuntime(8823): at android.os.Looper.loop(Looper.java:144)
02-24 14:04:32.635: ERROR/AndroidRuntime(8823): at android.app.ActivityThread.main(ActivityThread.java:4937)
02-24 14:04:32.635: ERROR/AndroidRuntime(8823): at java.lang.reflect.Method.invokeNative(Native Method)
02-24 14:04:32.635: ERROR/AndroidRuntime(8823): at java.lang.reflect.Method.invoke(Method.java:521)
02-24 14:04:32.635: ERROR/AndroidRuntime(8823): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-24 14:04:32.635: ERROR/AndroidRuntime(8823): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-24 14:04:32.635: ERROR/AndroidRuntime(8823): at dalvik.system.NativeStart.main(Native Method)
Some help will be appreciated.
Thanks in advance
try this
public void deleteFavorite(int imageId){
m_db.delete(FAVORITE_TABLE, FAVORITES_COLUMN_VIEWED_IMAGE + "=" +imageId,null);
}

Categories

Resources