Skip to content

android_libcpp_shared` 0.2.0 fails on NDK 28 for arm64-v8a #5

Closed

Description

@chillbrodev

android_libcpp_shared 0.2.0 fails on NDK 28 for arm64-v8a

Package: package:android_libcpp_shared 0.2.0
Repo: dart-lang/native
Flutter: 3.44.2
NDK: 28.2.13676358
Host: macOS with Apple Silicon M1 Pro
Target ABI: arm64-v8a (Pixel 6a)

Error:

Hook.build hook of package:android_libcpp_shared has invalid output
- Code asset "package:android_libcpp_shared/libc++_shared.so" file
  (/Users/.../ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64//sysroot/usr/lib/aarch64-linux-android/libc++_shared.so)
  does not exist as a file.

Root cause:

NDK 28 changed the layout for arm64. There are two issues:

1. Wrong path — missing API-level subdirectory.
The package looks at:

sysroot/usr/lib/aarch64-linux-android/libc++_shared.so

But in NDK 28 the file lives at:

sysroot/usr/lib/aarch64-linux-android/24/libc++.so

2. Wrong filename.
For arm64 in NDK 28 the library is named libc++.so, not libc++_shared.so.

Verification:

# Top-level aarch64 directory — no libc++_shared.so
ls $NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/aarch64-linux-android/
# libc++_static.a  libc++abi.a  libc++experimental.a  libc.a  ...
# No libc++_shared.so

# API-level subdirectory — libc++.so present under a different name
ls $NDK_HOME/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/aarch64-linux-android/24/
# libc++.so  libc.so  libm.so  libdl.so  ...

# Other ABIs still have libc++_shared.so at the top level (not affected)
find $NDK_HOME -name "libc++_shared.so"
# arm-linux-androideabi, x86_64-linux-android, i686-linux-android, riscv64-linux-android
# Missing: aarch64-linux-android

Additional behaviour:
The build succeeds on the first run because hook output is cached in .dart_tool/hooks_runner/. Subsequent builds (or after flutter clean) fail immediately because the cached file path is validated and the file does not exist. This makes the bug appear intermittent.

Activity

  1. kattaliraees commented on Jun 14, 2026

    @kattaliraees

    Same issue

    Hook.build hook of package:android_libcpp_shared has invalid output
    - Code asset "package:android_libcpp_shared/libc++_shared.so" file (/Users/hostname/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64//sysroot/usr/lib/arm-linux-androideabi/libc++_shared.so) does not exist as a file.
    
    ~ find $ANDROID_HOME/ndk/28.2.13676358 -name "libc++_shared.so" 2>/dev/null
    /Users/hostname/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so
    /Users/hostname/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/i686-linux-android/libc++_shared.so
    /Users/hostname/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/riscv64-linux-android/libc++_shared.so

    had to do this for the build to succeed

    dependency_overrides:
      android_libcpp_shared: 0.1.1
  2. chillbrodev commented on Jun 15, 2026

    @chillbrodev
    Author

    Good call, I ended up building my C++ library with ANDROID_STL=c++_static instead but good to know you can downgrade and have it work. Thanks for that

    Same issue

    Hook.build hook of package:android_libcpp_shared has invalid output

    • Code asset "package:android_libcpp_shared/libc++_shared.so" file (/Users/hostname/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64//sysroot/usr/lib/arm-linux-androideabi/libc++_shared.so) does not exist as a file.

    ~ find $ANDROID_HOME/ndk/28.2.13676358 -name "libc++_shared.so" 2>/dev/null
    /Users/hostname/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so
    /Users/hostname/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/i686-linux-android/libc++_shared.so
    /Users/hostname/Library/Android/sdk/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/riscv64-linux-android/libc++_shared.so
    had to do this for the build to succeed

    dependency_overrides:
    android_libcpp_shared: 0.1.1

  3. chillbrodev commented on Aug 7, 2026

    @chillbrodev
    Author

    @zeyus Bump on this

  4. zeyus commented on Aug 7, 2026

    @zeyus
    Member

    @chillbrodev thanks for the ping, I don't know what is going on with my github, but I haven't had any notifications for this repo. I will take a look next week, including the pending PRs. Sorry for the delay, I also just got back from vacation

  5. chillbrodev commented on Aug 11, 2026

    @chillbrodev
    Author

    @chillbrodev thanks for the ping, I don't know what is going on with my github, but I haven't had any notifications for this repo. I will take a look next week, including the pending PRs. Sorry for the delay, I also just got back from vacation

    No worries, GitHub has been weird lately. I hope your vacation was good. If you need anything please let me know. I am happy to test as needed.

  6. zeyus commented on Aug 12, 2026

    @zeyus
    Member

    @chillbrodev Just investigating this, it's odd, on my linux machine and my macos I see that specific libc++_shared.so

    Linux ndk 28:

    Image

    Linux ndk 29:

    Image

    And MacOS:

    Image Image Image
  7. zeyus commented on Aug 12, 2026

    @zeyus
    Member

    @kattaliraees @chillbrodev I'm about to push a fix that will more helpfully fail and checks more paths.

    But it might be helpful if you both can run:
    find /path/to/ndk -name 'libc++_shared.so'
    and share the output, as that file should exist in each NDK version, if it doesn't it could be a partial/corrupt install

  8. added a commit that references this issue on Aug 12, 2026
    4c7d50d
  9. zeyus commented on Aug 12, 2026

    @zeyus
    Member

    btw @chillbrodev libc++_shared.so is different from libc++.so so it can't just replace one with the other.

    I've just released version 0.2.1 which has (hopefully) the fix for this, it should at the very least give you more information about when it fails.

    And you can now specify the location of the NDK root (or the path the the specific libc++_shared.so either via an env var ANDROID_LIBCPP_SHARED_PATH or, in your pubspec.yaml (this avoids gradle cache but of course, then there's a hardcoded path in the pubspec which is probably less useful in most cases):

    hooks:
      user_defines:
        android_libcpp_shared:
          libcpp_shared_path: /path/to/libc++_shared.so
  10. added a commit that references this issue on Aug 12, 2026
    8b7de26
  11. chillbrodev commented on Aug 12, 2026

    @chillbrodev
    Author

    @zeyus Okay great, I'll pull this down and give it a go. I think what might have happened is I got a bad NDK stuck in my path. Thanks for investigating this and pushing up some fixes.

    Here is the output you requested for "find /path/to/ndk -name 'libc++_shared.so'"

    ╰─❯ find /Users/uptech/android/ndk/28.2.13676358 -name 'libc++_shared.so'
    /Users/uptech/android/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/arm-linux-androideabi/libc++_shared.so
    /Users/uptech/android/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/x86_64-linux-android/libc++_shared.so
    /Users/uptech/android/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/i686-linux-android/libc++_shared.so
    /Users/uptech/android/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/riscv64-linux-android/libc++_shared.so

  12. zeyus commented on Aug 13, 2026

    @zeyus
    Member

    @zeyus Okay great, I'll pull this down and give it a go. I think what might have happened is I got a bad NDK stuck in my path. Thanks for investigating this and pushing up some fixes.

    Here is the output you requested for "find /path/to/ndk -name 'libc++_shared.so'"

    ╰─❯ find /Users/uptech/android/ndk/28.2.13676358 -name 'libc++_shared.so' /Users/uptech/android/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/arm-linux-androideabi/libc++_shared.so /Users/uptech/android/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/x86_64-linux-android/libc++_shared.so /Users/uptech/android/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/i686-linux-android/libc++_shared.so /Users/uptech/android/ndk/28.2.13676358/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/riscv64-linux-android/libc++_shared.so

    Ah, interesting, it seems like the triple you're targeting (aarch64-linux-android) is not actually there!

    I think that points to a corrupted NDK install, as you can see, each triple should have its own libc++_shared.so, what I would suggest is just deleting that entire NDK directory (rm -rf /Users/uptech/android/ndk/28.2.13676358) and then reinstall ndk 28.2.13676358, using sdkmanager, e.g. sdkmanager --install ndk;28.2.13676358, or using the GUI in Android Studio.

    If you still don't end up with libc++_shared.so there, let me know, at least the package will fail with a more useful error message now. I have 3 NDKs installed on my linux machine, and even more on my macbook, and use this package to compile some native libs, and it has been working, but I would love to pick up on some of these edge cases so it's as easy as possible (e.g. the PR and issue about windows, which I don't have access to for testing) :D

  13. chillbrodev commented on Aug 14, 2026

    @chillbrodev
    Author

    @zeyus I will do the NDK re-install tomorrow and let you know. I also have a windows machine and could test things there for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions