i have developed an application that works fine on android 2.1 version but when i launch it on android 4.0 version it does not run and throws the stack trace like this:
09-26 19:45:10.961: E/AndroidRuntime(785): FATAL EXCEPTION: main
09-26 19:45:10.961: E/AndroidRuntime(785): java.lang.OutOfMemoryError
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.Bitmap.nativeCreate(Native Method)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.content.res.Resources.loadDrawable(Resources.java:1937)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.content.res.Resources.getDrawable(Resources.java:664)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.widget.ImageView.resolveUri(ImageView.java:542)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.widget.ImageView.setImageResource(ImageView.java:315)
09-26 19:45:10.961: E/AndroidRuntime(785): at com.deedatech.AnimalsNameForKids.AnimalsNameForKidsActivity.onCreate(AnimalsNameForKidsActivity.java:85)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.Activity.performCreate(Activity.java:4465)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.ActivityThread.access$600(ActivityThread.java:122)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.os.Handler.dispatchMessage(Handler.java:99)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.os.Looper.loop(Looper.java:137)
09-26 19:45:10.961: E/AndroidRuntime(785): at android.app.ActivityThread.main(ActivityThread.java:4340)
09-26 19:45:10.961: E/AndroidRuntime(785): at java.lang.reflect.Method.invokeNative(Native Method)
09-26 19:45:10.961: E/AndroidRuntime(785): at java.lang.reflect.Method.invoke(Method.java:511)
09-26 19:45:10.961: E/AndroidRuntime(785): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-26 19:45:10.961: E/AndroidRuntime(785): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-26 19:45:10.961: E/AndroidRuntime(785): at dalvik.system.NativeStart.main(Native Method)
i just dont understand why this happens because the same program runs perfect on android 2.1 version but throws outOfMemoryError on 4.0 version. please help if u have some idea..
If you are decoding a Bitmap from the UI thread, there is a risk to get the outOfMemoryError. Try to change your decode stream to an asynTask.
Contrary to what Anis said, decoding yor Bitmap on a different thread will not help you avoid an Out Of Memory (OOM) Error, you're still loading exactly the same amount of data into your application.
You need to either reduce the size of the image you are loading or downsample it so you aren't loading in all of the data, for more information on this take a look at Loading Large Bitmaps Efficiently.
Related
I try to code an Android App.
The code below should add the parent of a file to my list, but only if the parent is not already in the list.
files[] is an array of Files in a directory
imageFolders is created like this:
private List <File> imageFolders;
private String [] extensions;
File [] files = folder.listFiles();
extensions = new String [] {".png",".jpg",".jpeg"};
//important part:
if(files[i].toString().contains(extensions[b]))
{
System.out.println("Checkpoint 1");
if(!imageFolders.contains((File)files[i].getParentFile()))
{
System.out.println("Checkpoint 2");
imageFolders.add((File)files[i].getParentFile());
}
}
And then the log gives me this and the app shuts down:
09-26 08:33:55.580: I/System.out(1753): /system/lib/hw/camera.goldfish.jpeg.so //gives me the file[i]
09-26 08:33:55.580: I/System.out(1753): Checkpoint 1
09-26 08:33:55.590: D/AndroidRuntime(1753): Shutting down VM
09-26 08:33:55.610: W/dalvikvm(1753): threadid=1: thread exiting with uncaught exception
(group=0xb1a87ba8)
09-26 08:33:55.650: E/AndroidRuntime(1753): FATAL EXCEPTION: main
09-26 08:33:55.650: E/AndroidRuntime(1753): Process: de.FriedSloth.fastphotomanager, PID: 1753
09-26 08:33:55.650: E/AndroidRuntime(1753): java.lang.RuntimeException: Unable to start activity
ComponentInfo{de.FriedSloth.fastphotomanager/de.FriedSloth.fastphotomanager.Side2}: java.lang.NullPointerException
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.ActivityThread.access$800(ActivityThread.java:135)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.os.Handler.dispatchMessage(Handler.java:102)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.os.Looper.loop(Looper.java:136)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.ActivityThread.main(ActivityThread.java:5017)
09-26 08:33:55.650: E/AndroidRuntime(1753): at java.lang.reflect.Method.invokeNative(Native
Method)
09-26 08:33:55.650: E/AndroidRuntime(1753): at java.lang.reflect.Method.invoke(Method.java:515)
09-26 08:33:55.650: E/AndroidRuntime(1753): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
09-26 08:33:55.650: E/AndroidRuntime(1753): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
09-26 08:33:55.650: E/AndroidRuntime(1753): at dalvik.system.NativeStart.main(Native Method)
09-26 08:33:55.650: E/AndroidRuntime(1753): Caused by: java.lang.NullPointerException
09-26 08:33:55.650: E/AndroidRuntime(1753): at de.FriedSloth.fastphotomanager.Side2.hSearchImages(Side2.java:61)
09-26 08:33:55.650: E/AndroidRuntime(1753): at de.FriedSloth.fastphotomanager.Side2.hSearchImages(Side2.java:52)
09-26 08:33:55.650: E/AndroidRuntime(1753): at de.FriedSloth.fastphotomanager.Side2.hSearchImages(Side2.java:52)
09-26 08:33:55.650: E/AndroidRuntime(1753): at de.FriedSloth.fastphotomanager.Side2.onCreate(Side2.java:32)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.Activity.performCreate(Activity.java:5231)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
09-26 08:33:55.650: E/AndroidRuntime(1753): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
09-26 08:33:55.650: E/AndroidRuntime(1753): ... 11 more
I'm using ActionShrelockBar & libslidemenu library.
The slide menu work's fine for 2.3 to 4.2.
But when i tried it in 4.3 latest version of android the slidemenu crashes .
I tried by adding support library but no go.
07-26 02:04:14.400: E/AndroidRuntime(785): FATAL EXCEPTION: main
07-26 02:04:14.400: E/AndroidRuntime(785): java.lang.ClassCastException: com.android.internal.widget.ActionBarOverlayLayout cannot be cast to android.widget.FrameLayout
07-26 02:04:14.400: E/AndroidRuntime(785): at com.coboltforge.slidemenu.SlideMenu.show(SlideMenu.java:317)
07-26 02:04:14.400: E/AndroidRuntime(785): at com.coboltforge.slidemenu.SlideMenu.show(SlideMenu.java:260)
07-26 02:04:14.400: E/AndroidRuntime(785): at com.hrh.lba.fragments.CategoryFragment.onOptionsItemSelected(CategoryFragment.java:326)
07-26 02:04:14.400: E/AndroidRuntime(785): at android.support.v4.app.Watson.onMenuItemSelected(Watson.java:127)
07-26 02:04:14.400: E/AndroidRuntime(785): at com.actionbarsherlock.ActionBarSherlock.callbackOptionsItemSelected(ActionBarSherlock.java:603)
07-26 02:04:14.400: E/AndroidRuntime(785): at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchOptionsItemSelected(ActionBarSherlockNative.java:78)
07-26 02:04:14.400: E/AndroidRuntime(785): at com.actionbarsherlock.app.SherlockFragmentActivity.onMenuItemSelected(SherlockFragmentActivity.java:205)
07-26 02:04:14.400: E/AndroidRuntime(785): at com.android.internal.widget.ActionBarView$3.onClick(ActionBarView.java:171)
07-26 02:04:14.400: E/AndroidRuntime(785): at android.view.View.performClick(View.java:4240)
07-26 02:04:14.400: E/AndroidRuntime(785): at android.view.View$PerformClick.run(View.java:17721)
07-26 02:04:14.400: E/AndroidRuntime(785): at android.os.Handler.handleCallback(Handler.java:730)
07-26 02:04:14.400: E/AndroidRuntime(785): at android.os.Handler.dispatchMessage(Handler.java:92)
07-26 02:04:14.400: E/AndroidRuntime(785): at android.os.Looper.loop(Looper.java:137)
07-26 02:04:14.400: E/AndroidRuntime(785): at android.app.ActivityThread.main(ActivityThread.java:5103)
07-26 02:04:14.400: E/AndroidRuntime(785): at java.lang.reflect.Method.invokeNative(Native Method)
07-26 02:04:14.400: E/AndroidRuntime(785): at java.lang.reflect.Method.invoke(Method.java:525)
07-26 02:04:14.400: E/AndroidRuntime(785): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
Tried with this patch .
And it's working great for 4.3 now .
Patch
The key is in the first string:
com.android.internal.widget.ActionBarOverlayLayout cannot be cast to
android.widget.FrameLayout
Check source of SlideMenu.java at line 317
There must be some changes to SDK, so that you don't get expected class there.
I'm getting a NullPointerException after calling updateAppWidgetSize() in my app (which is basically AOSP's Jelly Bean Launcher)
Output is as follows:
09-26 00:47:34.681: E/AndroidRuntime(2026): FATAL EXCEPTION: main
09-26 00:47:34.681: E/AndroidRuntime(2026): java.lang.NullPointerException
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.os.Parcel.readException(Parcel.java:1431)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.os.Parcel.readException(Parcel.java:1379)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.android.internal.appwidget.IAppWidgetService$Stub$Proxy.updateAppWidgetOptions(IAppWidgetService.java:535)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.appwidget.AppWidgetManager.updateAppWidgetOptions(AppWidgetManager.java:353)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.appwidget.AppWidgetHostView.updateAppWidgetOptions(AppWidgetHostView.java:256)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.appwidget.AppWidgetHostView.updateAppWidgetSize(AppWidgetHostView.java:245)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.launcherjellybean.android.AppWidgetResizeFrame.updateWidgetSizeRanges(AppWidgetResizeFrame.java:339)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.launcherjellybean.android.LauncherAppWidgetInfo.notifyWidgetSizeChanged(LauncherAppWidgetInfo.java:84)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.launcherjellybean.android.Launcher.completeAddAppWidget(Launcher.java:1153)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.launcherjellybean.android.Launcher.addAppWidgetImpl(Launcher.java:1591)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.launcherjellybean.android.Launcher.addAppWidgetFromDrop(Launcher.java:1653)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.launcherjellybean.android.Workspace$8.run(Workspace.java:3071)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.launcherjellybean.android.Workspace$9.run(Workspace.java:3266)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.launcherjellybean.android.DragLayer$3.onAnimationEnd(DragLayer.java:628)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1018)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.animation.ValueAnimator.access$400(ValueAnimator.java:51)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:623)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:639)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.view.Choreographer.doFrame(Choreographer.java:524)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.os.Handler.handleCallback(Handler.java:615)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.os.Handler.dispatchMessage(Handler.java:92)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.os.Looper.loop(Looper.java:137)
09-26 00:47:34.681: E/AndroidRuntime(2026): at android.app.ActivityThread.main(ActivityThread.java:4745)
09-26 00:47:34.681: E/AndroidRuntime(2026): at java.lang.reflect.Method.invokeNative(Native Method)
09-26 00:47:34.681: E/AndroidRuntime(2026): at java.lang.reflect.Method.invoke(Method.java:511)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-26 00:47:34.681: E/AndroidRuntime(2026): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-26 00:47:34.681: E/AndroidRuntime(2026): at dalvik.system.NativeStart.main(Native Method)
I had to make some slight modifications to the AOSP launcher source to remove some private API use, as well as making a separate change so that widgets that have a AppWidgetHostView can be placed. Apart from that, I'm working with an unmodified version of the launcher that ships with AOSP (API 16).
The source is available if you are interested in seeing this issue for yourself (100% occurrence rate when attempting to add the Analog Clock or Messages widgets).
Any help would be appreciated.
I am following Cocos2D-X for iOS and Android: Getting Started tutorial from Raywenderlich site.
I have downloaded the android project from create-android-project.sh command as stated in the site. When I try to run the project in eclipse I got the following logs:
09-26 13:04:05.081: W/dalvikvm(517): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/a/samplecocos2dxandroid21;
09-26 13:04:05.081: W/dalvikvm(517): Class init failed in newInstance call (Lcom/a/samplecocos2dxandroid21;)
09-26 13:04:05.081: D/AndroidRuntime(517): Shutting down VM
09-26 13:04:05.081: W/dalvikvm(517): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
09-26 13:04:05.091: E/AndroidRuntime(517): FATAL EXCEPTION: main
09-26 13:04:05.091: E/AndroidRuntime(517): java.lang.ExceptionInInitializerError
09-26 13:04:05.091: E/AndroidRuntime(517): at java.lang.Class.newInstanceImpl(Native Method)
09-26 13:04:05.091: E/AndroidRuntime(517): at java.lang.Class.newInstance(Class.java:1319)
09-26 13:04:05.091: E/AndroidRuntime(517): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
09-26 13:04:05.091: E/AndroidRuntime(517): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
09-26 13:04:05.091: E/AndroidRuntime(517): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
09-26 13:04:05.091: E/AndroidRuntime(517): at android.app.ActivityThread.access$600(ActivityThread.java:123)
09-26 13:04:05.091: E/AndroidRuntime(517): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
09-26 13:04:05.091: E/AndroidRuntime(517): at android.os.Handler.dispatchMessage(Handler.java:99)
09-26 13:04:05.091: E/AndroidRuntime(517): at android.os.Looper.loop(Looper.java:137)
09-26 13:04:05.091: E/AndroidRuntime(517): at android.app.ActivityThread.main(ActivityThread.java:4424)
09-26 13:04:05.091: E/AndroidRuntime(517): at java.lang.reflect.Method.invokeNative(Native Method)
09-26 13:04:05.091: E/AndroidRuntime(517): at java.lang.reflect.Method.invoke(Method.java:511)
09-26 13:04:05.091: E/AndroidRuntime(517): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-26 13:04:05.091: E/AndroidRuntime(517): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-26 13:04:05.091: E/AndroidRuntime(517): at dalvik.system.NativeStart.main(Native Method)
09-26 13:04:05.091: E/AndroidRuntime(517): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load game: findLibrary returned null
09-26 13:04:05.091: E/AndroidRuntime(517): at java.lang.Runtime.loadLibrary(Runtime.java:365)
09-26 13:04:05.091: E/AndroidRuntime(517): at java.lang.System.loadLibrary(System.java:535)
09-26 13:04:05.091: E/AndroidRuntime(517): at com.a.samplecocos2dxandroid21.<clinit>(samplecocos2dxandroid21.java:106)
09-26 13:04:05.091: E/AndroidRuntime(517): ... 15 more
android ndk, android sdk path setting and change an create-android-project.sh already done.
Can somebody please tell me where I am wrong and what is the solution of that..,.
you didn't run the build_native.sh so that your game is not built to a shared lib, that is why it complain about Can't find library
I got the following Class not found exception while working with map based application
09-26 15:33:19.810: ERROR/AndroidRuntime(27866):
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.zyksatwo/com.zyksatwo.MapRouteActivity}:
java.lang.ClassNotFoundException: com.zyksatwo.MapRouteActivity in
loader dalvik.system.PathClassLoader[/data/app/com.zyksatwo-1.apk]
09-26 15:33:19.810: ERROR/AndroidRuntime(27866): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1618)
09-26 15:33:19.810: ERROR/AndroidRuntime(27866): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1716)
09-26 15:33:19.810: ERROR/AndroidRuntime(27866): at
android.app.ActivityThread.access$1500(ActivityThread.java:124) 09-26
15:33:19.810: ERROR/AndroidRuntime(27866): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:968)
09-26 15:33:19.810: ERROR/AndroidRuntime(27866): at
android.os.Handler.dispatchMessage(Handler.java:99) 09-26
15:33:19.810: ERROR/AndroidRuntime(27866): at
android.os.Looper.loop(Looper.java:130) 09-26 15:33:19.810:
ERROR/AndroidRuntime(27866): at
android.app.ActivityThread.main(ActivityThread.java:3806) 09-26
15:33:19.810: ERROR/AndroidRuntime(27866): at
java.lang.reflect.Method.invokeNative(Native Method) 09-26
15:33:19.810: ERROR/AndroidRuntime(27866): at
java.lang.reflect.Method.invoke(Method.java:507) 09-26 15:33:19.810:
ERROR/AndroidRuntime(27866): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-26 15:33:19.810: ERROR/AndroidRuntime(27866): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 09-26
15:33:19.810: ERROR/AndroidRuntime(27866): at
dalvik.system.NativeStart.main(Native Method) 09-26 15:33:19.810:
ERROR/AndroidRuntime(27866): Caused by:
java.lang.ClassNotFoundException: com.zyksatwo.MapRouteActivity in loader dalvik.system.PathClassLoader[/data/app/com.zyksatwo-1.apk
Please help me to figure out the mistake I did here
did you add <uses-library android:name="com.google.android.maps" /> in your menifest file?
if not then plz add this Tag inside your Application Tag in your Menifest.xml file