I generated my application APK file.
now, when im trying to open it via my device, im getting :
5474-5474/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.android.packageinstaller, PID: 5474
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:422)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
at android.content.res.Resources.loadDrawable(Resources.java:2150)
at android.content.res.Resources.getDrawable(Resources.java:715)
at com.android.packageinstaller.PackageUtil.getAppSnippet(PackageUtil.java:181)
at com.android.packageinstaller.InstallAppProgress.initView(InstallAppProgress.java:248)
at com.android.packageinstaller.InstallAppProgress.onCreate(InstallAppProgress.java:182)
at android.app.Activity.performCreate(Activity.java:5275)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5105)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(Native Method)
please please help me...
what did I do wrong?
Android allocates 4 bytes per pixel for the image. Add to that the fact that if the icon is in drawable, android allocates additional resources to scale it up.
Android would also have limitations on how much memory it can allocate to the icon while installing the app. If the icon is too big, the app will run out of memory.
Solution - Follow the icon design guidelines here for adaptive or here for legacy. If you don't want to go into the complexities, just reduce your icon size and your app will work.
Related
In my half a dozens of physical devices and in emulators the app doesn't crashes, but while testing in Firebase 4/10 devices test failed with:
java.lang.OutOfMemoryError: Failed to allocate a 42465612 byte allocation
with 13253240 free bytes and 12MB until OOM
FATAL EXCEPTION: main
Process: technocrats.com.gymaholic, PID: 24886
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:422)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
at android.content.res.Resources.loadDrawable(Resources.java:2150)
at android.content.res.Resources.getDrawable(Resources.java:715)
at android.support.v7.widget.ResourcesWrapper.getDrawable(ResourcesWrapper.java:130)
at android.support.v7.widget.TintResources.getDrawable(TintResources.java:46)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:465)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:203)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:191)
at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:102)
at android.support.v7.widget.AppCompatImageHelper.loadFromAttributes(AppCompatImageHelper.java:59)
at android.support.v7.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:79)
at android.support.v7.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:69)
at android.support.v7.app.AppCompatViewInflater.createImageButton(AppCompatViewInflater.java:202)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:122)
at android.support.v7.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1266)
at android.support.v7.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1316)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:684)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:745)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:745)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at technocrats.com.gymaholic.MainActivity.onCreate(MainActivity.java:57)
at android.app.Activity.performCreate(Activity.java:5275)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2169)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2255)
at android.app.ActivityThread.access$800(ActivityThread.java:142)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5118)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:610)
at dalvik.system.NativeStart.main(Native Method)
As Christophe already mentioned in the comments, this doesn't look like an issue with Firebase Test Lab. It actually is telling you that you are not making good use of the available device resources.
The error message suggests that your app tries to allocate a 40 MB image, which is definitely way too much.
Try to make your usage of images more reasonable:
Use PNGs or VectorDrawables as they give you a better compression ratio than GIF for the same quality
If you need animations, try out animated vector drawables.
Use other types of drawables like ShapeDrawable or NinePatchDrawable, which are especially useful for backgrounds that need to scale based on device dimensions and screen densities.
I am following Steps provided by IBM to build MobileFirst hybrid application for default Aurora store. I found the desired WCWorklight.zip at location
C:\{Installation dir}\components\store-enhancements\samples\Worklight\
On tutorial there were many js files that need to be replaced but those were not present in WCWorklight.zip e.g.
After building the apk when I ran it it is throwing error
Process: com.ibm.commerce.worklight.android, PID: 3001
java.lang.NoClassDefFoundError: com.worklight.location.internal.nativeImpl.AndroidWLDevice
at com.worklight.wlclient.api.WLClient.<init>(WLClient.java:177)
at com.worklight.wlclient.api.WLClient.createInstance(WLClient.java:229)
at com.worklight.common.Logger.setContext(Logger.java:549)
at com.worklight.androidgap.WLDroidGap.onCreate(WLDroidGap.java:43)
at com.ibm.commerce.worklight.android.WCHybrid.onCreate(WCHybrid.java:143)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Please let me know if any one faced such issues.
Thanks in advance.
WebSphere Commerce specifically mentions that you need Worklight 6.0, where you are using 7.1.
You need to check if there is a version that is updated for 7.1.
7.1 is wholly different from 6.0 (by years of development).
Contact IBM WebSphere Commerce.
I am trying to load a 3MB image using getDrawable() for testing purposes, but I get an out of memory leak exception. Is there any limit on the size of image drawable you can use in android ?
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:594)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:429)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
at android.content.res.Resources.loadDrawable(Resources.java:2113)
at android.content.res.Resources.getDrawable(Resources.java:700)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:321)
at com.testleak.MainActivity.onCreate(MainActivity.java:22)
at android.app.Activity.performCreate(Activity.java:5248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5097)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Is there any limit on the size of image drawable you can use in android ?
Yes. It has to fit in available memory when decoded. A 3MB PNG or JPEG file will be much larger when decoded, as the decoded memory usage is width x height x 4 bytes/pixel.
"Available memory" depends on:
The heap limit imposed by your device, based on installed system RAM (see ActivityManager and getMemoryClass())
The largest single block of free memory within your heap, which will depend on a lot of factors at runtime
I am trying to integrate Flickr in android using the Flickr4Java library. Flickr4Java uses Log4j for logging. So when I try to create an instance of flickr, something like Flickr flickr = new Flickr(apiKey, sharedSecret, new REST()); I get the following stack trace
05-12 01:24:28.714 8449-8449/edu.sdsu.cs.sharepic E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: edu.sdsu.cs.sharepic, PID: 8449
java.lang.VerifyError: org/apache/log4j/config/PropertySetter
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:805)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:580)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)
at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
at org.apache.log4j.Logger.getLogger(Logger.java:117)
at com.flickr4java.flickr.REST.<clinit>(REST.java:46)
at edu.sdsu.cs.sharepic.model.Flickr1.<init>(Flickr1.java:28)
at edu.sdsu.cs.sharepic.activity.SelectProfileActivity.init(SelectProfileActivity.java:75)
at edu.sdsu.cs.sharepic.activity.SelectProfileActivity.onCreate(SelectProfileActivity.java:41)
at android.app.Activity.performCreate(Activity.java:5248)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
I am guessing it has got something to do with configuration of the log4j library, but don't know how to solve the problem. Any help will be much appreciated.
Log4j uses apis from java.beans that is missing in android.
Try this library https://code.google.com/archive/p/android-logging-log4j/
I have yet to look at it tough
I've tried to import mupdf to my app, but when I open it, i got some weird error and it force closes. Why? I really don't understand.
this is my logcat:
10-10 15:34:17.802 8657-8657/com.tproductions.Openit E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.tproductions.Openit, PID: 8657
java.lang.UnsatisfiedLinkError: Native method not found: com.artifex.mupdfdemo.MuPDFCore.openFile:(Ljava/lang/String;)J
at com.artifex.mupdfdemo.MuPDFCore.openFile(Native Method)
at com.artifex.mupdfdemo.MuPDFCore.<init>(MuPDFCore.java:68)
at com.artifex.mupdfdemo.MuPDFActivity.openFile(MuPDFActivity.java:204)
at com.artifex.mupdfdemo.MuPDFActivity.onCreate(MuPDFActivity.java:303)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2201)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2286)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:212)
at android.app.ActivityThread.main(ActivityThread.java:5135)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:877)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
at dalvik.system.NativeStart.main(Native Method)
It looks like something has gone wrong in the native build.
It's probably best to retry that; there are instructions here:
http://www.mupdf.com/doc/how-to-build-mupdf-for-android
and here:
http://git.ghostscript.com/?p=mupdf.git;a=blob_plain;f=platform/android/ReadMe.txt;hb=HEAD
It's probably best to use the git code from master - the latest is 1.6, versions prior to 1.5 are unlikely to build cleanly with the current NDKs.