Skip to content

Temporary fix for Android 16KB page-size compatibility #192

@jwh-hutchison

Description

@jwh-hutchison

Problem

When targeting newer Android devices with 16KB page sizes, some builds fail due to unaligned native libraries, especially when using the default RxDNSSD binaries. In addition to that, Google Play requires that all android apps are 16-KB aligned therefore unless this is patched, your app will not be accepted by Google.

Fix

To quickly fix the issue, tweak the RxDNSSD dependency to my prebuilt RnDNSSD libraries that support 16KB page sizes:

dependencies {
    // Replace the original dependency:
    // api 'com.github.andriydruk:RxDNSSD:0.9.16'

    // Use the patched fork instead:
    api 'com.github.jwh-hutchison:RxDNSSD:0.9.20'
}

This forked version includes .so libraries rebuilt with -Wl,-z,max-page-size=16384 for compatibility with 16KB page-size devices.

After running:
/check_elf_alignment.sh android/app/build/outputs/apk/release/app-release.apk

You will see that both x86_64 and arm64_v8a dnssd libraries are 16-kb aligned:

x86/libjdns_sd.so: \e[32mALIGNED\e[0m (2**14)
x86/libjdns_sd_embedded.so: \e[32mALIGNED\e[0m (2**14)
arm64-v8a/libjdns_sd.so: \e[32mALIGNED\e[0m (2**14)
arm64-v8a/libjdns_sd_embedded.so: \e[32mALIGNED\e[0m (2**14)

It's important that I add that:
This was published to jitpack rather than maven because I honestly didn't have time to set up signing, I recommend someone fork the RxDNSSD repo and deploy to maven with package signing, then open a PR for 'add 16-kb page-sizes' as a feature (which would then reference the RxDNSSD dependency in place of mine).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions