-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Expand file tree
/
Copy pathAndroidLibraryConventionPlugin.kt
More file actions
82 lines (76 loc) · 3.14 KB
/
AndroidLibraryConventionPlugin.kt
File metadata and controls
82 lines (76 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.android.ndk.samples.buildlogic
import com.android.build.api.dsl.LibraryExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import java.lang.System.getProperty
class AndroidLibraryConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.android.library")
}
extensions.configure<LibraryExtension> {
compileSdk = Versions.COMPILE_SDK
ndkVersion = Versions.NDK
externalNativeBuild {
cmake {
version = Versions.CMAKE
}
}
defaultConfig {
minSdk = Versions.MIN_SDK
lint {
targetSdk = Versions.TARGET_SDK
}
testOptions {
targetSdk = Versions.TARGET_SDK
}
externalNativeBuild {
cmake {
arguments.add("-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON")
// Determine if the OS is Windows
val isWindows = getProperty("os.name").lowercase().contains("win")
val cmakeModulePath = if (isWindows) {
rootDir.resolve("cmake").toString().replace('\\', '/')
} else {
rootDir.resolve("cmake").toString()
}
arguments.add("-DCMAKE_MODULE_PATH=$cmakeModulePath")
}
}
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
targetCompatibility = Versions.JAVA
}
// Studio will not automatically pass logcat through ndk-stack, so we need to avoid
// stripping debug binaries if we want the crash trace to be readable.
buildTypes {
debug {
packaging {
jniLibs {
keepDebugSymbols += "**/*.so"
}
}
}
}
}
}
}
}