Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions audio-echo/app/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.22.1)
project(echo LANGUAGES C CXX)

add_library(echo
SHARED
SHARED
audio_main.cpp
audio_player.cpp
audio_recorder.cpp
Expand All @@ -12,12 +12,28 @@ add_library(echo

#include libraries needed for echo lib
target_link_libraries(echo
PRIVATE
PRIVATE
OpenSLES
android
log
atomic)

target_compile_options(echo
PRIVATE
-Wall -Werror)
PRIVATE
-Wall
-Werror
)

if (ANDROID_ABI STREQUAL riscv64)
# This sample uses OpenSLES, which was deprecated in API 26. Our
# minSdkVersion is 21, but we also build for riscv64, which isn't a
# supported ABI yet and so that configuration is built for the latest API
# level supported by the NDK.
#
# Longer term, this sample should probably be deleted. App developers
# should be using Oboe rather than OpenSLES, and we already have a separate
# sample for Oboe. There is some potentially useful audio latency
# measurement in this sample that should be moved to the Oboe sample before
# we delete it though.
target_compile_options(echo PRIVATE -Wno-deprecated-declarations)
endif ()
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {
arguments.add("-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON")
}
}

ndk {
// riscv64 isn't a supported Android ABI yet (August 2025), but we're
// enabling it here as part of that experiment. Until it's a supported ABI,
// don't include this in your app, as Play will block uploads of APKs which
// contain riscv64 libraries.
abiFilters.addAll(
listOf(
"arm64-v8a",
"armeabi-v7a",
"riscv64",
"x86",
"x86_64",
)
)
}
}
compileOptions {
sourceCompatibility = Versions.JAVA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
arguments.add("-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON")
}
}
ndk {
// riscv64 isn't a supported Android ABI yet (August 2025), but we're
// enabling it here as part of that experiment. Until it's a supported ABI,
// don't include this in your app, as Play will block uploads of APKs which
// contain riscv64 libraries.
abiFilters.addAll(
listOf(
"arm64-v8a",
"armeabi-v7a",
"riscv64",
"x86",
"x86_64",
)
)
}
}
compileOptions {
sourceCompatibility = Versions.JAVA
Expand Down
6 changes: 6 additions & 0 deletions hello-libs/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ android {
arguments '-DANDROID_STL=c++_static'
}
}

ndk {
// This sample relies on prebuilt libraries, and we haven't built
// rv64 versions of those libraries yet.
abiFilters.remove("riscv64")
}
}

