Signing APK causes error "Failed to extract native libraries – 'libsqlite3_python.so' is not page-aligned"
- Dominant language
- Python
- Stars
- 3.3k
- Forks
- 549
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 40
Description
### Describe the bug
Installing release APK with `adb install dist/Hello World-0.0.1.apk` results in `INSTALL_FAILED_INVALID_APK`, while installing debug APK with `adb install dist/Hello World-0.0.1.debug.apk` has no issue.
The release APK was properly signed using
### Steps to reproduce
- Create clean new environment with `python -m venv beeware-venv`
- Activate new environement `source beeware-venv/bin/activate`
- Create briefcase project with all values to default `briefcase new`
- Create android platform `briefcase create android`
- Package android `briefcase package android -p apk`
- Sign APK with previously created `upload-key-hellow_world.jks` key using
`~/.cache/briefcase/tools/java17/bin/jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ~/.local/share/android/upload-key-hello_world.jks "dist/Hello World-0.0.1.apk" upload-key -storepass android`
- Install apk on device with `adb install dist/Hellow World-0.0.1.apk` (emulator or physical device behave the same)
- Results in `adb: failed to install dist/Hello World-0.0.1.apk: Failure [INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2]`
### Expected behavior
The APK should install without any issues as it correctly happen when installing debug version of the APK.
### Screenshots
_No response_
### Environment
- Operating System: ArchLinux (6.13.1-arch1-1)
- Python version: 3.13.1
- Software versions:
- Briefcase: 0.3.31
### Logs
logcat section I believe to be relevant :
```
02-06 10:59:31.048 1357 1357 I abb : StartCommandInProcess(73657474696e67730067657400676c6f settings.get.glo [truncated])
02-06 10:59:31.049 557 557 W Binder:557_12: type=1400 audit(0.0:333): avc: denied { getopt } for scontext=u:r:system_server:s0 tcontext=u:r:shell:s0 tclass=unix_stream_socket permissive=0
02-06 10:59:31.057 1357 1357 I abb : StartCommandInProcess(7061636b61676500696e7374616c6c00 package.install. [truncated])
02-06 10:59:31.049 557 557 W Binder:557_12: type=1400 audit(0.0:334): avc: denied { getopt } for scontext=u:r:system_server:s0 tcontext=u:r:shell:s0 tclass=unix_stream_socket permissive=0
02-06 10:59:31.049 557 557 W Binder:557_12: type=1400 audit(0.0:335): avc: denied { getopt } for scontext=u:r:system_server:s0 tcontext=u:r:shell:s0 tclass=unix_stream_socket permissive=0
02-06 10:59:31.369 557 557 W Binder:557_12: type=1400 audit(0.0:336): avc: denied { getopt } for scontext=u:r:system_server:s0 tcontext=u:r:shell:s0 tclass=unix_stream_socket permissive=0
02-06 10:59:31.557 557 643 E NativeLibraryHelper: Library 'libsqlite3_python.so' is not page-aligned - will not be able to open it directly from apk.
02-06 10:59:31.557 557 643 W NativeHelper: Failure copying native libraries [errorCode=-2]
02-06 10:59:31.557 557 643 E PackageInstallerSession: Failed to verify session 1347179052 [INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2]
02-06 10:59:31.569 446 474 E installd: Couldn't opendir /data/app/vmdl1347179052.tmp: No such file or directory
02-06 10:59:31.569 446 474 E installd: Failed to delete /data/app/vmdl1347179052.tmp: No such file
```
### Additional context
_No response_
Contributor guide
Research direction
Start by reproducing the documented Briefcase Android create, package, signing, and adb install commands, then compare the debug and signed release APKs around libsqlite3_python.so. Use the reported NativeLibraryHelper page-alignment error to trace which packaging or signing step changes the native library layout; done means the signed release APK installs successfully on the affected device or emulator.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, python
- Domain
- build-system, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100