mirror of
https://github.com/fmtlib/fmt.git
synced 2026-02-10 20:30:00 +08:00
Update Android Gradle Plugin to 9.x (#4658)
This commit is contained in:
parent
d58e3f08d0
commit
b7b1abce38
@ -1 +1,2 @@
|
|||||||
<manifest package="dev.fmt" />
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
</manifest>
|
||||||
|
|||||||
@ -1,56 +1,68 @@
|
|||||||
|
//UPDATED: Updated for Android Gradle Plugin 9.x
|
||||||
|
//Removes deprecated APIs
|
||||||
|
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
|
|
||||||
// General gradle arguments for root project
|
// General gradle arguments for root project
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
mavenCentral() // UPDATED: jcenter() is deprecated and shut-down
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
|
/*
|
||||||
|
https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
|
||||||
//
|
//
|
||||||
// https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
|
UPDATED to Android Gradle Plugin 9.0.0
|
||||||
//
|
|
||||||
// Notice that 4.0.0 here is the version of [Android Gradle Plugin]
|
According to URL above you will need Gradle 6.1 or higher
|
||||||
// According to URL above you will need Gradle 6.1 or higher
|
*/
|
||||||
//
|
classpath "com.android.tools.build:gradle:9.0.0"
|
||||||
classpath "com.android.tools.build:gradle:4.1.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
mavenCentral() // UPDATED: jcenter replacement
|
||||||
}
|
}
|
||||||
|
|
||||||
// Project's root where CMakeLists.txt exists: rootDir/support/.cxx -> rootDir
|
// Project's root where CMakeLists.txt exists: rootDir/support/.cxx -> rootDir
|
||||||
|
|
||||||
def rootDir = Paths.get(project.buildDir.getParent()).getParent()
|
def rootDir = Paths.get(project.buildDir.getParent()).getParent()
|
||||||
println("rootDir: ${rootDir}")
|
println("rootDir: ${rootDir}")
|
||||||
|
|
||||||
// Output: Shared library (.so) for Android
|
// Output: Shared library (.so) for Android
|
||||||
|
|
||||||
apply plugin: "com.android.library"
|
apply plugin: "com.android.library"
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 25 // Android 7.0
|
|
||||||
|
|
||||||
// Target ABI
|
// UPDATED: Namespace is now required in build.gralde for AGP 8+ (it was moved from manifest)
|
||||||
// - This option controls target platform of module
|
|
||||||
// - The platform might be limited by compiler's support
|
namespace = "dev.fmt"
|
||||||
// some can work with Clang(default), but some can work only with GCC...
|
|
||||||
// if bad, both toolchains might not support it
|
compileSdk 36 // UPDATED: Target Android 16 (API 36). 'compileSdkVersion' is deprecated
|
||||||
splits {
|
|
||||||
abi {
|
/* Target ABI
|
||||||
enable true
|
- This option controls target platform of module
|
||||||
// Specify platforms for Application
|
- The platform might be limited by compiler's support
|
||||||
reset()
|
some can work with Clang(default), but some can work only with GCC...
|
||||||
include "arm64-v8a", "armeabi-v7a", "x86_64"
|
if bad, both toolchains might not support it
|
||||||
}
|
-* UPDATED: 'splits' block is deprecated for libraries. We now use 'ndk.abifilters' in defaultConfig
|
||||||
}
|
-> splits { abi { ...... } } -> removed
|
||||||
ndkVersion "21.3.6528147" // ANDROID_NDK_HOME is deprecated. Be explicit
|
*/
|
||||||
|
|
||||||
|
ndkVersion = "28.2.13676358" // UPDATED: Locked to stable NDK 28 (AGP 9 defualt). Be explicit.
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 21 // Android 5.0+
|
minSdk 21 // Android 5.0+ (UPDATED: syntax)
|
||||||
targetSdkVersion 25 // Follow Compile SDK
|
targetSdkVersion 36 // Follow Compile SDK (UPDATED: syntax)
|
||||||
versionCode 34 // Follow release count
|
versionCode 34 // Follow release count
|
||||||
versionName "7.1.2" // Follow Official version
|
versionName "7.1.2" // Follow Official version
|
||||||
|
|
||||||
|
// UPDATED: Correct way to filter ABIs for a library in modern AGP
|
||||||
|
ndk{
|
||||||
|
abiFilters "arm64-v8a", "armeabi-v7a", "x86_64"
|
||||||
|
}
|
||||||
|
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
arguments "-DANDROID_STL=c++_shared" // Specify Android STL
|
arguments "-DANDROID_STL=c++_shared" // Specify Android STL
|
||||||
@ -71,7 +83,7 @@ android {
|
|||||||
// neighbor of the top level cmake
|
// neighbor of the top level cmake
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
version "3.10.0+"
|
version = "3.22.1" // UPDATED: 3.10 is too old for AGP 9
|
||||||
path "${rootDir}/CMakeLists.txt"
|
path "${rootDir}/CMakeLists.txt"
|
||||||
// buildStagingDirectory "./build" // Custom path for cmake output
|
// buildStagingDirectory "./build" // Custom path for cmake output
|
||||||
}
|
}
|
||||||
@ -86,20 +98,26 @@ android {
|
|||||||
|
|
||||||
// https://developer.android.com/studio/build/native-dependencies#build_system_configuration
|
// https://developer.android.com/studio/build/native-dependencies#build_system_configuration
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
prefab true
|
prefab = true
|
||||||
prefabPublishing true
|
prefabPublishing = true
|
||||||
}
|
}
|
||||||
prefab {
|
prefab {
|
||||||
fmt {
|
fmt {
|
||||||
headers "${rootDir}/include"
|
headers = "${rootDir}/include"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assemble.doLast
|
assemble.doLast
|
||||||
{
|
{
|
||||||
// Instead of `ninja install`, Gradle will deploy the files.
|
/*
|
||||||
// We are doing this since FMT is dependent to the ANDROID_STL after build
|
*- Instead of `ninja install`, Gradle will deploy the files.
|
||||||
|
*- We are doing this since FMT is dependent to the ANDROID_STL after build
|
||||||
|
|
||||||
|
UPDATED: Path Adjustments
|
||||||
|
-> AGP 9+ often puts intermediates in build/intermediates/cxx/ or similar
|
||||||
|
-> Note: This manual copy is Fragile. If empty, check 'build/intermediates/cxx'.
|
||||||
|
*/
|
||||||
copy {
|
copy {
|
||||||
from "build/intermediates/cmake"
|
from "build/intermediates/cmake"
|
||||||
into "${rootDir}/libs"
|
into "${rootDir}/libs"
|
||||||
|
|||||||
8
support/gradle.properties
Normal file
8
support/gradle.properties
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Required for modern Android builds (AGP 8.0+)
|
||||||
|
android.useAndroidX=true
|
||||||
|
|
||||||
|
# Improves build performance
|
||||||
|
android.nonTransitiveRClass=true
|
||||||
|
|
||||||
|
# Memory settings for the build process
|
||||||
|
org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g
|
||||||
6
support/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
support/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
#This downloads Gradle 9.3 automatically
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.0-bin.zip
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
Loading…
x
Reference in New Issue
Block a user