Change way to set app name and application id for android app

M committed Jan 11, 2022 at 19:23 UTC da170118a8ab9df917edab3079c707741af112d4
4 files changed +22 -2
.gitignore
+1
@@ -129,3 +129,4 @@ assets/images/app_logo.png
129
130 /pubspec.yaml
131 /pubspec.lock
132 +/android/app.properties
android/app/build.gradle
+8 -2
@@ -30,6 +30,12 @@ if (keystorePropertiesFile.exists()) {
30 keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
31 }
32
33 +def appProperties = new Properties()
34 +def appPropertiesFile = rootProject.file('app.properties')
35 +if (appPropertiesFile.exists()) {
36 + keystoreProperties.load(new FileInputStream(appPropertiesFile))
37 +}
38 +
39 android {
40 compileSdkVersion 29
41
@@ -38,13 +44,13 @@ android {
44 }
45
46 defaultConfig {
41 - applicationId System.getenv('APP_ANDROID_ID')
47 + applicationId appProperties['id']
48 minSdkVersion 21
49 targetSdkVersion 29
50 versionCode flutterVersionCode.toInteger()
51 versionName flutterVersionName
52 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
47 - manifestPlaceholders = [APP_NAME: System.getenv('APP_ANDROID_NAME')]
53 + manifestPlaceholders = [APP_NAME: appProperties['name']]
54
55 externalNativeBuild {
56 cmake {
scripts/android/app_config.sh
+1
@@ -5,6 +5,7 @@ if [ -z "$APP_ANDROID_TYPE" ]; then
5 exit 1
6 fi
7
8 +./app_properties.sh
9 ./app_icon.sh
10
11 CONFIG_ARGS=""
scripts/android/app_properties.sh new
+12
@@ -0,0 +1,12 @@
1 +#!/bin/bash
2 +
3 +APP_PROPERTIES_PATH=./../../android/app.properties
4 +
5 +if [ -z "$APP_ANDROID_TYPE" ]; then
6 + echo "Please set APP_ANDROID_TYPE"
7 + exit 1
8 +fi
9 +
10 +touch $APP_PROPERTIES_PATH
11 +
12 +echo -e "id=${APP_ANDROID_BUNDLE_ID}\nname=${APP_ANDROID_NAME}" > $APP_PROPERTIES_PATH
\ No newline at end of file