apply plugin: "com.android.application" apply plugin: "org.jetbrains.kotlin.android" apply plugin: "com.facebook.react" apply plugin: "com.google.gms.google-services" apply plugin: "com.google.firebase.crashlytics" /** * This is the configuration block to customize your React Native Android app. * By default you don't need to apply any configuration, just uncomment the lines you need */ react { /* Folders */ // The root of your project, i.e. where "package.json" lives. Default is '..' // root = file("../") // The folder where the react-native NPM package is. Default is ../node_modules/react-native // reactNativeDir = file("../node_modules/react-native") // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen // codegenDir = file("../node_modules/@react-native/codegen") // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js // cliFile = file("../node_modules/react-native/cli.js") /* Variants */ // The list of variants to that are debuggable. For those we're going to // skip the bundling of the JS bundle and the assets. By default is just 'debug'. // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants. // debuggableVariants = ["liteDebug", "prodDebug"] /* Bundling */ // A list containing the node command and its flags. Default is just 'node'. // nodeExecutableAndArgs = ["node"] // // The command to run when bundling. By default is 'bundle' // bundleCommand = "ram-bundle" // // The path to the CLI configuration file. Default is empty. // bundleConfig = file(../rn-cli.config.js) // // The name of the generated asset file containing your JS bundle // bundleAssetName = "MyApplication.android.bundle" // // The entry file for bundle generation. Default is 'index.android.js' or 'index.js' // entryFile = file("../js/MyApplication.android.js") // // A list of extra flags to pass to the 'bundle' commands. // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle // extraPackagerArgs = [] /* Hermes Commands */ // The hermes compiler command to run. By default it is 'hermesc' // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc" // // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map" // hermesFlags = ["-O", "-output-source-map"] // 启用自动链接 autolinkLibrariesWithApp() } /** * Set this to true to Run Proguard on Release builds to minify the Java bytecode. */ def enableProguardInReleaseBuilds = true /** * The preferred build flavor of JavaScriptCore (JSC) * * For example, to use the international variant, you can use: * `def jscFlavor = io.github.react-native-community:jsc-android-intl:2026004.+` * * The international variant includes ICU i18n library and necessary data * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that * give correct results when using with locales other than en-US. Note that * this variant is about 6MiB larger per architecture than default. */ def jscFlavor = 'io.github.react-native-community:jsc-android:2026004.+' def getMyVersionCode() { def files = file('version.properties') Properties props = new Properties() props.load(new FileInputStream(files)) def code = props['VERSION_CODE'].toInteger() //def task = gradle.startParameter.taskNames //if ('assembleRelease' in task) { code++ //} props['VERSION_CODE'] = code.toString() props.store(files.newWriter(), null) return code } static def releaseTime() { return new Date().format("yyyyMMdd", TimeZone.getDefault()); } android { ndkVersion rootProject.ext.ndkVersion compileSdk rootProject.ext.compileSdkVersion buildToolsVersion rootProject.ext.buildToolsVersion namespace "com.strides.chargeco" defaultConfig { applicationId "com.strides.chargeco" minSdk rootProject.ext.minSdkVersion targetSdk rootProject.ext.targetSdkVersion versionCode getMyVersionCode() versionName rootProject.ext.versionName multiDexEnabled true } signingConfigs { debug { storeFile file('vbea.keystore') storePassword 'dec2020' keyAlias 'vbea' keyPassword 'dec2020' } release { storeFile file('vbea.jks') storePassword 'dec2020' keyAlias 'vbea' keyPassword 'dec2020' } } buildTypes { debug { signingConfig signingConfigs.debug //热更新应用分发Staging key //resValue "string", "CodePushDeploymentKey", "zu0zkOWpBhXTGQ83pC15FW3puB--tuSG5TvIQ" } release { // Caution! In production, you need to generate your own keystore file. // see https://reactnative.dev/docs/signed-apk-android. signingConfig signingConfigs.release minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" ndk { // 移除 armeabi,只保留支持 16KB 页面大小的架构 //abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64" abiFilters "arm64-v8a" } //热更新应用分发Production key //resValue "string", "CodePushDeploymentKey", "rQGN1c2GXKx5EBT1scXipC9xwSQZMG62xiWOd" } } // applicationVariants are e.g. debug, release applicationVariants.all { variant -> variant.outputs.all { output -> if (variant.buildType.name=="release") { def fileName = "ChargEco-V${variant.versionName}-${variant.versionCode}" // 加入打包时间 fileName = fileName + "-${releaseTime()}" // 加入版本类型 fileName = fileName + "-${variant.buildType.name}.apk" //output.outputFile = new File(outputFile.parent, fileName) outputFileName = fileName } } } } dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) // The version of react-native is set by the React Native Gradle Plugin implementation "com.facebook.react:react-android" //noinspection GradleDynamicVersion implementation "com.facebook.fresco:animated-gif:3.6.0" // 如果你需要支持GIF动图 implementation "androidx.appcompat:appcompat:1.7.0" implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" if (hermesEnabled.toBoolean()) { implementation("com.facebook.react:hermes-android") } else { implementation jscFlavor } /*implementation(project(':react-native-maps')){ exclude group: 'com.google.android.gms', module: 'play-services-base' exclude group: 'com.google.android.gms', module: 'play-services-maps' } implementation 'com.google.android.gms:play-services-base:17.2.1'*/ /*implementation 'com.google.android.gms:play-services-maps:17.0.0' implementation 'com.google.maps.android:android-maps-utils:2.2.3'*/ implementation platform('com.google.firebase:firebase-bom:33.7.0') implementation 'com.google.firebase:firebase-messaging' implementation 'com.google.firebase:firebase-analytics' implementation 'com.google.firebase:firebase-crashlytics' } //apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle")