• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1apply plugin: "com.android.application"
2
3import com.android.build.OutputFile
4
5/**
6 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7 * and bundleReleaseJsAndAssets).
8 * These basically call `react-native bundle` with the correct arguments during the Android build
9 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
10 * bundle directly from the development server. Below you can see all the possible configurations
11 * and their defaults. If you decide to add a configuration block, make sure to add it before the
12 * `apply from: "../../node_modules/react-native/react.gradle"` line.
13 *
14 * project.ext.react = [
15 *   // the name of the generated asset file containing your JS bundle
16 *   bundleAssetName: "index.android.bundle",
17 *
18 *   // the entry file for bundle generation
19 *   entryFile: "index.android.js",
20 *
21 *   // whether to bundle JS and assets in debug mode
22 *   bundleInDebug: false,
23 *
24 *   // whether to bundle JS and assets in release mode
25 *   bundleInRelease: true,
26 *
27 *   // whether to bundle JS and assets in another build variant (if configured).
28 *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
29 *   // The configuration property can be in the following formats
30 *   //         'bundleIn${productFlavor}${buildType}'
31 *   //         'bundleIn${buildType}'
32 *   // bundleInFreeDebug: true,
33 *   // bundleInPaidRelease: true,
34 *   // bundleInBeta: true,
35 *
36 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
37 *   // for example: to disable dev mode in the staging build type (if configured)
38 *   devDisabledInStaging: true,
39 *   // The configuration property can be in the following formats
40 *   //         'devDisabledIn${productFlavor}${buildType}'
41 *   //         'devDisabledIn${buildType}'
42 *
43 *   // the root of your project, i.e. where "package.json" lives
44 *   root: "../../",
45 *
46 *   // where to put the JS bundle asset in debug mode
47 *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
48 *
49 *   // where to put the JS bundle asset in release mode
50 *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
51 *
52 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
53 *   // require('./image.png')), in debug mode
54 *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
55 *
56 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
57 *   // require('./image.png')), in release mode
58 *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
59 *
60 *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
61 *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
62 *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
63 *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
64 *   // for example, you might want to remove it from here.
65 *   inputExcludes: ["android/**", "ios/**"],
66 *
67 *   // override which node gets called and with what additional arguments
68 *   nodeExecutableAndArgs: ["node"],
69 *
70 *   // supply additional arguments to the packager
71 *   extraPackagerArgs: []
72 * ]
73 */
74
75project.ext.react = [
76    entryFile: "index.js",
77    // your index js if not default, other settings
78    // Hermes JSC ?
79    enableHermes: false,
80]
81
82apply from: "../../node_modules/react-native/react.gradle"
83
84/**
85 * Set this to true to create two separate APKs instead of one:
86 *   - An APK that only works on ARM devices
87 *   - An APK that only works on x86 devices
88 * The advantage is the size of the APK is reduced by about 4MB.
89 * Upload all the APKs to the Play Store and people will download
90 * the correct one based on the CPU architecture of their device.
91 */
92def enableSeparateBuildPerCPUArchitecture = false
93
94/**
95 * Run Proguard to shrink the Java bytecode in release builds.
96 */
97def enableProguardInReleaseBuilds = false
98
99
100/**
101 * Use international variant JavaScriptCore
102 * International variant includes ICU i18n library and necessary data allowing to use
103 * e.g. Date.toLocaleString and String.localeCompare that give correct results
104 * when using with locales other than en-US.
105 * Note that this variant is about 6MiB larger per architecture than default.
106 */
107def useIntlJsc = false
108
109
110android {
111    compileSdkVersion rootProject.ext.compileSdkVersion
112
113    compileOptions {
114        sourceCompatibility JavaVersion.VERSION_1_8
115        targetCompatibility JavaVersion.VERSION_1_8
116    }
117
118    defaultConfig {
119        applicationId "com.test"
120        minSdkVersion rootProject.ext.minSdkVersion
121        targetSdkVersion rootProject.ext.targetSdkVersion
122        versionCode 1
123        versionName "1.0"
124
125        testBuildType System.getProperty('testBuildType', 'debug')  // This will later be used to control the test apk build type
126        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
127    }
128    splits {
129        abi {
130            reset()
131            enable enableSeparateBuildPerCPUArchitecture
132            universalApk false  // If true, also generate a universal APK
133            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
134        }
135    }
136    buildTypes {
137        release {
138            minifyEnabled enableProguardInReleaseBuilds
139            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
140        }
141    }
142    // applicationVariants are e.g. debug, release
143    applicationVariants.all { variant ->
144        variant.outputs.each { output ->
145            // For each separate APK per architecture, set a unique version code as described here:
146            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
147            def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
148            def abi = output.getFilter(OutputFile.ABI)
149            if (abi != null) {  // null for the universal-debug, universal-release variants
150                output.versionCodeOverride =
151                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
152            }
153        }
154    }
155}
156
157dependencies {
158  implementation project(':ejdb2_react_native')
159  implementation fileTree(dir: "libs", include: ["*.jar"])
160  implementation "androidx.annotation:annotation:1.1.0"
161  implementation 'androidx.appcompat:appcompat:1.1.0'
162  implementation 'androidx.legacy:legacy-support-v4:1.0.0'
163  implementation "com.facebook.react:react-native:+"  // From node_modules
164  androidTestImplementation('com.wix:detox:+') { transitive = true }
165  androidTestImplementation 'junit:junit:4.12'
166
167  // JSC from node_modules
168  if (useIntlJsc) {
169    implementation 'org.webkit:android-jsc-intl:+'
170  } else {
171    implementation 'org.webkit:android-jsc:+'
172  }
173}
174
175
176// Run this once to be able to run the application with BUCK
177// puts all compile dependencies into folder libs for BUCK to use
178task copyDownloadableDepsToLibs(type: Copy) {
179    from configurations.compile
180    into 'libs'
181}
182