xref: /MusicFree/android/app/build.gradle (revision 6613e77203923e5b1742a49281bfa5de03fc1440)
1apply plugin: "com.android.application"
2apply plugin: "org.jetbrains.kotlin.android"
3apply plugin: "com.facebook.react"
4
5import com.android.build.OutputFile
6import groovy.json.JsonSlurper
7
8
9/**
10 * This is the configuration block to customize your React Native Android app.
11 * By default you don't need to apply any configuration, just uncomment the lines you need.
12 */
13react {
14    /* Folders */
15    //   The root of your project, i.e. where "package.json" lives. Default is '../..'
16    // root = file("../../")
17    //   The folder where the react-native NPM package is. Default is ../../node_modules/react-native
18    // reactNativeDir = file("../../node_modules/react-native")
19    //   The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
20    // codegenDir = file("../../node_modules/@react-native/codegen")
21    //   The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
22    // cliFile = file("../../node_modules/react-native/cli.js")
23
24    /* Variants */
25    //   The list of variants to that are debuggable. For those we're going to
26    //   skip the bundling of the JS bundle and the assets. By default is just 'debug'.
27    //   If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
28    // debuggableVariants = ["liteDebug", "prodDebug"]
29
30    /* Bundling */
31    //   A list containing the node command and its flags. Default is just 'node'.
32    // nodeExecutableAndArgs = ["node"]
33    //
34    //   The command to run when bundling. By default is 'bundle'
35    // bundleCommand = "ram-bundle"
36    //
37    //   The path to the CLI configuration file. Default is empty.
38    // bundleConfig = file(../rn-cli.config.js)
39    //
40    //   The name of the generated asset file containing your JS bundle
41    // bundleAssetName = "MyApplication.android.bundle"
42    //
43    //   The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
44    // entryFile = file("../js/MyApplication.android.js")
45    //
46    //   A list of extra flags to pass to the 'bundle' commands.
47    //   See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
48    // extraPackagerArgs = []
49
50    /* Hermes Commands */
51    //   The hermes compiler command to run. By default it is 'hermesc'
52    // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
53    //
54    //   The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
55    // hermesFlags = ["-O", "-output-source-map"]
56
57    /* Autolinking */
58    autolinkLibrariesWithApp()
59
60    //
61    // Added by install-expo-modules
62    entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", rootDir.getAbsoluteFile().getParentFile().getAbsolutePath(), "android", "absolute"].execute(null, rootDir).text.trim())
63    cliFile = new File(["node", "--print", "require.resolve('@expo/cli')"].execute(null, rootDir).text.trim())
64    bundleCommand = "export:embed"
65    //
66    // Added by install-expo-modules
67    entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", rootDir.getAbsoluteFile().getParentFile().getAbsolutePath(), "android", "absolute"].execute(null, rootDir).text.trim())
68    cliFile = new File(["node", "--print", "require.resolve('@expo/cli')"].execute(null, rootDir).text.trim())
69    bundleCommand = "export:embed"
70}
71
72/**
73 * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
74 */
75def enableProguardInReleaseBuilds = false
76
77/**
78 * The preferred build flavor of JavaScriptCore (JSC)
79 *
80 * For example, to use the international variant, you can use:
81 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
82 *
83 * The international variant includes ICU i18n library and necessary data
84 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
85 * give correct results when using with locales other than en-US. Note that
86 * this variant is about 6MiB larger per architecture than default.
87 */
88def jscFlavor = 'org.webkit:android-jsc:+'
89
90// !! Add lines
91def keystoreProperties = new Properties()
92def keystorePropertiesFile = rootProject.file('keystore.properties')
93if (keystorePropertiesFile.exists()) {
94    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
95}
96
97static def getVersion() {
98    def inputFile = new File("../package.json")
99    def packageJson = new JsonSlurper().parseText(inputFile.text)
100    return packageJson["version"]
101}
102
103// static def versionStringToCode(String version) {
104//     def parts = version.split('\\.')
105//     def versionCode = 0
106//     def multiplier = 1000000
107//
108//     parts.each { part ->
109//         versionCode += part.toInteger() * multiplier
110//         multiplier /= 1000
111//     }
112//
113//     return versionCode.intValue()
114// }
115
116def appVersion = getVersion()
117def appVersionCode = 400011
118
119
120android {
121    ndkVersion rootProject.ext.ndkVersion
122    buildToolsVersion rootProject.ext.buildToolsVersion
123    compileSdk rootProject.ext.compileSdkVersion
124
125    namespace "fun.upup.musicfree"
126
127    defaultConfig {
128        applicationId "fun.upup.musicfree"
129        minSdkVersion rootProject.ext.minSdkVersion
130        targetSdkVersion rootProject.ext.targetSdkVersion
131        versionCode appVersionCode
132        versionName appVersion
133    }
134    signingConfigs {
135        debug {
136            storeFile file('debug.keystore')
137            storePassword 'android'
138            keyAlias 'androiddebugkey'
139            keyPassword 'android'
140        }
141        // !! Add lines
142         release {
143            storeFile file(keystoreProperties['RELEASE_STORE_FILE'])
144            storePassword keystoreProperties['RELEASE_STORE_PASSWORD']
145            keyAlias keystoreProperties['RELEASE_KEY_ALIAS']
146            keyPassword keystoreProperties['RELEASE_KEY_PASSWORD']
147        }
148    }
149    splits {
150            abi {
151                reset()
152                enable true
153                universalApk true
154                include "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
155            }
156    }
157
158
159
160    buildTypes {
161        debug {
162            signingConfig signingConfigs.debug
163        }
164        release {
165            // Caution! In production, you need to generate your own keystore file.
166            // see https://reactnative.dev/docs/signed-apk-android.
167            signingConfig signingConfigs.release
168            minifyEnabled enableProguardInReleaseBuilds
169            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
170        }
171    }
172}
173
174dependencies {
175    // The version of react-native is set by the React Native Gradle Plugin
176    implementation("com.facebook.react:react-android")
177
178    if (hermesEnabled.toBoolean()) {
179        implementation("com.facebook.react:hermes-android")
180    } else {
181        implementation jscFlavor
182    }
183
184    // !! Add lines
185    implementation project(':react-native-fs')
186    implementation 'com.facebook.fresco:animated-gif:2.5.0'
187    // https://mvnrepository.com/artifact/net.jthink/jaudiotagger
188    implementation 'net.jthink:jaudiotagger:2.2.5'
189}
190
191