xref: /MusicFree/android/app/build.gradle (revision 6613e77203923e5b1742a49281bfa5de03fc1440)
1bf6e62f2S猫头猫apply plugin: "com.android.application"
25589cdf3S猫头猫apply plugin: "org.jetbrains.kotlin.android"
35589cdf3S猫头猫apply plugin: "com.facebook.react"
4bf6e62f2S猫头猫
5bf6e62f2S猫头猫import com.android.build.OutputFile
6cf2d630eS猫头猫import groovy.json.JsonSlurper
7bf6e62f2S猫头猫
85589cdf3S猫头猫
9bf6e62f2S猫头猫/**
105589cdf3S猫头猫 * This is the configuration block to customize your React Native Android app.
115589cdf3S猫头猫 * By default you don't need to apply any configuration, just uncomment the lines you need.
12bf6e62f2S猫头猫 */
135589cdf3S猫头猫react {
145589cdf3S猫头猫    /* Folders */
15*6613e772Smaotoumao    //   The root of your project, i.e. where "package.json" lives. Default is '../..'
16*6613e772Smaotoumao    // root = file("../../")
17*6613e772Smaotoumao    //   The folder where the react-native NPM package is. Default is ../../node_modules/react-native
18*6613e772Smaotoumao    // reactNativeDir = file("../../node_modules/react-native")
19*6613e772Smaotoumao    //   The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
20*6613e772Smaotoumao    // codegenDir = file("../../node_modules/@react-native/codegen")
21*6613e772Smaotoumao    //   The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
22*6613e772Smaotoumao    // cliFile = file("../../node_modules/react-native/cli.js")
23bf6e62f2S猫头猫
245589cdf3S猫头猫    /* Variants */
255589cdf3S猫头猫    //   The list of variants to that are debuggable. For those we're going to
265589cdf3S猫头猫    //   skip the bundling of the JS bundle and the assets. By default is just 'debug'.
275589cdf3S猫头猫    //   If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
285589cdf3S猫头猫    // debuggableVariants = ["liteDebug", "prodDebug"]
29bf6e62f2S猫头猫
305589cdf3S猫头猫    /* Bundling */
315589cdf3S猫头猫    //   A list containing the node command and its flags. Default is just 'node'.
325589cdf3S猫头猫    // nodeExecutableAndArgs = ["node"]
335589cdf3S猫头猫    //
345589cdf3S猫头猫    //   The command to run when bundling. By default is 'bundle'
355589cdf3S猫头猫    // bundleCommand = "ram-bundle"
365589cdf3S猫头猫    //
375589cdf3S猫头猫    //   The path to the CLI configuration file. Default is empty.
385589cdf3S猫头猫    // bundleConfig = file(../rn-cli.config.js)
395589cdf3S猫头猫    //
405589cdf3S猫头猫    //   The name of the generated asset file containing your JS bundle
415589cdf3S猫头猫    // bundleAssetName = "MyApplication.android.bundle"
425589cdf3S猫头猫    //
435589cdf3S猫头猫    //   The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
445589cdf3S猫头猫    // entryFile = file("../js/MyApplication.android.js")
455589cdf3S猫头猫    //
465589cdf3S猫头猫    //   A list of extra flags to pass to the 'bundle' commands.
475589cdf3S猫头猫    //   See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
485589cdf3S猫头猫    // extraPackagerArgs = []
495589cdf3S猫头猫
505589cdf3S猫头猫    /* Hermes Commands */
515589cdf3S猫头猫    //   The hermes compiler command to run. By default it is 'hermesc'
525589cdf3S猫头猫    // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
535589cdf3S猫头猫    //
545589cdf3S猫头猫    //   The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
555589cdf3S猫头猫    // hermesFlags = ["-O", "-output-source-map"]
56*6613e772Smaotoumao
57*6613e772Smaotoumao    /* Autolinking */
58*6613e772Smaotoumao    autolinkLibrariesWithApp()
59*6613e772Smaotoumao
60*6613e772Smaotoumao    //
61*6613e772Smaotoumao    // Added by install-expo-modules
62*6613e772Smaotoumao    entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", rootDir.getAbsoluteFile().getParentFile().getAbsolutePath(), "android", "absolute"].execute(null, rootDir).text.trim())
63*6613e772Smaotoumao    cliFile = new File(["node", "--print", "require.resolve('@expo/cli')"].execute(null, rootDir).text.trim())
64*6613e772Smaotoumao    bundleCommand = "export:embed"
655589cdf3S猫头猫    //
665589cdf3S猫头猫    // Added by install-expo-modules
675589cdf3S猫头猫    entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", rootDir.getAbsoluteFile().getParentFile().getAbsolutePath(), "android", "absolute"].execute(null, rootDir).text.trim())
685589cdf3S猫头猫    cliFile = new File(["node", "--print", "require.resolve('@expo/cli')"].execute(null, rootDir).text.trim())
695589cdf3S猫头猫    bundleCommand = "export:embed"
705589cdf3S猫头猫}
71bf6e62f2S猫头猫
72bf6e62f2S猫头猫/**
735589cdf3S猫头猫 * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
74bf6e62f2S猫头猫 */
75bf6e62f2S猫头猫def enableProguardInReleaseBuilds = false
76bf6e62f2S猫头猫
77bf6e62f2S猫头猫/**
785589cdf3S猫头猫 * The preferred build flavor of JavaScriptCore (JSC)
79bf6e62f2S猫头猫 *
80bf6e62f2S猫头猫 * For example, to use the international variant, you can use:
81bf6e62f2S猫头猫 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
82bf6e62f2S猫头猫 *
83bf6e62f2S猫头猫 * The international variant includes ICU i18n library and necessary data
84bf6e62f2S猫头猫 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
85bf6e62f2S猫头猫 * give correct results when using with locales other than en-US. Note that
86bf6e62f2S猫头猫 * this variant is about 6MiB larger per architecture than default.
87bf6e62f2S猫头猫 */
88bf6e62f2S猫头猫def jscFlavor = 'org.webkit:android-jsc:+'
89bf6e62f2S猫头猫
905589cdf3S猫头猫// !! Add lines
91bf6e62f2S猫头猫def keystoreProperties = new Properties()
92bf6e62f2S猫头猫def keystorePropertiesFile = rootProject.file('keystore.properties')
93bf6e62f2S猫头猫if (keystorePropertiesFile.exists()) {
94bf6e62f2S猫头猫    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
95bf6e62f2S猫头猫}
96bf6e62f2S猫头猫
975589cdf3S猫头猫static def getVersion() {
98cf2d630eS猫头猫    def inputFile = new File("../package.json")
99cf2d630eS猫头猫    def packageJson = new JsonSlurper().parseText(inputFile.text)
100cf2d630eS猫头猫    return packageJson["version"]
101cf2d630eS猫头猫}
102cf2d630eS猫头猫
103e9e7efbbS猫头猫// static def versionStringToCode(String version) {
104e9e7efbbS猫头猫//     def parts = version.split('\\.')
105e9e7efbbS猫头猫//     def versionCode = 0
106e9e7efbbS猫头猫//     def multiplier = 1000000
107e9e7efbbS猫头猫//
108e9e7efbbS猫头猫//     parts.each { part ->
109e9e7efbbS猫头猫//         versionCode += part.toInteger() * multiplier
110e9e7efbbS猫头猫//         multiplier /= 1000
111e9e7efbbS猫头猫//     }
112e9e7efbbS猫头猫//
113e9e7efbbS猫头猫//     return versionCode.intValue()
114e9e7efbbS猫头猫// }
11517958235S猫头猫
116cf2d630eS猫头猫def appVersion = getVersion()
117e9e7efbbS猫头猫def appVersionCode = 400011
11817958235S猫头猫
119cf2d630eS猫头猫
120bf6e62f2S猫头猫android {
121bf6e62f2S猫头猫    ndkVersion rootProject.ext.ndkVersion
1225589cdf3S猫头猫    buildToolsVersion rootProject.ext.buildToolsVersion
1235589cdf3S猫头猫    compileSdk rootProject.ext.compileSdkVersion
124bf6e62f2S猫头猫
1255589cdf3S猫头猫    namespace "fun.upup.musicfree"
12617958235S猫头猫
127bf6e62f2S猫头猫    defaultConfig {
128bf6e62f2S猫头猫        applicationId "fun.upup.musicfree"
129bf6e62f2S猫头猫        minSdkVersion rootProject.ext.minSdkVersion
130bf6e62f2S猫头猫        targetSdkVersion rootProject.ext.targetSdkVersion
13117958235S猫头猫        versionCode appVersionCode
132cf2d630eS猫头猫        versionName appVersion
133bf6e62f2S猫头猫    }
134bf6e62f2S猫头猫    signingConfigs {
135bf6e62f2S猫头猫        debug {
136bf6e62f2S猫头猫            storeFile file('debug.keystore')
137bf6e62f2S猫头猫            storePassword 'android'
138bf6e62f2S猫头猫            keyAlias 'androiddebugkey'
139bf6e62f2S猫头猫            keyPassword 'android'
140bf6e62f2S猫头猫        }
1415589cdf3S猫头猫        // !! Add lines
142bf6e62f2S猫头猫         release {
143bf6e62f2S猫头猫            storeFile file(keystoreProperties['RELEASE_STORE_FILE'])
144bf6e62f2S猫头猫            storePassword keystoreProperties['RELEASE_STORE_PASSWORD']
145bf6e62f2S猫头猫            keyAlias keystoreProperties['RELEASE_KEY_ALIAS']
146bf6e62f2S猫头猫            keyPassword keystoreProperties['RELEASE_KEY_PASSWORD']
147bf6e62f2S猫头猫        }
148bf6e62f2S猫头猫    }
14917958235S猫头猫    splits {
15017958235S猫头猫            abi {
15117958235S猫头猫                reset()
15217958235S猫头猫                enable true
15317958235S猫头猫                universalApk true
15417958235S猫头猫                include "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
15517958235S猫头猫            }
15617958235S猫头猫    }
15717958235S猫头猫
15817958235S猫头猫
15917958235S猫头猫
160bf6e62f2S猫头猫    buildTypes {
161bf6e62f2S猫头猫        debug {
162bf6e62f2S猫头猫            signingConfig signingConfigs.debug
163bf6e62f2S猫头猫        }
164bf6e62f2S猫头猫        release {
165bf6e62f2S猫头猫            // Caution! In production, you need to generate your own keystore file.
166bf6e62f2S猫头猫            // see https://reactnative.dev/docs/signed-apk-android.
167bf6e62f2S猫头猫            signingConfig signingConfigs.release
168bf6e62f2S猫头猫            minifyEnabled enableProguardInReleaseBuilds
169bf6e62f2S猫头猫            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
170bf6e62f2S猫头猫        }
171bf6e62f2S猫头猫    }
172bf6e62f2S猫头猫}
173bf6e62f2S猫头猫
174bf6e62f2S猫头猫dependencies {
1755589cdf3S猫头猫    // The version of react-native is set by the React Native Gradle Plugin
1765589cdf3S猫头猫    implementation("com.facebook.react:react-android")
177bf6e62f2S猫头猫
1785589cdf3S猫头猫    if (hermesEnabled.toBoolean()) {
1795589cdf3S猫头猫        implementation("com.facebook.react:hermes-android")
180bf6e62f2S猫头猫    } else {
181bf6e62f2S猫头猫        implementation jscFlavor
182bf6e62f2S猫头猫    }
183bf6e62f2S猫头猫
1845589cdf3S猫头猫    // !! Add lines
185bf6e62f2S猫头猫    implementation project(':react-native-fs')
186ed9fd4ceS猫头猫    implementation 'com.facebook.fresco:animated-gif:2.5.0'
1877993f90eS猫头猫    // https://mvnrepository.com/artifact/net.jthink/jaudiotagger
1887993f90eS猫头猫    implementation 'net.jthink:jaudiotagger:2.2.5'
189bf6e62f2S猫头猫}
190bf6e62f2S猫头猫
191