Skip to content

Commit 8727ced

Browse files
authored
Migrate Android to RN75 (#58)
* upgrade android * revert nitro change * remove flipper * fix: wrong app name
1 parent c3352a8 commit 8727ced

File tree

23 files changed

+256
-448
lines changed

23 files changed

+256
-448
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.reactnativequicksqlite">
2+
package="com.margelo.reactnativequicksqlite">
33

44
</manifest>

android/src/main/java/com/reactnativequicksqlite/QuickSQLiteBridge.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.reactnativequicksqlite;
1+
package com.margelo.reactnativequicksqlite;
22

33
import android.util.Log;
44

@@ -7,20 +7,23 @@
77
import com.facebook.react.turbomodule.core.CallInvokerHolderImpl;
88

99
public class QuickSQLiteBridge {
10-
private native void installNativeJsi(long jsContextNativePointer, CallInvokerHolderImpl jsCallInvokerHolder, String docPath);
10+
private native void installNativeJsi(long jsContextNativePointer, CallInvokerHolderImpl jsCallInvokerHolder,
11+
String docPath);
12+
1113
private native void clearStateNativeJsi();
14+
1215
public static final QuickSQLiteBridge instance = new QuickSQLiteBridge();
1316

1417
public void install(ReactContext context) {
15-
long jsContextPointer = context.getJavaScriptContextHolder().get();
16-
CallInvokerHolderImpl jsCallInvokerHolder = (CallInvokerHolderImpl)context.getCatalystInstance().getJSCallInvokerHolder();
17-
final String path = context.getFilesDir().getAbsolutePath();
18-
19-
installNativeJsi(
18+
long jsContextPointer = context.getJavaScriptContextHolder().get();
19+
CallInvokerHolderImpl jsCallInvokerHolder = (CallInvokerHolderImpl) context.getCatalystInstance()
20+
.getJSCallInvokerHolder();
21+
final String path = context.getFilesDir().getAbsolutePath();
22+
23+
installNativeJsi(
2024
jsContextPointer,
2125
jsCallInvokerHolder,
22-
path
23-
);
26+
path);
2427
}
2528

2629
public void clearState() {

android/src/main/java/com/reactnativequicksqlite/SequelModule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.reactnativequicksqlite;
1+
package com.margelo.reactnativequicksqlite;
22

33
import androidx.annotation.NonNull;
44
import android.util.Log;
@@ -12,7 +12,7 @@
1212

1313
class SequelModule extends ReactContextBaseJavaModule {
1414
public static final String NAME = "QuickSQLite";
15-
15+
1616
public SequelModule(ReactApplicationContext context) {
1717
super(context);
1818
}

android/src/main/java/com/reactnativequicksqlite/SequelPackage.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.reactnativequicksqlite;
1+
package com.margelo.reactnativequicksqlite;
22

33
import androidx.annotation.NonNull;
44

@@ -11,7 +11,6 @@
1111
import java.util.Collections;
1212
import java.util.List;
1313

14-
1514
public class SequelPackage implements ReactPackage {
1615
@NonNull
1716
@Override
@@ -24,4 +23,4 @@ public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext r
2423
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
2524
return Collections.emptyList();
2625
}
27-
}
26+
}

example/android/app/_BUCK

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ android_library(
3535

3636
android_build_config(
3737
name = "build_config",
38-
package = "com.quicksqliteexample",
38+
package = "com.margelo.reactnativequicksqlite.example",
3939
)
4040

4141
android_resource(
4242
name = "res",
43-
package = "com.quicksqliteexample",
43+
package = "com.margelo.reactnativequicksqlite.example",
4444
res = "src/main/res",
4545
)
4646

example/android/app/build.gradle

Lines changed: 59 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,89 @@
11
apply plugin: "com.android.application"
2+
apply plugin: "org.jetbrains.kotlin.android"
23
apply plugin: "com.facebook.react"
34

4-
import com.android.build.OutputFile
5-
65
/**
7-
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
8-
* and bundleReleaseJsAndAssets).
9-
* These basically call `react-native bundle` with the correct arguments during the Android build
10-
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
11-
* bundle directly from the development server. Below you can see all the possible configurations
12-
* and their defaults. If you decide to add a configuration block, make sure to add it before the
13-
* `apply from: "../../node_modules/react-native/react.gradle"` line.
14-
*
15-
* project.ext.react = [
16-
* // the name of the generated asset file containing your JS bundle
17-
* bundleAssetName: "index.android.bundle",
18-
*
19-
* // the entry file for bundle generation. If none specified and
20-
* // "index.android.js" exists, it will be used. Otherwise "index.js" is
21-
* // default. Can be overridden with ENTRY_FILE environment variable.
22-
* entryFile: "index.android.js",
23-
*
24-
* // https://reactnative.dev/docs/performance#enable-the-ram-format
25-
* bundleCommand: "ram-bundle",
26-
*
27-
* // whether to bundle JS and assets in debug mode
28-
* bundleInDebug: false,
29-
*
30-
* // whether to bundle JS and assets in release mode
31-
* bundleInRelease: true,
32-
*
33-
* // whether to bundle JS and assets in another build variant (if configured).
34-
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
35-
* // The configuration property can be in the following formats
36-
* // 'bundleIn${productFlavor}${buildType}'
37-
* // 'bundleIn${buildType}'
38-
* // bundleInFreeDebug: true,
39-
* // bundleInPaidRelease: true,
40-
* // bundleInBeta: true,
41-
*
42-
* // whether to disable dev mode in custom build variants (by default only disabled in release)
43-
* // for example: to disable dev mode in the staging build type (if configured)
44-
* devDisabledInStaging: true,
45-
* // The configuration property can be in the following formats
46-
* // 'devDisabledIn${productFlavor}${buildType}'
47-
* // 'devDisabledIn${buildType}'
48-
*
49-
* // the root of your project, i.e. where "package.json" lives
50-
* root: "../../",
51-
*
52-
* // where to put the JS bundle asset in debug mode
53-
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
54-
*
55-
* // where to put the JS bundle asset in release mode
56-
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
57-
*
58-
* // where to put drawable resources / React Native assets, e.g. the ones you use via
59-
* // require('./image.png')), in debug mode
60-
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
61-
*
62-
* // where to put drawable resources / React Native assets, e.g. the ones you use via
63-
* // require('./image.png')), in release mode
64-
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
65-
*
66-
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
67-
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
68-
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
69-
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
70-
* // for example, you might want to remove it from here.
71-
* inputExcludes: ["android/**", "ios/**"],
72-
*
73-
* // override which node gets called and with what additional arguments
74-
* nodeExecutableAndArgs: ["node"],
75-
*
76-
* // supply additional arguments to the packager
77-
* extraPackagerArgs: []
78-
* ]
6+
* This is the configuration block to customize your React Native Android app.
7+
* By default you don't need to apply any configuration, just uncomment the lines you need.
798
*/
80-
81-
project.ext.react = [
82-
hermesEnabled: true, // clean and rebuild if changing
83-
]
84-
85-
apply plugin: 'com.facebook.react'
86-
87-
/**
88-
* Set this to true to create two separate APKs instead of one:
89-
* - An APK that only works on ARM devices
90-
* - An APK that only works on x86 devices
91-
* The advantage is the size of the APK is reduced by about 4MB.
92-
* Upload all the APKs to the Play Store and people will download
93-
* the correct one based on the CPU architecture of their device.
94-
*/
95-
def enableSeparateBuildPerCPUArchitecture = false
9+
react {
10+
/* Folders */
11+
// The root of your project, i.e. where "package.json" lives. Default is '../..'
12+
// root = file("../../")
13+
// The folder where the react-native NPM package is. Default is ../../node_modules/react-native
14+
// reactNativeDir = file("../../node_modules/react-native")
15+
// The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
16+
// codegenDir = file("../../node_modules/@react-native/codegen")
17+
// The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
18+
// cliFile = file("../../node_modules/react-native/cli.js")
19+
20+
/* Variants */
21+
// The list of variants to that are debuggable. For those we're going to
22+
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
23+
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
24+
// debuggableVariants = ["liteDebug", "prodDebug"]
25+
26+
/* Bundling */
27+
// A list containing the node command and its flags. Default is just 'node'.
28+
// nodeExecutableAndArgs = ["node"]
29+
//
30+
// The command to run when bundling. By default is 'bundle'
31+
// bundleCommand = "ram-bundle"
32+
//
33+
// The path to the CLI configuration file. Default is empty.
34+
// bundleConfig = file(../rn-cli.config.js)
35+
//
36+
// The name of the generated asset file containing your JS bundle
37+
// bundleAssetName = "MyApplication.android.bundle"
38+
//
39+
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
40+
// entryFile = file("../js/MyApplication.android.js")
41+
//
42+
// A list of extra flags to pass to the 'bundle' commands.
43+
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
44+
// extraPackagerArgs = []
45+
46+
/* Hermes Commands */
47+
// The hermes compiler command to run. By default it is 'hermesc'
48+
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
49+
//
50+
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
51+
// hermesFlags = ["-O", "-output-source-map"]
52+
53+
/* Autolinking */
54+
autolinkLibrariesWithApp()
55+
}
9656

9757
/**
98-
* Run Proguard to shrink the Java bytecode in release builds.
58+
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
9959
*/
10060
def enableProguardInReleaseBuilds = false
10161

10262
/**
103-
* The preferred build flavor of JavaScriptCore.
63+
* The preferred build flavor of JavaScriptCore (JSC)
10464
*
10565
* For example, to use the international variant, you can use:
10666
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
10767
*
10868
* The international variant includes ICU i18n library and necessary data
10969
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
110-
* give correct results when using with locales other than en-US. Note that
70+
* give correct results when using with locales other than en-US. Note that
11171
* this variant is about 6MiB larger per architecture than default.
11272
*/
11373
def jscFlavor = 'org.webkit:android-jsc:+'
11474

115-
/**
116-
* Whether to enable the Hermes VM.
117-
*
118-
* This should be set on project.ext.react and that value will be read here. If it is not set
119-
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
120-
* and the benefits of using Hermes will therefore be sharply reduced.
121-
*/
122-
def hermesEnabled = project.ext.react.get("hermesEnabled", false);
123-
124-
/**
125-
* Architectures to build native code for.
126-
*/
127-
def reactNativeArchitectures() {
128-
def value = project.getProperties().get("reactNativeArchitectures")
129-
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
130-
}
131-
13275
android {
13376
ndkVersion rootProject.ext.ndkVersion
77+
buildToolsVersion rootProject.ext.buildToolsVersion
78+
compileSdk rootProject.ext.compileSdkVersion
13479

135-
compileSdkVersion rootProject.ext.compileSdkVersion
136-
137-
namespace "com.quicksqliteexample"
80+
namespace "com.margelo.reactnativequicksqlite.example"
13881
defaultConfig {
139-
applicationId "com.quicksqliteexample"
82+
applicationId "com.margelo.reactnativequicksqlite.example"
14083
minSdkVersion rootProject.ext.minSdkVersion
14184
targetSdkVersion rootProject.ext.targetSdkVersion
14285
versionCode 1
14386
versionName "1.0"
144-
145-
}
146-
147-
splits {
148-
abi {
149-
reset()
150-
enable enableSeparateBuildPerCPUArchitecture
151-
universalApk false // If true, also generate a universal APK
152-
include (*reactNativeArchitectures())
153-
}
15487
}
15588
signingConfigs {
15689
debug {
@@ -172,43 +105,15 @@ android {
172105
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
173106
}
174107
}
175-
176-
// applicationVariants are e.g. debug, release
177-
applicationVariants.all { variant ->
178-
variant.outputs.each { output ->
179-
// For each separate APK per architecture, set a unique version code as described here:
180-
// https://developer.android.com/studio/build/configure-apk-splits.html
181-
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
182-
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
183-
def abi = output.getFilter(OutputFile.ABI)
184-
if (abi != null) { // null for the universal-debug, universal-release variants
185-
output.versionCodeOverride =
186-
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
187-
}
188-
189-
}
190-
}
191108
}
192109

193110
dependencies {
194-
195-
implementation "com.facebook.react:react-android"
196-
197-
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
198-
199-
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
200-
201-
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
202-
exclude group:'com.squareup.okhttp3', module:'okhttp'
203-
}
204-
205-
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
111+
// The version of react-native is set by the React Native Gradle Plugin
112+
implementation("com.facebook.react:react-android")
206113

207114
if (hermesEnabled.toBoolean()) {
208115
implementation("com.facebook.react:hermes-android")
209116
} else {
210117
implementation jscFlavor
211118
}
212119
}
213-
214-
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

example/android/app/src/debug/AndroidManifest.xml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools">
44

5-
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
6-
75
<application
86
android:usesCleartextTraffic="true"
97
tools:targetApi="28"
10-
tools:ignore="GoogleAppIndexingWarning">
11-
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
12-
</application>
8+
tools:ignore="GoogleAppIndexingWarning" />
139
</manifest>

0 commit comments

Comments
 (0)