Closed a-eid closed 11 months ago
@a-eid How did you change the Kotlin version?
Also, does it work for iOS?
@ansh
How did you change the Kotlin version?
you need to use expo-build-properties
Also, does it work for iOS?
I think so yes.
@a-eid Are you using expo-dev-client? When I try to build my app with EAS Build, it fails and gives me a bunch of errors.
Also, what Kotlin version did you change it to?
I don't think I was using expo-dev-client
for that project.
I changed kotlin version to 1.6.10
.
i will try to add this on next weeks
@luccasr73 Have you had a chance to look at this yet? This could greatly improve performance for Android. :-)
const withWatermelonDBAndroidJSI = (config) => {
function settingGradle(gradleConfig) {
return withSettingsGradle(gradleConfig, (mod) => {
if (!mod.modResults.contents.includes(':watermelondb-jsi')) {
mod.modResults.contents += `
include ':watermelondb-jsi'
project(':watermelondb-jsi').projectDir =
new File(rootProject.projectDir, '../node_modules/@nozbe/watermelondb/native/android-jsi')
`;
}
return mod;
});
}
function buildGradle(gradleConfig) {
return withAppBuildGradle(gradleConfig, (mod) => {
if (
!mod.modResults.contents.includes("pickFirst '**/libc++_shared.so'")
) {
mod.modResults.contents = mod.modResults.contents.replace(
'android {',
`
android {
packagingOptions {
pickFirst '**/libc++_shared.so'
}
`
);
}
if (
!mod.modResults.contents.includes(
"implementation project(':watermelondb-jsi')"
)
) {
mod.modResults.contents = mod.modResults.contents.replace(
'dependencies {',
`
dependencies {
implementation project(':watermelondb-jsi')
`
);
}
return mod;
});
}
function mainApplication(mainAppConfig) {
return withMainApplication(mainAppConfig, (mod) => {
if (
!mod.modResults.contents.includes(
'import com.nozbe.watermelondb.jsi.WatermelonDBJSIPackage;'
)
) {
mod.modResults.contents = mod.modResults.contents.replace(
'import com.nozbe.watermelondb.WatermelonDBPackage;',
`
import com.nozbe.watermelondb.WatermelonDBPackage;
import com.nozbe.watermelondb.jsi.WatermelonDBJSIPackage;
import com.facebook.react.bridge.JSIModulePackage;
`
);
}
if (
!mod.modResults.contents.includes('return new WatermelonDBJSIPackage()')
) {
mod.modResults.contents = mod.modResults.contents.replace(
'new ReactNativeHostWrapper(this, new DefaultReactNativeHost(this) {',
`
new ReactNativeHostWrapper(this, new DefaultReactNativeHost(this) {
@Override
protected JSIModulePackage getJSIModulePackage() {
return new WatermelonDBJSIPackage();
}
`
);
}
return mod;
});
}
return mainApplication(settingGradle(buildGradle(config)));
};
This is how I do it But beware that you might need to change it accordingly if you have multiple JSI packages See the docs for more info https://watermelondb.dev/docs/Installation#android-react-native
const withWatermelonDBAndroidJSI = (config) => { function settingGradle(gradleConfig) { return withSettingsGradle(gradleConfig, (mod) => { if (!mod.modResults.contents.includes(':watermelondb-jsi')) { mod.modResults.contents += ` include ':watermelondb-jsi' project(':watermelondb-jsi').projectDir = new File(rootProject.projectDir, '../node_modules/@nozbe/watermelondb/native/android-jsi') `; } return mod; }); } function buildGradle(gradleConfig) { return withAppBuildGradle(gradleConfig, (mod) => { if ( !mod.modResults.contents.includes("pickFirst '**/libc++_shared.so'") ) { mod.modResults.contents = mod.modResults.contents.replace( 'android {', ` android { packagingOptions { pickFirst '**/libc++_shared.so' } ` ); } if ( !mod.modResults.contents.includes( "implementation project(':watermelondb-jsi')" ) ) { mod.modResults.contents = mod.modResults.contents.replace( 'dependencies {', ` dependencies { implementation project(':watermelondb-jsi') ` ); } return mod; }); } function mainApplication(mainAppConfig) { return withMainApplication(mainAppConfig, (mod) => { if ( !mod.modResults.contents.includes( 'import com.nozbe.watermelondb.jsi.WatermelonDBJSIPackage;' ) ) { mod.modResults.contents = mod.modResults.contents.replace( 'import com.nozbe.watermelondb.WatermelonDBPackage;', ` import com.nozbe.watermelondb.WatermelonDBPackage; import com.nozbe.watermelondb.jsi.WatermelonDBJSIPackage; import com.facebook.react.bridge.JSIModulePackage; ` ); } if ( !mod.modResults.contents.includes('return new WatermelonDBJSIPackage()') ) { mod.modResults.contents = mod.modResults.contents.replace( 'new ReactNativeHostWrapper(this, new DefaultReactNativeHost(this) {', ` new ReactNativeHostWrapper(this, new DefaultReactNativeHost(this) { @Override protected JSIModulePackage getJSIModulePackage() { return new WatermelonDBJSIPackage(); } ` ); } return mod; }); } return mainApplication(settingGradle(buildGradle(config))); };
This is how I do it But beware that you might need to change it accordingly if you have multiple JSI packages See the docs for more info https://watermelondb.dev/docs/Installation#android-react-native
hi how to use this code in expo?
hey, thank you for the plugin, it works with expo 45, you just need to change the kotlin version manually.
I was wondering if you're planning to add the jsi step to the plugin, it looks like it's not yet added / installed.
[š] JSI SQLiteAdapter not availableā¦ falling back to asynchronous operation. This will happen if you're using remote debugger, and may happen if you forgot to recompile native app after WatermelonDB update