Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiled binaries do not run on really old Android versions #1195

Open
5 of 11 tasks
nullchinchilla opened this issue Jan 25, 2023 · 4 comments
Open
5 of 11 tasks

Compiled binaries do not run on really old Android versions #1195

nullchinchilla opened this issue Jan 25, 2023 · 4 comments
Labels
A-android Area: android targets question

Comments

@nullchinchilla
Copy link

Checklist

Describe your issue

On Android 5, compiled binaries fail to run with messages on stderr like:

WARNING: linker: /data/app/io.geph.android-1/lib/arm/libgeph.so: unused DT entry: type 0x6ffffef5 arg 0x15d4
...
CANNOT LINK EXECUTABLE: cannot locate symbol "__register_atfork" referenced by "/data/app/io.geph.android-1/lib/arm/libgeph.so"...

From some googling, this looks like it's targeting too new of an Android SDK version. Is there any place where this can be configured?

What target(s) are you cross-compiling for?

aarch64-linux-android, armv7-linux-androideabi

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.4 (80c9f91 2023-01-20)

Example

No response

Additional information / notes

No response

@Emilgardis Emilgardis added question A-android Area: android targets labels Jan 25, 2023
@Emilgardis
Copy link
Member

Hi!

To target an older android, you'll need to clone the cross repository and initialize the submodule cross-toolchains

Then see this wiki entry: https://github.com/cross-rs/cross/wiki/FAQ#android-version-configuration

Hopefully that helps, here is the dockerfile we use https://github.com/cross-rs/cross/blob/main/docker/Dockerfile.armv7-linux-androideabi#L16-L18

If you get into any issue, let us know!

@nullchinchilla
Copy link
Author

That sounds...complicated :(

Would it be possible to either default to a really old Android version (because Android NDK is forwards-compatible), or expose this through some sort of runtime flag?

@Emilgardis
Copy link
Member

Emilgardis commented Jan 25, 2023

(note I don't really understand how android versioning work so take this with a grain of salt and feel free to educate/correct me!)

Just leaving some breadcrumbs here, not strictly related to your question.

Notes

the NDK may be forward-compatible, but I don't think rust supports older APIs, what api do you need? rust < 1.68 supports 15 (via NDK r17), and the releases after tomorrows release (which would be 1.68) will be api 19 (via NDK r23).

It seems the fix to your problem is available here

Resolution: build your code with an NDK target API level that matches your app's minimum API level, or avoid using atfork/pthread_atfork.

The fix

The fix for you would be an environment with sdk 21, right?

To do this, you'll need to do

$ git clone https://github.com/cross-rs/cross.git # or ssh git@github.com:cross-rs/cross.git
$ git submodule update --init --recursive
$ cargo build-docker-image armv7-linux-androideabi \
  --build-arg ANDROID_NDK=r25d \
  --build-arg ANDROID_SDK=21 \
  --build-arg ANDROID_VERSION=5.0.0_r1

which will spit out an image ghcr.io/cross-rs/armv7-linux-androideabi:local you can put in your Cross.toml

I'll see what we can do about creating some images that people commonly use so it's easier (you'd only have to change the image used), that is part of #1155

@nullchinchilla
Copy link
Author

I'll see what we can do about creating some images that people commonly use so it's easier (you'd only have to change the image used), that is part of #1155

Yeah that seems ideal.

I don't need versions that old (21 is enough), but I think that Android 9 is too new to be a good default, considering a very significant fraction of phones, especially in 3rd world countries, run older Androids. I'd suggest "the oldest Android version that the latest NDK supports" as a sane default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-android Area: android targets question
Projects
None yet
Development

No branches or pull requests

2 participants