Skip to content

Crash on scanning large APKs #75

@erazemk

Description

@erazemk

When trying to scan a large APK (through the "Scan APK" feature), the app crashes with the following message:

FATAL EXCEPTION: AsyncTask #1
Process: tech.projectmatris.antimalwareapp, PID: 10842
java.lang.RuntimeException: An error occurred while executing doInBackground()
	at android.os.AsyncTask$4.done(AsyncTask.java:415)
	at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
	at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
	at java.util.concurrent.FutureTask.run(FutureTask.java:271)
	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.lang.Thread.run(Thread.java:920)
Caused by: java.lang.OutOfMemoryError: Failed to allocate a 1463300032 byte allocation with 25165824 free bytes and 764MB until OOM, target footprint 29321320, growth limit 805306368
	at tech.projectmatris.antimalwareapp.utils.Sha256HashExtractor.convertFileByteArray(Sha256HashExtractor.java:25)
	at tech.projectmatris.antimalwareapp.utils.Sha256HashExtractor.getSha256Hash(Sha256HashExtractor.java:18)
	at tech.projectmatris.antimalwareapp.scanners.ApkScanner.doInBackground(ApkScanner.java:132)
	at tech.projectmatris.antimalwareapp.scanners.ApkScanner.doInBackground(ApkScanner.java:37)
	at android.os.AsyncTask$3.call(AsyncTask.java:394)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	... 4 more

The APK I tried to scan is 1,46 GB large.
I'm guessing the app extracts the apk in memory and then scans it also in memory? Would it be possible to extract the application to a temporary directory and scan through that?

My device is a Poco F3 (8 GB of RAM), Android 12.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions