I have one Activity and 4 tab Activities.In each tab activity i have gallery , grid layout when i am coming back from tab-activities to my main Activity i am getting outofMemory exception.In my all tab activities i have lot of images.I have strucked from 5 day .Please help me.Here my logcat is:
07-30 17:28:42.375: I/dalvikvm-heap(18784): Forcing collection of SoftReferences for 16384016-byte allocation
07-30 17:28:42.406: D/dalvikvm(18784): GC_BEFORE_OOM freed 1K, 34% free 40614K/61511K, paused 29ms, total 30ms
07-30 17:28:42.406:
E/dalvikvm-heap(18784): Out of memory on a 16384016-byte allocation.
07-30 17:28:42.406: I/dalvikvm(18784): "main" prio=5 tid=1 RUNNABLE
07-30 17:28:42.406: I/dalvikvm(18784):
| group="main" sCount=0 dsCount=0 obj=0x41f726a0 self=0x41f5f018
07-30 17:28:42.406: I/dalvikvm(18784):
| sysTid=18784 nice=0 sched=0/0 cgrp=apps handle=1075198032
07-30 17:28:42.406: I/dalvikvm(18784):
| schedstat=( 0 0 0 ) utm=219 stm=55 core=0
07-30 17:28:42.406: I/dalvikvm(18784):
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
07-30 17:28:42.406: I/dalvikvm(18784):
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:592)
07-30 17:28:42.406: I/dalvikvm(18784):
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
07-30 17:28:42.406: I/dalvikvm(18784):
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
07-30 17:28:42.406:
I/dalvikvm(18784): at android.content.res.Resources.loadDrawable(Resources.java:1963)
07-30 17:28:42.406:
I/dalvikvm(18784): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
07-30 17:28:42.406: I/dalvikvm(18784): at android.view.View.<init>(View.java:3419)
07-30 17:28:42.406: I/dalvikvm(18784): at android.view.View.<init>(View.java:3352)
07-30 17:28:42.406: I/dalvikvm(18784): at android.view.ViewGroup.<init>(ViewGroup.java:426)
07-30 17:28:42.406: I/dalvikvm(18784): at android.widget.RelativeLayout.<init>(RelativeLayout.java:184)
07-30 17:28:42.406: I/dalvikvm(18784): at java.lang.reflect.Constructor.constructNative(Native Method)
07-30 17:28:42.406: I/dalvikvm(18784): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
07-30 17:28:42.406: I/dalvikvm(18784): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
07-30 17:28:42.406: I/dalvikvm(18784): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
07-30 17:28:42.406: I/dalvikvm(18784): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
07-30 17:28:42.406: I/dalvikvm(18784): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
07-30 17:28:42.416: I/dalvikvm(18784): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
07-30 17:28:42.416: I/dalvikvm(18784): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
07-30 17:28:42.416: I/dalvikvm(18784): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
07-30 17:28:42.416: I/dalvikvm(18784): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:306)
07-30 17:28:42.416: I/dalvikvm(18784): at android.app.Activity.setContentView(Activity.java:1901)
07-30 17:28:42.416: I/dalvikvm(18784): at com.inventit.commentu.CommentU_Activity.onCreate(CommentU_Activity.java:182)
07-30 17:28:42.416: I/dalvikvm(18784): at android.app.Activity.performCreate(Activity.java:5048)
07-30 17:28:42.416: I/dalvikvm(18784): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
07-30 17:28:42.416: I/dalvikvm(18784): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2052)
07-30 17:28:42.416: I/dalvikvm(18784): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2113)
07-30 17:28:42.416: I/dalvikvm(18784): at android.app.ActivityThread.access$700(ActivityThread.java:139)
07-30 17:28:42.416: I/dalvikvm(18784): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1224)
07-30 17:28:42.416: I/dalvikvm(18784): at android.os.Handler.dispatchMessage(Handler.java:99)
07-30 17:28:42.416: I/dalvikvm(18784): at android.os.Looper.loop(Looper.java:137)
07-30 17:28:42.416: I/dalvikvm(18784): at android.app.ActivityThread.main(ActivityThread.java:4918)
07-30 17:28:42.416: I/dalvikvm(18784): at java.lang.reflect.Method.invokeNative(Native Method)
07-30 17:28:42.416: I/dalvikvm(18784): at java.lang.reflect.Method.invoke(Method.java:511)
07-30 17:28:42.416: I/dalvikvm(18784): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
07-30 17:28:42.416: I/dalvikvm(18784): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
07-30 17:28:42.416: I/dalvikvm(18784): at dalvik.system.NativeStart.main(Native Method)
07-30 17:28:42.416: A/libc(18784): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 18784 (ventit.commentu)
07-30 17:28:42.416: A/libc(18784): Fatal signal 11 (SIGSEGV) at 0x007d0000 (code=1), thread 18799 (ventit.commentu)
07-30 17:28:50.154: E/Trace(18971): error opening trace file: No such file or directory (2)
07-30 17:28:50.154: D/ActivityThread(18971): setTargetHeapUtilization:0.25
07-30 17:28:50.154: D/ActivityThread(18971): setTargetHeapIdealFree:8388608
07-30 17:28:50.154: D/ActivityThread(18971): setTargetHeapConcurrentStart:2097152
07-30 17:28:50.294: D/dalvikvm(18971): GC_FOR_ALLOC freed 76K, 23% free 16129K/20931K, paused 16ms, total 17ms
07-30 17:28:50.334: I/dalvikvm-heap(18971): Grow heap (frag case) to 40.043MB for 16384016-byte allocation
Thanking in Advance.
Check the Managing Bitmap Memory article from developers site.
For API<=10:
On Android 2.3.3 (API level 10) and lower, using recycle() is recommended. If you're displaying large amounts of bitmap data in your app, you're likely to run into OutOfMemoryError errors. The recycle() method allows an app to reclaim memory as soon as possible.
Caution: You should use recycle() only when you are sure that the bitmap is no longer being used. If you call recycle() and later attempt to draw the bitmap, you will get the error: "Canvas: trying to use a recycled bitmap".
The following code snippet gives an example of calling recycle(). It uses reference counting (in the variables mDisplayRefCount and mCacheRefCount) to track whether a bitmap is currently being displayed or in the cache. The code recycles the bitmap when these conditions are met:
The reference count for both mDisplayRefCount and mCacheRefCount is 0.
The bitmap is not null, and it hasn't been recycled yet.
For API>=11:
Android 3.0 (API Level 11) introduces the BitmapFactory.Options.inBitmap field. If this option is set, decode methods that take the Options object will attempt to reuse an existing bitmap when loading content. This means that the bitmap's memory is reused, resulting in improved performance, and removing both memory allocation and de-allocation.
Related
My application crashes on Android 4.2 because of Cordova/Phonegap SplashScreen plugin!
My app total size is: 5mb and I'm using the default splash screens of PhoneGap!! I tested the application on an Emulator and on a device and getting the same problem, the app crashes
Cordova version:
3.5.0-0.2.6
Plugins list:
com.adobe.plugins.GAPlugin 2.3.1 "GAPlugin"
com.google.playservices 18.0.0 "Google Play Services for Android"
com.ionic.keyboard 1.0.2 "Keyboard"
com.phonegap.plugins.barcodescanner 2.0.0 "BarcodeScanner"
com.postmedia.DFPPlugin 0.0.2 "DFPPlugin"
com.pushwoosh.plugins.pushwoosh 3.2.0 "Pushwoosh"
it.mobimentum.phonegapspinnerplugin 1.1.0 "SpinnerPlugin"
nl.x-services.plugins.socialsharing 4.3.0 "SocialSharing"
org.apache.cordova.console 0.2.9 "Console"
org.apache.cordova.device 0.2.10 "Device"
org.apache.cordova.dialogs 0.2.8 "Notification"
org.apache.cordova.globalization 0.2.8 "Globalization"
org.apache.cordova.inappbrowser 0.5.0 "InAppBrowser"
org.apache.cordova.network-information 0.2.10 "Network Information"
org.apache.cordova.splashscreen 0.3.1 "Splashscreen"
org.apache.cordova.statusbar 0.1.6 "StatusBar"
org.pushandplay.cordova.apprate 0.0.23 "AppRate"
Here is the log from eclipse logcat:
08-02 12:11:57.279: D/dalvikvm(3599): GC_FOR_ALLOC freed 3K, 1% free 42575K/42744K, paused 2ms, total 2ms
08-02 12:11:57.279: I/dalvikvm-heap(3599): Forcing collection of SoftReferences for 92174412-byte allocation
08-02 12:11:57.289: D/dalvikvm(3599): GC_BEFORE_OOM freed 9K, 1% free 42566K/42744K, paused 11ms, total 11ms
08-02 12:11:57.289: E/dalvikvm-heap(3599): Out of memory on a 92174412-byte allocation.
08-02 12:11:57.289: I/dalvikvm(3599): "main" prio=5 tid=1 RUNNABLE
08-02 12:11:57.289: I/dalvikvm(3599): | group="main" sCount=0 dsCount=0 obj=0xb2d37938 self=0xb81d4e80
08-02 12:11:57.289: I/dalvikvm(3599): | sysTid=3599 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=-1208110944
08-02 12:11:57.289: I/dalvikvm(3599): | state=R schedstat=( 0 0 0 ) utm=13 stm=3 core=0
08-02 12:11:57.299: I/dalvikvm(3599): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
08-02 12:11:57.299: I/dalvikvm(3599): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
08-02 12:11:57.299: I/dalvikvm(3599): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
08-02 12:11:57.299: I/dalvikvm(3599): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
08-02 12:11:57.299: I/dalvikvm(3599): at android.content.res.Resources.loadDrawable(Resources.java:1965)
08-02 12:11:57.299: I/dalvikvm(3599): at android.content.res.Resources.getDrawable(Resources.java:660)
08-02 12:11:57.299: I/dalvikvm(3599): at android.view.View.setBackgroundResource(View.java:14463)
08-02 12:11:57.299: I/dalvikvm(3599): at org.apache.cordova.CordovaActivity$5.run(CordovaActivity.java:1070)
08-02 12:11:57.299: I/dalvikvm(3599): at android.app.Activity.runOnUiThread(Activity.java:4644)
08-02 12:11:57.299: I/dalvikvm(3599): at org.apache.cordova.CordovaActivity.showSplashScreen(CordovaActivity.java:1093)
08-02 12:11:57.299: I/dalvikvm(3599): at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:370)
08-02 12:11:57.299: I/dalvikvm(3599): at com.bkam.Bkam.onCreate(Bkam.java:33)
08-02 12:11:57.299: I/dalvikvm(3599): at android.app.Activity.performCreate(Activity.java:5104)
08-02 12:11:57.299: I/dalvikvm(3599): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
08-02 12:11:57.299: I/dalvikvm(3599): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
08-02 12:11:57.299: I/dalvikvm(3599): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
08-02 12:11:57.299: I/dalvikvm(3599): at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-02 12:11:57.299: I/dalvikvm(3599): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
08-02 12:11:57.299: I/dalvikvm(3599): at android.os.Handler.dispatchMessage(Handler.java:99)
08-02 12:11:57.299: I/dalvikvm(3599): at android.os.Looper.loop(Looper.java:137)
08-02 12:11:57.299: I/dalvikvm(3599): at android.app.ActivityThread.main(ActivityThread.java:5039)
08-02 12:11:57.299: I/dalvikvm(3599): at java.lang.reflect.Method.invokeNative(Native Method)
08-02 12:11:57.299: I/dalvikvm(3599): at java.lang.reflect.Method.invoke(Method.java:511)
08-02 12:11:57.299: I/dalvikvm(3599): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
08-02 12:11:57.299: I/dalvikvm(3599): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
08-02 12:11:57.299: I/dalvikvm(3599): at dalvik.system.NativeStart.main(Native Method)
08-02 12:11:57.299: D/skia(3599): --- allocation failed for scaled bitmap
08-02 12:11:57.299: D/AndroidRuntime(3599): Shutting down VM
08-02 12:11:57.299: W/dalvikvm(3599): threadid=1: thread exiting with uncaught exception (group=0xb2d36908)
08-02 12:11:57.309: E/AndroidRuntime(3599): FATAL EXCEPTION: main
08-02 12:11:57.309: E/AndroidRuntime(3599): java.lang.OutOfMemoryError
08-02 12:11:57.309: E/AndroidRuntime(3599): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
08-02 12:11:57.309: E/AndroidRuntime(3599): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
08-02 12:11:57.309: E/AndroidRuntime(3599): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
08-02 12:11:57.309: E/AndroidRuntime(3599): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
08-02 12:11:57.309: E/AndroidRuntime(3599): at android.content.res.Resources.loadDrawable(Resources.java:1965)
08-02 12:11:57.309: E/AndroidRuntime(3599): at android.content.res.Resources.getDrawable(Resources.java:660)
08-02 12:11:57.309: E/AndroidRuntime(3599): at android.view.View.setBackgroundResource(View.java:14463)
08-02 12:11:57.309: E/AndroidRuntime(3599): at org.apache.cordova.CordovaActivity$5.run(CordovaActivity.java:1070)
08-02 12:11:57.309: E/AndroidRuntime(3599): at android.app.Activity.runOnUiThread(Activity.java:4644)
08-02 12:11:57.309: E/AndroidRuntime(3599): at org.apache.cordova.CordovaActivity.showSplashScreen(CordovaActivity.java:1093)
08-02 12:11:57.309: E/AndroidRuntime(3599): at org.apache.cordova.CordovaActivity.loadUrl(CordovaActivity.java:370)
08-02 12:11:57.309: E/AndroidRuntime(3599): at com.bkam.Bkam.onCreate(Bkam.java:33)
08-02 12:11:57.309: E/AndroidRuntime(3599): at android.app.Activity.performCreate(Activity.java:5104)
08-02 12:11:57.309: E/AndroidRuntime(3599): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
08-02 12:11:57.309: E/AndroidRuntime(3599): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
08-02 12:11:57.309: E/AndroidRuntime(3599): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
08-02 12:11:57.309: E/AndroidRuntime(3599): at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-02 12:11:57.309: E/AndroidRuntime(3599): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
08-02 12:11:57.309: E/AndroidRuntime(3599): at android.os.Handler.dispatchMessage(Handler.java:99)
08-02 12:11:57.309: E/AndroidRuntime(3599): at android.os.Looper.loop(Looper.java:137)
08-02 12:11:57.309: E/AndroidRuntime(3599): at android.app.ActivityThread.main(ActivityThread.java:5039)
08-02 12:11:57.309: E/AndroidRuntime(3599): at java.lang.reflect.Method.invokeNative(Native Method)
08-02 12:11:57.309: E/AndroidRuntime(3599): at java.lang.reflect.Method.invoke(Method.java:511)
08-02 12:11:57.309: E/AndroidRuntime(3599): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
08-02 12:11:57.309: E/AndroidRuntime(3599): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
08-02 12:11:57.309: E/AndroidRuntime(3599): at dalvik.system.NativeStart.main(Native Method)
I'm getting an ANR that seems to be from Toast.makeText:
DALVIK THREADS: (mutexes: tll=0 tsl=0 tscl=0 ghl=0 hwl=0 hwll=0)
"main" prio=5 tid=1 SUSPENDED | group="main" sCount=1 dsCount=0
obj=0x40163600 self=0x12620 | sysTid=4197 nice=0 sched=0/0
cgrp=default handle=-1345338264 | schedstat=( 149532214000 43042125000
324000 ) utm=13923 stm=1030 core=0 at
android.graphics.Matrix.native_create(Native Method) at
android.graphics.Matrix.(Matrix.java:49) at
android.view.View.(View.java:1852) at
android.view.View.(View.java:2411) at
android.view.ViewGroup.(ViewGroup.java:365) at
android.widget.LinearLayout.(LinearLayout.java:156) at
android.widget.LinearLayout.(LinearLayout.java:152) at
java.lang.reflect.Constructor.constructNative(Native Method) at
java.lang.reflect.Constructor.newInstance(Constructor.java:416) at
android.view.LayoutInflater.createView(LayoutInflater.java:576) at
com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:644)
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
at android.view.LayoutInflater.inflate(LayoutInflater.java:457) at
android.view.LayoutInflater.inflate(LayoutInflater.java:391) at
android.view.LayoutInflater.inflate(LayoutInflater.java:347) at
android.widget.Toast.makeText(Toast.java:230) at
android.widget.Toast.makeText(Toast.java:253) at
com.anthonymandra.framework.ViewerActivity.onActivityResult(ViewerActivity.java:802)
at android.app.Activity.dispatchActivityResult(Activity.java:4581) at
android.app.ActivityThread.deliverResults(ActivityThread.java:2814) at
android.app.ActivityThread.handleSendResult(ActivityThread.java:2861)
at android.app.ActivityThread.access$1000(ActivityThread.java:122) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054)
at android.os.Handler.dispatchMessage(Handler.java:99) at
android.os.Looper.loop(Looper.java:132) at
android.app.ActivityThread.main(ActivityThread.java:4123) at
java.lang.reflect.Method.invokeNative(Native Method) at
java.lang.reflect.Method.invoke(Method.java:491) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) at
dalvik.system.NativeStart.main(Native Method)
This is the line of code called from within onActivityResult:
Toast.makeText(this, R.string.save_success, Toast.LENGTH_SHORT).show();
Anyone know why a Toast might cause an ANR, or what might really be wrong if I'm misreading this? Thanks!
Instead of using direct call to R.string, you should use getResources() and then like below
String strSuccess = getString(R.string.save_success);
Toast.makeText(this, strSuccess, Toast.LENGTH_SHORT).show();
or
Toast.makeText(this, getString(R.string.save_success),Toast.LENGTH_SHORT).show();
Read more
I am using FragmentActivity in my application with several Fragments. Each of these fragments hold an image and some text with animation. When user swipes on the screen, the fragment changes.
Now I have been working on this since 10 days and have tested the FragmentActivity on different devices with different Android versions. The reason that I am stuck on this from last 10 days is I am getting a crash
Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 27830 (ple.myfragexample)
Now, this error occurs only when I test the FragmentActivity on Android 4.1.2 particularly. It would run fine on Android 2.3.3, 4.0.3, 4.0.4, 4.2 and even 2.2. The error log is as below:
08-07 14:34:13.843: D/dalvikvm(27830): GC_FOR_ALLOC freed 3845K, 14% free 35407K/40903K, paused 4ms, total 14ms
08-07 14:34:13.848: I/dalvikvm-heap(27830): Grow heap (frag case) to 39.590MB for 3932176-byte allocation
08-07 14:34:13.878: D/dalvikvm(27830): GC_CONCURRENT freed 3K, 5% free 39244K/40903K, paused 11ms+4ms, total 30ms
08-07 14:34:13.928: D/dalvikvm(27830): GC_FOR_ALLOC freed 0K, 5% free 39244K/40903K, paused 16ms, total 16ms
08-07 14:34:13.928: I/dalvikvm-heap(27830): Forcing collection of SoftReferences for 8847376-byte allocation
08-07 14:34:13.953: D/dalvikvm(27830): GC_BEFORE_OOM freed 9K, 5% free 39235K/40903K, paused 24ms, total 24ms
08-07 14:34:13.953: E/dalvikvm-heap(27830): Out of memory on a 8847376-byte allocation.
08-07 14:34:13.953: I/dalvikvm(27830): "main" prio=5 tid=1 RUNNABLE
08-07 14:34:13.953: I/dalvikvm(27830): | group="main" sCount=0 dsCount=0 obj=0x41ea8508 self=0x41e989c8
08-07 14:34:13.953: I/dalvikvm(27830): | sysTid=27830 nice=0 sched=0/0 cgrp=apps handle=1074937648
08-07 14:34:13.953: I/dalvikvm(27830): | schedstat=( 2591504030 1697770606 13588 ) utm=221 stm=38 core=0
08-07 14:34:13.953: I/dalvikvm(27830): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
08-07 14:34:13.953: I/dalvikvm(27830): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:625)
08-07 14:34:13.953: I/dalvikvm(27830): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:478)
08-07 14:34:13.953: I/dalvikvm(27830): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
08-07 14:34:13.953: I/dalvikvm(27830): at android.content.res.Resources.loadDrawable(Resources.java:1963)
08-07 14:34:13.953: I/dalvikvm(27830): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.View.<init>(View.java:3449)
08-07 14:34:13.953: I/dalvikvm(27830): at android.widget.ImageView.<init>(ImageView.java:114)
08-07 14:34:13.953: I/dalvikvm(27830): at android.widget.ImageView.<init>(ImageView.java:110)
08-07 14:34:13.953: I/dalvikvm(27830): at java.lang.reflect.Constructor.constructNative(Native Method)
08-07 14:34:13.953: I/dalvikvm(27830): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
08-07 14:34:13.953: I/dalvikvm(27830): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
08-07 14:34:13.953: I/dalvikvm(27830): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
08-07 14:34:13.953: I/dalvikvm(27830): at com.example.myfragexample.pages.Page6.onCreateView(Page6.java:52)
08-07 14:34:13.953: I/dalvikvm(27830): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
08-07 14:34:13.953: I/dalvikvm(27830): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:911)
08-07 14:34:13.953: I/dalvikvm(27830): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
08-07 14:34:13.953: I/dalvikvm(27830): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
08-07 14:34:13.953: I/dalvikvm(27830): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
08-07 14:34:13.953: I/dalvikvm(27830): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
08-07 14:34:13.953: I/dalvikvm(27830): at android.os.Handler.handleCallback(Handler.java:615)
08-07 14:34:13.953: I/dalvikvm(27830): at android.os.Handler.dispatchMessage(Handler.java:92)
08-07 14:34:13.953: I/dalvikvm(27830): at android.os.Looper.loop(Looper.java:137)
08-07 14:34:13.953: I/dalvikvm(27830): at android.app.ActivityThread.main(ActivityThread.java:4921)
08-07 14:34:13.953: I/dalvikvm(27830): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 14:34:13.953: I/dalvikvm(27830): at java.lang.reflect.Method.invoke(Method.java:511)
08-07 14:34:13.953: I/dalvikvm(27830): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
08-07 14:34:13.953: I/dalvikvm(27830): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
08-07 14:34:13.953: I/dalvikvm(27830): at dalvik.system.NativeStart.main(Native Method)
08-07 14:34:13.953: A/libc(27830): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 27830 (ple.myfragexample)
I have searched a lot over the internet and tried many thing about this, however, the working of my Fragments got smoother on devices with any other version of Android, but just on Android 4.1.2. I also tried to use Universal Image Loader, but it still crashes with Fatal signal 11. The error log I get when I am using Universal Image Loader is as below:
08-07 14:20:03.678: D/dalvikvm(27268): GC_FOR_ALLOC freed 3857K, 32% free 33002K/48455K, paused 31ms, total 34ms
08-07 14:20:03.678: I/dalvikvm-heap(27268): Grow heap (frag case) to 37.241MB for 3932176-byte allocation
08-07 14:20:03.708: D/dalvikvm(27268): GC_FOR_ALLOC freed 5K, 24% free 36837K/48455K, paused 28ms, total 28ms
08-07 14:20:03.738: D/dalvikvm(27268): GC_CONCURRENT freed <1K, 24% free 36837K/48455K, paused 11ms+2ms, total 30ms
08-07 14:20:03.848: D/dalvikvm(27268): GC_FOR_ALLOC freed <1K, 24% free 36837K/48455K, paused 17ms, total 17ms
08-07 14:20:03.848: I/dalvikvm-heap(27268): Forcing collection of SoftReferences for 8847376-byte allocation
08-07 14:20:03.883: D/dalvikvm(27268): GC_BEFORE_OOM freed 9K, 24% free 36828K/48455K, paused 32ms, total 35ms
08-07 14:20:03.883: E/dalvikvm-heap(27268): Out of memory on a 8847376-byte allocation.
08-07 14:20:03.888: I/dalvikvm(27268): "pool-1-thread-1" prio=4 tid=12 RUNNABLE
08-07 14:20:03.888: I/dalvikvm(27268): | group="main" sCount=0 dsCount=0 obj=0x4293af60 self=0x4f6c9470
08-07 14:20:03.888: I/dalvikvm(27268): | sysTid=27283 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1098606736
08-07 14:20:03.888: I/dalvikvm(27268): | schedstat=( 2735922613 2106917058 1146 ) utm=266 stm=7 core=0
08-07 14:20:03.888: I/dalvikvm(27268): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
08-07 14:20:03.888: I/dalvikvm(27268): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:625)
08-07 14:20:03.888: I/dalvikvm(27268): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:478)
08-07 14:20:03.888: I/dalvikvm(27268): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
08-07 14:20:03.888: I/dalvikvm(27268): at android.content.res.Resources.loadDrawable(Resources.java:1963)
08-07 14:20:03.888: I/dalvikvm(27268): at android.content.res.Resources.getDrawable(Resources.java:672)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStreamFromDrawable(BaseImageDownloader.java:184)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStream(BaseImageDownloader.java:84)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.decode.BaseImageDecoder.getImageStream(BaseImageDecoder.java:82)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.decode.BaseImageDecoder.decode(BaseImageDecoder.java:68)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.decodeImage(LoadAndDisplayImageTask.java:284)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:243)
08-07 14:20:03.888: I/dalvikvm(27268): at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:125)
08-07 14:20:03.888: I/dalvikvm(27268): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
08-07 14:20:03.888: I/dalvikvm(27268): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
08-07 14:20:03.888: I/dalvikvm(27268): at java.lang.Thread.run(Thread.java:856)
08-07 14:20:03.888: A/libc(27268): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 27283 (pool-1-thread-1)
Now, I know there are lots of questions with Fatal signal 11 on here too, but I am concerned and confused as I am getting this crash only on Android 4.1.2 and not on any other Android versions.
My issue is solved now. I just got my images re-sized from my Graphics team. Previously I was using 1280x768 resolution images but I got them scaled down to 800x480 and the crash is gone. Thanks for all the suggestions though.
Also, I think Jelly Bean (4.x) has enhanced UI and so, it occupies more memory for handling the UI itself than the lower versions of Android, and that's why it was not able to manage handling(scaling down) the larger images.
Have a look at my question:
Strange crash drawing on canvas on Android 4.0.3. A/libc: Fatal signal 11 (SIGSEGV)
maybe it's the same problem. The issue arises when I try to use a small number for stroke or others Paint properties.
setStrokeWidth(0.007f);
Never solved, I suggest to scale the Canvas and use bigger numbers.
Check this MOCKUP of my application :
PROBLEM :
If I click on SECOND PAGE button from FIRST PAGE, it open new intent of SECOND PAGE
Then
I click on THIRD PAGE button from SECOND PAGE, then it goes to THIRD PAGE
Then
I again goes to FIRST PAGE by using FIRST PAGE BUTTON then CRASH THE APPLICATION by giving below error "Out of memory on ...."
ERROR :
05-13 11:35:06.417: D/dalvikvm(11948): GC_BEFORE_OOM freed 9K, 19% free 39660K/48583K, paused 36ms, total 36ms
05-13 11:35:06.417: E/dalvikvm-heap(11948): Out of memory on a 8684816-byte allocation.
05-13 11:35:06.425: I/dalvikvm(11948): "main" prio=5 tid=1 RUNNABLE
05-13 11:35:06.425: I/dalvikvm(11948): | group="main" sCount=0 dsCount=0 obj=0x40f01508 self=0x40d41a18
05-13 11:35:06.425: I/dalvikvm(11948): | sysTid=11948 nice=0 sched=0/0 cgrp=apps handle=1074921264
05-13 11:35:06.425: I/dalvikvm(11948): | schedstat=( 5318603531 1290588360 5684 ) utm=446 stm=85 core=0
05-13 11:35:06.425: I/dalvikvm(11948): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
05-13 11:35:06.425: I/dalvikvm(11948): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:592)
05-13 11:35:06.425: I/dalvikvm(11948): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
05-13 11:35:06.425: I/dalvikvm(11948): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
05-13 11:35:06.425: I/dalvikvm(11948): at android.content.res.Resources.loadDrawable(Resources.java:1963)
05-13 11:35:06.425: I/dalvikvm(11948): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
05-13 11:35:06.425: I/dalvikvm(11948): at android.view.View.<init>(View.java:3443)
05-13 11:35:06.425: I/dalvikvm(11948): at android.view.View.<init>(View.java:3376)
05-13 11:35:06.425: I/dalvikvm(11948): at android.view.ViewGroup.<init>(ViewGroup.java:426)
05-13 11:35:06.425: I/dalvikvm(11948): at android.widget.RelativeLayout.<init>(RelativeLayout.java:184)
05-13 11:35:06.425: I/dalvikvm(11948): at java.lang.reflect.Constructor.constructNative(Native Method)
05-13 11:35:06.425: I/dalvikvm(11948): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
05-13 11:35:06.433: I/dalvikvm(11948): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
05-13 11:35:06.433: I/dalvikvm(11948): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
05-13 11:35:06.433: I/dalvikvm(11948): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
05-13 11:35:06.433: I/dalvikvm(11948): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
05-13 11:35:06.433: I/dalvikvm(11948): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
05-13 11:35:06.433: I/dalvikvm(11948): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
05-13 11:35:06.433: I/dalvikvm(11948): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
05-13 11:35:06.433: I/dalvikvm(11948): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
05-13 11:35:06.433: I/dalvikvm(11948): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-13 11:35:06.433: I/dalvikvm(11948): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-13 11:35:06.433: I/dalvikvm(11948): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:306)
05-13 11:35:06.433: I/dalvikvm(11948): at android.app.Activity.setContentView(Activity.java:1912)
05-13 11:35:06.440: I/dalvikvm(11948): at com.mca.LastingPowerActivity.onCreate(LastingPowerActivity.java:24)
05-13 11:35:06.440: I/dalvikvm(11948): at android.app.Activity.performCreate(Activity.java:5163)
05-13 11:35:06.440: I/dalvikvm(11948): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
05-13 11:35:06.440: I/dalvikvm(11948): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
05-13 11:35:06.440: I/dalvikvm(11948): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
05-13 11:35:06.440: I/dalvikvm(11948): at android.app.ActivityThread.access$600(ActivityThread.java:140)
05-13 11:35:06.440: I/dalvikvm(11948): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
05-13 11:35:06.440: I/dalvikvm(11948): at android.os.Handler.dispatchMessage(Handler.java:99)
05-13 11:35:06.440: I/dalvikvm(11948): at android.os.Looper.loop(Looper.java:137)
05-13 11:35:06.440: I/dalvikvm(11948): at android.app.ActivityThread.main(ActivityThread.java:4895)
05-13 11:35:06.440: I/dalvikvm(11948): at java.lang.reflect.Method.invokeNative(Native Method)
05-13 11:35:06.440: I/dalvikvm(11948): at java.lang.reflect.Method.invoke(Method.java:511)
05-13 11:35:06.440: I/dalvikvm(11948): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
05-13 11:35:06.440: I/dalvikvm(11948): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
05-13 11:35:06.440: I/dalvikvm(11948): at dalvik.system.NativeStart.main(Native Method)
05-13 11:35:06.440: D/skia(11948): --- decoder->decode returned false
05-13 11:35:06.440: D/AndroidRuntime(11948): Shutting down VM
05-13 11:35:06.440: W/dalvikvm(11948): threadid=1: thread exiting with uncaught exception (group=0x40f002a0)
05-13 11:35:06.456: E/AndroidRuntime(11948): FATAL EXCEPTION: main
05-13 11:35:06.456: E/AndroidRuntime(11948): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mca/com.mca.LastingPowerActivity}: android.view.InflateException: Binary XML file line #18: Error inflating class <unknown>
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2122)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.app.ActivityThread.access$600(ActivityThread.java:140)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1228)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.os.Handler.dispatchMessage(Handler.java:99)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.os.Looper.loop(Looper.java:137)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.app.ActivityThread.main(ActivityThread.java:4895)
05-13 11:35:06.456: E/AndroidRuntime(11948): at java.lang.reflect.Method.invokeNative(Native Method)
05-13 11:35:06.456: E/AndroidRuntime(11948): at java.lang.reflect.Method.invoke(Method.java:511)
05-13 11:35:06.456: E/AndroidRuntime(11948): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
05-13 11:35:06.456: E/AndroidRuntime(11948): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
05-13 11:35:06.456: E/AndroidRuntime(11948): at dalvik.system.NativeStart.main(Native Method)
05-13 11:35:06.456: E/AndroidRuntime(11948): Caused by: android.view.InflateException: Binary XML file line #18: Error inflating class <unknown>
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
05-13 11:35:06.456: E/AndroidRuntime(11948): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-13 11:35:06.456: E/AndroidRuntime(11948): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:306)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.app.Activity.setContentView(Activity.java:1912)
05-13 11:35:06.456: E/AndroidRuntime(11948): at com.mca.LastingPowerActivity.onCreate(LastingPowerActivity.java:24)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.app.Activity.performCreate(Activity.java:5163)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2061)
05-13 11:35:06.456: E/AndroidRuntime(11948): ... 11 more
05-13 11:35:06.456: E/AndroidRuntime(11948): Caused by: java.lang.reflect.InvocationTargetException
05-13 11:35:06.456: E/AndroidRuntime(11948): at java.lang.reflect.Constructor.constructNative(Native Method)
05-13 11:35:06.456: E/AndroidRuntime(11948): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
05-13 11:35:06.456: E/AndroidRuntime(11948): ... 26 more
05-13 11:35:06.456: E/AndroidRuntime(11948): Caused by: java.lang.OutOfMemoryError
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:592)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.content.res.Resources.loadDrawable(Resources.java:1963)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.view.View.<init>(View.java:3443)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.view.View.<init>(View.java:3376)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.view.ViewGroup.<init>(ViewGroup.java:426)
05-13 11:35:06.456: E/AndroidRuntime(11948): at android.widget.RelativeLayout.<init>(RelativeLayout.java:184)
05-13 11:35:06.456: E/AndroidRuntime(11948): ... 29 more
If anybody knows then share your answers, so that I can resolve it.
Thank you.
Ensure that you are reusing activities from application's stack and not creating a new instance of an Activity every time. If that is not the case then the application's stack will surely run out of memory.
I am also facing same problem and what I am doing is following.
When your activity leave its state and go to other activity, it calls "onStop()" after successfully start activity2. So do this
#Override
protected void onStop()
{
relativeLayout.setBackgroundDrawable(null);
}
When you close your activity2 and come back to activity1, "onResume() will call. So do this,
#Override
protected void onResume()
{
relativeLayout.setBackgroundResource(R.drawable.home_bg);
}
This will solve your problem.
Two solution I like to mention first if you are using not much heavy images add android:largeHeap="true" in your AndroidManifest.xml.
or
load your bitmaps using Outofmemory solution link and recycle that bitmap while switching activities. Its common problem and its solution provide in stackoverflow multiple times.
It would probably the best if you went through the existing questions answers see if yours matches with some of existing ones, then if not, write up what makes your situation different.
Strange out of memory issue while loading an image to a Bitmap object
Out of memory exception due to large bitmap size
Android handling out of memory exception on image processing
to keep heap size at minimum ;
when you return from 3rd page you can use code below which will clear activities.
Intent intent = new Intent(getActivity(), MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);//to clear previous activities
startActivity(intent);
or you can use to clear activity.
finish();
or you can just pass context instead of creating new one
Activity a = (Activity) getContext();
or you can use fragments.
You must unload your texture atlases and reload them again if required, otherwise it is definitely going to generate out of memory error.
Here is how you can unload your texture to release memory:
// all the textures you think are big
Engine.getTextureManager().unloadTexture(bg);
bg.clearTextureAtlasSources();
System.gc();
I hope it will help solving your problem.
I configured ActiveAndroid at AndroidManifest.xml as described below:
<application
android:name="com.xxx.xxxx.XXXApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
<meta-data
android:name="AA_DB_NAME"
android:value="MyDB.db" />
<meta-data
android:name="AA_DB_VERSION"
android:value="2" />
...
</application>
Application class:
public class XXXApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
ActiveAndroid.initialize(this);
}
}
Mode class is:
#Table(name = "Routes")
public class Route extends Model {
...
public static List<Routes> all(){
return new Select().from(Route.class).execute();
}
}
Ps: I follow the documentation:
https://github.com/pardom/ActiveAndroid/wiki/Getting-started
When call Routes.all() I got this error:
tried to execute code in unprepared class 'Lbr/com/xxx/xxx/xxxx/models/Route;'
Full stack is:
03-08 16:41:56.505: E/dalvikvm(23688): ERROR: tried to execute code in unprepared class 'Lbr/com/xxx/xxx/xxxx/models/Route;' (5)
03-08 16:41:56.505: I/dalvikvm(23688): "main" prio=5 tid=1 RUNNABLE
03-08 16:41:56.505: I/dalvikvm(23688): | group="main" sCount=0 dsCount=0 obj=0x41800508 self=0x417efce0
03-08 16:41:56.505: I/dalvikvm(23688): | sysTid=23688 nice=0 sched=0/0 cgrp=apps handle=1075560240
03-08 16:41:56.505: I/dalvikvm(23688): | schedstat=( 1596851683 269907401 1132 ) utm=148 stm=11 core=0
03-08 16:41:56.505: I/dalvikvm(23688): at com.xxxx.models.Route.all(Route.java:-1)
03-08 16:41:56.505: I/dalvikvm(23688): at com.xxxx.activities.SavedRoutesActivity.onCreate(SavedRoutesActivity.java:-1)
03-08 16:41:56.505: I/dalvikvm(23688): at com.xxxx.activities.SavedRoutesActivity_.onCreate(SavedRoutesActivity_.java:24)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.Activity.performCreate(Activity.java:5206)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.ActivityThread.access$600(ActivityThread.java:140)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
03-08 16:41:56.505: I/dalvikvm(23688): at android.os.Handler.dispatchMessage(Handler.java:99)
03-08 16:41:56.505: I/dalvikvm(23688): at android.os.Looper.loop(Looper.java:137)
03-08 16:41:56.505: I/dalvikvm(23688): at android.app.ActivityThread.main(ActivityThread.java:4898)
03-08 16:41:56.505: I/dalvikvm(23688): at java.lang.reflect.Method.invokeNative(Native Method)
03-08 16:41:56.505: I/dalvikvm(23688): at java.lang.reflect.Method.invoke(Method.java:511)
03-08 16:41:56.505: I/dalvikvm(23688): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
03-08 16:41:56.505: I/dalvikvm(23688): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
03-08 16:41:56.505: I/dalvikvm(23688): at dalvik.system.NativeStart.main(Native Method)
03-08 16:41:56.505: E/dalvikvm(23688): VM aborting
03-08 16:41:56.505: A/libc(23688): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 23688 (o.mobile.xxxx)
This is late but could help someone else who faces the same problem.
This problem only occurs in debug mode, To solve it :
remove any watched expressions (In Debug View) that involve that unprepared class.
If you don't use that class in your code just remove it (which solve the first point too).
Hope it helps.
Did you remember to write a standard constructor for Route? E. g.
public Route(){
super();
}
And if you have your own Application class, it must be derived from com.activeandroid.app.Application:
public class Application extends com.activeandroid.app.Application {
…
}
If that doesn’t help, please post the signature of Route.