Provide option to easily modify app name and version.

Chery-picked from #243.
This commit is contained in:
Miku AuahDark
2023-09-28 13:44:18 +08:00
parent fefb7dfc8d
commit f73a91c0be
3 changed files with 60 additions and 30 deletions
+41 -8
View File
@@ -1,18 +1,21 @@
import java.nio.charset.StandardCharsets
plugins {
id 'com.android.application'
}
android {
namespace "org.love2d.android"
compileSdk 33
ndkVersion "25.2.9519653"
ndkVersion "26.0.10792818"
defaultConfig {
applicationId "org.love2d.android"
versionCode 32
versionName "12.0"
applicationId project.properties["app.application_id"]
versionCode project.properties["app.version_code"].toInteger()
versionName project.properties["app.version_name"]
minSdk 21
targetSdk 33
compileSdk 34
targetSdk 34
externalNativeBuild {
cmake {
arguments "-DANDROID_STL=c++_shared"
@@ -24,6 +27,30 @@ android {
targets "love_android", "OpenAL", "love"
}
}
def getAppName = {
def nameArray = project.properties["app.name_byte_array"]
def name = project.properties["app.name"]
if (name != null && nameArray != null) {
throw new Exception("Only define either `app.name` or `app.name_byte_array` in gradle.properties, but not both!")
}
if (name == null) {
def nameArraySplit = nameArray.split(",")
def nameBytes = new byte[nameArraySplit.length]
def count = 0
for (String s: nameArraySplit) {
nameBytes[count++] = (byte) Integer.parseInt(s)
}
return new String(nameBytes, StandardCharsets.UTF_8)
}
return name
}
manifestPlaceholders = [
NAME:getAppName(),
ORIENTATION:project.properties["app.orientation"],
]
}
def retrieveAll3pModules = { ->
@@ -33,6 +60,7 @@ android {
if (details.isDirectory()) {
if (file(details.file.path + "/Android.mk").exists() ||
file(details.file.path + "/CMakeLists.mk").exists()) {
def logger = project.getLogger()
logger.lifecycle("3rd-party module: " + details.file.path)
def javainfo = file(details.file.path + "/java.txt")
@@ -71,7 +99,7 @@ android {
prefab true
}
flavorDimensions 'mode', 'recording'
flavorDimensions = ['mode', 'recording']
productFlavors {
normal {
dimension 'mode'
@@ -123,7 +151,12 @@ android {
}
packagingOptions {
jniLibs {
excludes += ['lib/armeabi-v7a/libOpenSLES.so', 'lib/arm64-v8a/libOpenSLES.so', 'lib/x86/libOpenSLES.so', 'lib/x86_64/libOpenSLES.so']
excludes += [
'lib/armeabi-v7a/libOpenSLES.so',
'lib/arm64-v8a/libOpenSLES.so',
'lib/x86/libOpenSLES.so',
'lib/x86_64/libOpenSLES.so'
]
}
}
}
+2 -2
View File
@@ -24,7 +24,7 @@
<application
android:allowBackup="true"
android:icon="@drawable/love"
android:label="LÖVE for Android">
android:label="${NAME}">
<!-- You don't have to change the activity class unless you have special needs! !-->
<activity
android:name="org.love2d.android.GameActivity"
@@ -32,7 +32,7 @@
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"
android:launchMode="singleInstance"
android:screenOrientation="landscape">
android:screenOrientation="${ORIENTATION}">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
+17 -20
View File
@@ -1,22 +1,19 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
# To set the application display name, only define either `app.name` or `app.name_byte_array`.
# For a rule of thumb:
# * Use `app.name` if your app name doesn't contain any non-ANSI characters.
# * Otherwise, convert your app name to UTF-8 byte array, comma delimited, and put
# it in `app.name_byte_array`
#app.name=LÖVE for Android
app.name_byte_array=76,195,150,86,69,32,102,111,114,32,65,110,100,114,111,105,100
app.application_id=org.love2d.android
app.orientation=landscape
app.version_code=32
app.version_name=12.0
# No need to modify anything past this line!
android.enableJetifier=false
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
android.nonTransitiveRClass=true
android.nonFinalResIds=true