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 // Added by install-expo-modules 58 entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", rootDir.getAbsoluteFile().getParentFile().getAbsolutePath(), "android", "absolute"].execute(null, rootDir).text.trim()) 59 cliFile = new File(["node", "--print", "require.resolve('@expo/cli')"].execute(null, rootDir).text.trim()) 60 bundleCommand = "export:embed" 61} 62 63/** 64 * Set this to true to Run Proguard on Release builds to minify the Java bytecode. 65 */ 66def enableProguardInReleaseBuilds = false 67 68/** 69 * The preferred build flavor of JavaScriptCore (JSC) 70 * 71 * For example, to use the international variant, you can use: 72 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` 73 * 74 * The international variant includes ICU i18n library and necessary data 75 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that 76 * give correct results when using with locales other than en-US. Note that 77 * this variant is about 6MiB larger per architecture than default. 78 */ 79def jscFlavor = 'org.webkit:android-jsc:+' 80 81// !! Add lines 82def keystoreProperties = new Properties() 83def keystorePropertiesFile = rootProject.file('keystore.properties') 84if (keystorePropertiesFile.exists()) { 85 keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) 86} 87 88static def getVersion() { 89 def inputFile = new File("../package.json") 90 def packageJson = new JsonSlurper().parseText(inputFile.text) 91 return packageJson["version"] 92} 93 94static def versionStringToCode(String version) { 95 def parts = version.split('\\.') 96 def versionCode = 0 97 def multiplier = 1000000 98 99 parts.each { part -> 100 versionCode += part.toInteger() * multiplier 101 multiplier /= 1000 102 } 103 104 return versionCode.intValue() 105} 106 107def appVersion = getVersion() 108def appVersionCode = versionStringToCode(appVersion) 109 110 111android { 112 ndkVersion rootProject.ext.ndkVersion 113 buildToolsVersion rootProject.ext.buildToolsVersion 114 compileSdk rootProject.ext.compileSdkVersion 115 116 namespace "fun.upup.musicfree" 117 118 defaultConfig { 119 applicationId "fun.upup.musicfree" 120 minSdkVersion rootProject.ext.minSdkVersion 121 targetSdkVersion rootProject.ext.targetSdkVersion 122 versionCode appVersionCode 123 versionName appVersion 124 } 125 signingConfigs { 126 debug { 127 storeFile file('debug.keystore') 128 storePassword 'android' 129 keyAlias 'androiddebugkey' 130 keyPassword 'android' 131 } 132 // !! Add lines 133 release { 134 storeFile file(keystoreProperties['RELEASE_STORE_FILE']) 135 storePassword keystoreProperties['RELEASE_STORE_PASSWORD'] 136 keyAlias keystoreProperties['RELEASE_KEY_ALIAS'] 137 keyPassword keystoreProperties['RELEASE_KEY_PASSWORD'] 138 } 139 } 140 splits { 141 abi { 142 reset() 143 enable true 144 universalApk true 145 include "armeabi-v7a", "arm64-v8a", "x86", "x86_64" 146 } 147 } 148 149 applicationVariants.all { variant -> 150 variant.outputs.each { output -> 151 def versionCodes = ["armeabi-v7a": 1, "arm64-v8a": 2, "x86": 3, "x86_64": 4] 152 153 def abi = output.getFilter(OutputFile.ABI) 154 155 if (abi != null) { 156 output.versionCodeOverride = defaultConfig.versionCode * 100 + versionCodes.get(abi); 157 } else { 158 output.versionCodeOverride = defaultConfig.versionCode * 100 159 } 160 } 161 } 162 163 buildTypes { 164 debug { 165 signingConfig signingConfigs.debug 166 } 167 release { 168 // Caution! In production, you need to generate your own keystore file. 169 // see https://reactnative.dev/docs/signed-apk-android. 170 signingConfig signingConfigs.release 171 minifyEnabled enableProguardInReleaseBuilds 172 proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 173 } 174 } 175} 176 177dependencies { 178 // The version of react-native is set by the React Native Gradle Plugin 179 implementation("com.facebook.react:react-android") 180 181 if (hermesEnabled.toBoolean()) { 182 implementation("com.facebook.react:hermes-android") 183 } else { 184 implementation jscFlavor 185 } 186 187 // !! Add lines 188 implementation project(':react-native-fs') 189 implementation 'com.facebook.fresco:animated-gif:2.5.0' 190 // https://mvnrepository.com/artifact/net.jthink/jaudiotagger 191 implementation 'net.jthink:jaudiotagger:2.2.5' 192} 193 194apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) 195