Android "mmap failed: Out of memory" with large APK - android

My Android app APK is fairly large at ~480 MB. I can install the app just fine but on Android OS 2.2 when the app is launched I get this error (in logcat):
09-21 00:04:12.855: W/dalvikvm(3178): mmap(480331001, RO, FILE|SHARED, 28, 0) failed: Out of memory
09-21 00:04:12.855: W/dalvikvm(3178): Map of '/data/app/com.mycompany.myapp-1.apk' failed
09-21 00:04:12.855: D/AndroidRuntime(3178): Shutting down VM
09-21 00:04:12.855: W/dalvikvm(3178): threadid=1: thread exiting with uncaught exception (group=0x4001d828)
09-21 00:04:12.859: E/AndroidRuntime(3178): FATAL EXCEPTION: main
09-21 00:04:12.859: E/AndroidRuntime(3178): java.lang.RuntimeException: Unable to instantiate activity
...
This does not happen on OS 4.0+. Some users are reporting a crash on startup in 2.3.4 and 2.3.7, which I suspect is the same problem. Why is mmap failing on my APK?
EDIT: I know the app is very large (it's a game with lots of assets) and the Play Store limits APKs to 50 MB, but this is for a carrier in another country that has no APK size limit. I already have a version of the app on the Play Store with an APK of ~20MB that makes use of expansion files which exhibits no mmap problems.

Just a guess but on first run try copying the file to user memory, then mapping it from there.

Related

Android Bundle package crash on startup

My Delphi project have both android 32 and 64 destination. I can deploy them on my test devices and they both works fine.
Now google forces me to upload a single app bundle file (.aab), so i flagged the "Generate Android App Bundle file (arm + arm64)" option, set up my provisioning keystore, loaded the alias and then generated that .aab file
I uploaded that as a beta release for my app from the android developer portal and after a few hours it became available to download for my test devices. But.. it shows the start up logo.. and nothing else.
I don't really know how to debug this since both the apks are working fine (32 and 64 bit), so i tried to launch adb logcat *:W, but i still cannot get useful info. I got those lines in endless loop:
10-30 09:59:21.656 13723 13723 E systems.<my app name>: Not starting debugger since process cannot load the jdwp agent.
10-30 09:59:21.688 13723 13723 W systems.<my app name>: JIT profile information will not be recorded: profile file does not exits.
10-30 09:59:21.688 13723 13723 W systems.<my app name>: JIT profile information will not be recorded: profile file does not exits.
10-30 09:59:21.703 922 1100 E ANDR-IOP: IIop:: Iop HAL Service is not available.
10-30 09:59:21.707 13723 13743 E Perf : Fail to get file list oat
10-30 09:59:21.707 13723 13743 E Perf : getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
10-30 09:59:21.743 13723 13723 W linker : Warning: "/data/app/<my app name>-43xRWdYLtXcvUAbEkuUk6g==/split_config.arm64_v8a.apk!/lib/arm64-v8a/lib<my app name>.so" unused DT entry: DT_RPATH (type 0xf arg 0x2cf24) (ignoring)
Just for info: getFolderSize() is not a function i use in my code (its not even declared).
Also, i think this is pretty important: my app deploys some .so files (different files for 32 and 64 bit) and some other files, like images and fonts.
Why i think this is important? Just a suspect born reading this similar issue (but with xamarin): https://github.com/xamarin/Xamarin.Forms/issues/11450
I also tried to deploy the .aab manually on my devices but the only thing i found is how to generate the .apks file from the .aab, and i still cannot deploy it on my devices.
I'm using Delphi 10.4.1 and i also tried to recreate the .dproj file setting up everything again.
How i can debug this? Or how i can get more info about the cause?
Edit: Solved it! I had a few problems that, mixed together, caused this; i'll try to list them in case someone will have a similar issue and will end here!
my androidmanifest.template.xml file was generated by an older version of delphi and was missing some important parts
you need to include all the needed .so files in both 32 and 64bit build to actually have them in the bundle
using TPath.GetLibraryPath() when loading .so files can produce different results if you are using it inside a .aab bundle package
i was trying to load one of those .so file from the initialization section using the function TPath.GetLibraryPath() to get the root path, that was causing a unhandled exception that make my app crash into the splash screen
I solved simply removing TPath.GetLibraryPath() from the path i was using to load my .so and now it works

Fatal Exception: java.lang.IllegalAccessError: tried to access method android.support.v4.app.FragmentActivity.onReallyStop:()

The following crash increased from one release to the other, once we switched from generating a release build from a windows machine to a Mac OS X machine. It happens primarily with Android 4 (90% + )
Any help is appreciated.
Fatal Exception: java.lang.IllegalAccessError: tried to access method android.support.v4.app.FragmentActivity.onReallyStop:()V from class xx.com.app.view.orderflow.OrderActivity
at xx.com.app.view.orderflow.OrderActivity.onReallyStop(OrderActivity.java)
at android.support.v4.app.FragmentActivity.doReallyStop(FragmentActivity.java:668)
at android.support.v4.app.FragmentActivity$1.handleMessage(FragmentActivity.java:87)

SQLCipher fails with I/O error for file size over 2GB on Android

I am trying to encrypt a sqlite database that is over 2GB in size on Android. This causes the app to crash with an I/O error.
I am using the binaries for 3.1.0 available on the page at https://www.zetetic.net/sqlcipher/sqlcipher-for-android/
Is there a limit to the file size that can be used with the sqlCipher for Android.
Thanks.
[UPDATE]
The error I get is
net.sqlcipher.database.SQLiteDiskIOException: disk I/O error
with the stack trace as
[net.sqlcipher.database.SQLiteDatabase.native_setLocale(Native Method),
net.sqlcipher.database.SQLiteDatabase.setLocale(SQLiteDatabase.java:2092),
net.sqlcipher.database.SQLiteDatabase.<init>(SQLiteDatabase.java:1958),
net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:875),
net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:930),
com.puneet.android.sqlitesample.MainActivity.ConvertNormalToSQLCipheredDB(MainActivity.java:134),
com.puneet.android.sqlitesample.MainActivity.buttonEncryptionOnClick(MainActivity.java:69),
java.lang.reflect.Method.invokeNative(Native Method),
java.lang.reflect.Method.invoke(Method.java:515),
android.view.View$1.onClick(View.java:3978),
android.view.View.performClick(View.java:4654),
android.view.View$PerformClick.run(View.java:19438),
android.os.Handler.handleCallback(Handler.java:733),
android.os.Handler.dispatchMessage(Handler.java:95),
android.os.Looper.loop(Looper.java:146),
android.app.ActivityThread.main(ActivityThread.java:5602),
java.lang.reflect.Method.invokeNative(Native Method),
java.lang.reflect.Method.invoke(Method.java:515),
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283),
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099),
dalvik.system.NativeStart.main(Native Method)]
The file is 2GB in size.

