From a4f70e70eb9af27c1eb783b2325e122e14300fbd Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Mon, 7 Oct 2024 16:11:46 -0700 Subject: [PATCH] Use testOnly in unit-test sample. Fixes https://github.com/android/ndk-samples/issues/1083. --- unit-test/app/build.gradle | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/unit-test/app/build.gradle b/unit-test/app/build.gradle index d7b63c55f..9c6274706 100644 --- a/unit-test/app/build.gradle +++ b/unit-test/app/build.gradle @@ -24,14 +24,20 @@ android { viewBinding true prefab true } + packagingOptions { - // Libraries that are wrongly included in the junit-gtest AAR that will - // end up in our APK if we don't explicitly exclude them. jniLibs { - excludes += ['**/libadder.so', '**/libapptest.so', '**/libc++_shared.so'] + // Gradle has no way of knowing which of the libraries in our + // CMakeLists.txt are for the app and which are for tests, so we + // have to tell it which libraries are test libraries. Without + // this, the test libraries will end up packaged in the real API + // and not just the test APK. + // + // If you copy this project, be sure to update this to specify the + // names of your own test libraries. + testOnly += ["**/libapp_tests.so"] } } - } dependencies {