externalNativeBuild {
Expand Down
14 changes: 13 additions & 1 deletion hello-neon/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@ plugins {

android {
namespace 'com.example.helloneon'

defaultConfig {
applicationId "com.example.helloneon"
versionCode 1
versionName "1.0"

ndk {
// rv64 doesn't support Neon intrinsics. You shouldn't really use
// those anyway, since they're just a non-portable wrapper around
// the portable Clang vector intrinsics:
//
// https://clang.llvm.org/docs/LanguageExtensions.html#vectors-and-extended-vectors
//
// TODO: Delete this sample in favor of a better one.
// https://github.com/android/ndk-samples/issues/1011
abiFilters.remove("riscv64")
}
}

externalNativeBuild {
Expand Down
9 changes: 7 additions & 2 deletions hello-oboe/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ plugins {

android {
namespace 'com.google.example.hellooboe'

defaultConfig {
applicationId "com.google.example.hellooboe"
versionCode 1
versionName "1.0"
externalNativeBuild.cmake {
arguments "-DANDROID_STL=c++_shared"
arguments "-DANDROID_STL=c++_shared"
}

ndk {
// Oboe doesn't currently (August 2025) include riscv64 libraries.
abiFilters.remove("riscv64")
}
}

Expand Down
7 changes: 6 additions & 1 deletion hello-vulkan/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ plugins {

android {
namespace 'com.android.hellovk'

defaultConfig {
applicationId 'com.android.hellovk'
// TODO: Figure out why this isn't 24.
Expand All @@ -35,6 +35,11 @@ android {
shaders {
glslcArgs.addAll(['-c'])
}
ndk {
// GameActivity doesn't currently (August 2025) include riscv64
// libraries.
abiFilters.remove("riscv64")
}
}

externalNativeBuild {
Expand Down
13 changes: 13 additions & 0 deletions native-activity/app/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,16 @@ target_link_libraries(native-activity
EGL
GLESv1_CM
log)

if (ANDROID_ABI STREQUAL riscv64)
# This sample uses Sensor Manager and Choreographer APIs which are
# deprecated in modern API levels. Our minSdkVersion is 21, but we also
# build for riscv64, which isn't a supported ABI yet and so that
# configuration is built for the latest API level supported by the NDK.
#
# This sample should be tweaked to use the replacement APIs when they're
# available at runtime and only use the older APIs on older devices. For
# now, just disable the deprecation warnings so we can get the riscv64
# samples building in CI, and we can come back to clean that up later.
target_compile_options(native-activity PRIVATE -Wno-deprecated-declarations)
endif ()
6 changes: 6 additions & 0 deletions prefab/curl-ssl/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ android {
}
}
}

ndk {
// None of the ndkports libraries currently (August 2025) include
// riscv64 libraries.
abiFilters.remove("riscv64")
}
}

externalNativeBuild {
Expand Down
6 changes: 6 additions & 0 deletions prefab/prefab-dependency/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ android {
}
}
}

ndk {
// None of the ndkports libraries currently (August 2025) include
// riscv64 libraries.
abiFilters.remove("riscv64")
}
}

externalNativeBuild {
Expand Down
55 changes: 55 additions & 0 deletions sanitizers/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,59 @@ android {
minSdk 21
versionCode 1
versionName "1.0"

// The sanitizers aren't all mutually compatible, so this sample is
// split into a buildType per sanitizer below. For most of those
// sanitizers, we support every ABI. The HWASan buildType is the
// exception, where we want to enable only arm64-v8a.
//
// Unfortunately, the convention plugin enables every ABI using
// defaultConfig.ndk.abiFilters, which apparently overrides anything we
// do in buildTypes. To be able to control which ABIs get built here
// using buildTypes, we have to undo the work done by the convention
// plugin by clearing the defaultConfig abiFilters. Instead, we enable
// all the ABIs in the debug and release buildTypes below, inherit from
// those for most of the sanitizers, but then again reset the list for
// HWASan to enable only arm64-v8a.
//
// We could instead change the convention plugin to use buildType
// instead, but then all the samples that need to disable rv64 would
// have to do it twice (once for release and once for debug). Since the
// sanitizers sample is the only one that needs this behavior, I'd
// rather keep the mess here rather than spread it around.
ndk {
abiFilters.clear()
}
}

buildTypes {
// Now that the defaultConfig abiFilters have been cleared, the
// buildType abiFilters will actually have an effect. Enable all ABIs,
// since that's what we want for most of the sanitizers.
debug {
ndk {
abiFilters(
"arm64-v8a",
"armeabi-v7a",
"riscv64",
"x86",
"x86_64",
)
}
}

release {
ndk {
abiFilters(
"arm64-v8a",
"armeabi-v7a",
"riscv64",
"x86",
"x86_64",
)
}
}

// HWASan for devices starting from Android 14. Does no longer require a special system image.
// See https://developer.android.com/ndk/guides/hwasan.
hwasan {
Expand All @@ -36,6 +86,11 @@ android {
}
}
ndk {
// The defaultConfig's abiFilters were cleared above, but then
// we also populated the debug buildType's abiFilters with all
// ABIs, which the hwasan buildType inherits. We only want
// arm64-v8a here.
abiFilters.clear()
abiFilters "arm64-v8a"
}
}
Expand Down
Binary file not shown.
6 changes: 6 additions & 0 deletions unit-test/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ android {
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

ndk {
// junit-gtest and googletest don't currently (August 2025) include
// riscv64 libraries.
abiFilters.remove("riscv64")
}
}

externalNativeBuild {
Expand Down