android / ndk-samples

Android NDK samples with Android Studio
http://developer.android.com/ndk
Apache License 2.0
10.06k stars 4.18k forks source link

Sanitizer: Set useLegacyPackaging for asan #970

Closed robotchaoX closed 8 months ago

robotchaoX commented 9 months ago

[Why] Property useLegacyPackaging determin whether to use the legacy convention of compressing all .so files in the APK. If null, .so files will be uncompressed and page-aligned when minSdk >= 23. Otherwise, it failed with "INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2" when minSdk >= 23. And wrap.sh is only available for API level 27 and above.

[How] Set useLegacyPackaging to true. Set compileSdk to 27.

[Reference] https://developer.android.com/ndk/guides/asan

fmayer commented 9 months ago

@DanAlbert @enh-google PTAL

DanAlbert commented 8 months ago

I added explanatory comments but otherwise LGTM.

DanAlbert commented 8 months ago

... but our CI's broken. I'll go look into that.

DanAlbert commented 8 months ago

GitHub is currently in the middle of rolling out changes to the GHA images that alter how the Android tools are installed: https://github.com/actions/runner-images/issues/8952. That bug says that sdkmanager is supposed to still be there, but maybe that isn't happening. I see Sentry updated their CI to use https://github.com/android-actions/setup-android, which I think tells us the problem:

Adding platform-tools (contains adb) and cmdline-tools/11.0/bin (contains sdkmanager) to $PATH.

I guess sdkmanager moved to a non-predictable location? Awesome. I'll send a PR to switch us over to setup-android.

DanAlbert commented 8 months ago

https://github.com/android/ndk-samples/pull/975 appears to fix it. Once that merges I'll rebase this PR so the checks can re-run, then it should be good to merge.