Skip to content

Commit de928b1

Browse files
konraddysputKonrad Dysput
andcommitted
react-native: add support for bridgeless mode in the android example project and start database always on start (#328)
Co-authored-by: Konrad Dysput <konrad.dysput@saucelabs.com>
1 parent cb282b1 commit de928b1

File tree

2 files changed

+52
-42
lines changed

2 files changed

+52
-42
lines changed
Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,71 @@
11
package com.reactnative;
22

33
import android.app.Application;
4+
5+
import androidx.annotation.NonNull;
6+
47
import com.facebook.react.PackageList;
58
import com.facebook.react.ReactApplication;
9+
import com.facebook.react.ReactHost;
610
import com.facebook.react.ReactNativeHost;
711
import com.facebook.react.ReactPackage;
812
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
13+
import com.facebook.react.defaults.DefaultReactHost;
914
import com.facebook.react.defaults.DefaultReactNativeHost;
1015
import com.facebook.soloader.SoLoader;
16+
1117
import java.util.List;
1218

1319
public class MainApplication extends Application implements ReactApplication {
1420

15-
private final ReactNativeHost mReactNativeHost = new DefaultReactNativeHost(this) {
16-
@Override
17-
public boolean getUseDeveloperSupport() {
18-
return BuildConfig.DEBUG;
19-
}
21+
private final ReactNativeHost mReactNativeHost = new DefaultReactNativeHost(this) {
22+
@Override
23+
public List<ReactPackage> getPackages() {
24+
List<ReactPackage> packages = new PackageList(this).getPackages();
25+
packages.add(new BacktraceDemoPackage());
26+
return packages;
27+
}
2028

21-
@Override
22-
protected List<ReactPackage> getPackages() {
23-
List<ReactPackage> packages = new PackageList(this).getPackages();
24-
packages.add(new BacktraceDemoPackage());
25-
return packages;
26-
}
29+
@Override
30+
public String getJSMainModuleName() {
31+
return "index";
32+
}
33+
34+
@Override
35+
public boolean getUseDeveloperSupport() {
36+
return BuildConfig.DEBUG;
37+
}
38+
39+
@Override
40+
public boolean isNewArchEnabled() {
41+
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
42+
}
2743

44+
@Override
45+
public Boolean isHermesEnabled() {
46+
return BuildConfig.IS_HERMES_ENABLED;
47+
}
48+
};
49+
50+
@NonNull
2851
@Override
29-
protected String getJSMainModuleName() {
30-
return "index";
52+
public ReactNativeHost getReactNativeHost() {
53+
return mReactNativeHost;
3154
}
3255

3356
@Override
34-
protected boolean isNewArchEnabled() {
35-
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
57+
public ReactHost getReactHost() {
58+
return DefaultReactHost.getDefaultReactHost(getApplicationContext(), mReactNativeHost);
3659
}
3760

3861
@Override
39-
protected Boolean isHermesEnabled() {
40-
return BuildConfig.IS_HERMES_ENABLED;
41-
}
42-
};
43-
44-
@Override
45-
public ReactNativeHost getReactNativeHost() {
46-
return mReactNativeHost;
47-
}
48-
49-
@Override
50-
public void onCreate() {
51-
super.onCreate();
52-
SoLoader.init(this, /* native exopackage */ false);
53-
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
54-
// If you opted-in for the New Architecture, we load the native entry point for
55-
// this app.
56-
DefaultNewArchitectureEntryPoint.load();
62+
public void onCreate() {
63+
super.onCreate();
64+
SoLoader.init(this, false);
65+
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
66+
// If you opted-in for the New Architecture, we load the native entry point for
67+
// this app.
68+
DefaultNewArchitectureEntryPoint.load();
69+
}
5770
}
58-
}
5971
}

examples/sdk/reactNative/index.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@ BacktraceClient.initialize({
1515
prop2: 123,
1616
},
1717
},
18-
database: __DEV__
19-
? undefined
20-
: {
21-
enable: true,
22-
captureNativeCrashes: true,
23-
createDatabaseDirectory: true,
24-
path: `${BacktraceClient.applicationDataPath}/backtrace`,
25-
},
18+
database: {
19+
enable: true,
20+
captureNativeCrashes: true,
21+
createDatabaseDirectory: true,
22+
path: `${BacktraceClient.applicationDataPath}/backtrace`,
23+
},
2624
});
2725

2826
AppRegistry.registerComponent(appName, () => App);

0 commit comments

Comments
 (0)