1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Add export setting to specify whether the native libraries should be compressed for the gradle build

This commit is contained in:
Fredia Huya-Kouadio
2024-02-15 17:43:32 -08:00
parent a9bb8509f2
commit a69a585c91
4 changed files with 43 additions and 0 deletions

View File

@@ -116,6 +116,14 @@ android {
if (shouldNotStrip()) {
doNotStrip '**/*.so'
}
jniLibs {
// Setting this to true causes AGP to package compressed native libraries when building the app
// For more background, see:
// - https://developer.android.com/build/releases/past-releases/agp-3-6-0-release-notes#extractNativeLibs
// - https://stackoverflow.com/a/44704840
useLegacyPackaging shouldUseLegacyPackaging()
}
}
signingConfigs {

View File

@@ -361,3 +361,26 @@ ext.shouldSign = { ->
ext.shouldNotStrip = { ->
return isAndroidStudio() || project.hasProperty("doNotStrip")
}
/**
* Whether to use the legacy convention of compressing all .so files in the APK.
*
* For more background, see:
* - https://developer.android.com/build/releases/past-releases/agp-3-6-0-release-notes#extractNativeLibs
* - https://stackoverflow.com/a/44704840
*/
ext.shouldUseLegacyPackaging = { ->
int minSdk = getExportMinSdkVersion()
if (minSdk < 23) {
// Enforce the default behavior for compatibility with device running api < 23
return true
}
String legacyPackagingFlag = project.hasProperty("compress_native_libraries") ? project.property("compress_native_libraries") : ""
if (legacyPackagingFlag != null && !legacyPackagingFlag.isEmpty()) {
return Boolean.parseBoolean(legacyPackagingFlag)
}
// Default behavior for minSdk >= 23
return false
}