Cannot run libgdx's 'Animation3DTest' on Android

I am trying to run the Animation3DTest , one of libgdx's test examples
On the desktop (lwjgl) I can run this test flawlessly, I can see a guy and a sword and I can move him around without any errors.
However, on Android, after starting this test, I got a force stop, and here is what showed on the Logcat
09-24 10:46:49.526 24530-24577/com.badlogic.gdx.tests.android E/AndroidRuntime﹕ FATAL EXCEPTION: GLThread 1445
com.badlogic.gdx.utils.GdxRuntimeException: File not found: com/badlogic/gdx/graphics/g3d/shaders/default.vertex.glsl (Classpath)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:133)
at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:77)
at com.badlogic.gdx.files.FileHandle.length(FileHandle.java:563)
at com.badlogic.gdx.backends.android.AndroidFileHandle.length(AndroidFileHandle.java:162)
at com.badlogic.gdx.files.FileHandle.readString(FileHandle.java:192)
at com.badlogic.gdx.files.FileHandle.readString(FileHandle.java:186)
at com.badlogic.gdx.graphics.g3d.shaders.DefaultShader.getDefaultVertexShader(DefaultShader.java:249)
at com.badlogic.gdx.graphics.g3d.utils.DefaultShaderProvider.<init>(DefaultShaderProvider.java:44)
at com.badlogic.gdx.graphics.g3d.ModelBatch.<init>(ModelBatch.java:101)
at com.badlogic.gdx.tests.g3d.BaseG3dTest.create(BaseG3dTest.java:38)
at com.badlogic.gdx.tests.g3d.BaseG3dHudTest.create(BaseG3dHudTest.java:50)
at com.badlogic.gdx.tests.g3d.Animation3DTest.create(Animation3DTest.java:45)
at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:322)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1514)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1242)
Get the latest nightly build. Here's the bug report.

NoClassDefFoundError - Rejecting re-init on previously-failed class

Please somebody explain me what this error means and how to avoid it.
After a while my app Force Closes because of this error:
09-28 12:53:45.746 I/dalvikvm(29489): Rejecting re-init on previously-failed class Lcom/bartat/android/ui/task/AsyncTaskExt; v=0x0
09-28 12:53:45.748 D/AndroidRuntime(29489): Shutting down VM
09-28 12:53:45.755 I/am_crash( 1146): [29489,com.bartat.android.secret,572996,java.lang.NoClassDefFoundError,com.bartat.android.ui.task.AsyncTaskExt,CommandsActivity.java,726]
09-28 12:53:45.755 I/am_finish_activity( 1146): [1079225264,123,com.bartat.android.secret/.CommandsActivity,crashed]
09-28 12:53:45.750 W/dalvikvm(29489): threadid=1: thread exiting with uncaught exception (group=0x40015560)
09-28 12:53:45.752 E/AndroidRuntime(29489): FATAL EXCEPTION: main
09-28 12:53:45.752 E/AndroidRuntime(29489): java.lang.NoClassDefFoundError: com.bartat.android.ui.task.AsyncTaskExt
This problem couldn't be solved by reinstalling the app.
If I rename the AsyncTaskExt to AsyncTaskExt2 for example then it works again for long. But after a few weeks/months it started to get this error again.
What does it mean? Why it is thrown and how to avoid it without renaming the class?
Please help me,
Tamás
Happens for me only if instant run is enabled.
This happens when a class couldn't be loaded for a variety of reasons. Unfortunately the new ART runtime doesn't log sufficient information as to the cause of this. If you can get hold of an older android device with Dalvik you'll see different logging, usually revealing the offence with more precision.
Last time I saw it live I had to deal with a JAR file that didn't actually include or list its dependencies, so adding the right dependent library to the gradle file solved it. The biggest issue is to figure which classes went missing - something dalvik logs/decompilation/documentation might be able to tell you.
There are many other reasons why classes can't be loaded in the entirety of the Java language so this specific cause might not apply universally.
I started having this problem after building another project with New Relic analytics enabled. Gradle daemon then cached the New Relic agent and it couldn't launch the other app.
What helped was
./gradlew --stop
you must add uses-library in your AndroidManifest.xml
Are you sure is this the first exception you are getting after running your application?
There may be some uncaught exceptions previously.

Categories

Resources