Skip to content

Commit

Permalink
Fix example-new-architecture project & minor react-native version upg…
Browse files Browse the repository at this point in the history
…rade

- Upgrade react-native to version 0.74.6
- Update project dependencies
- Fix metro config
- Upgrade gradle version
- Increase minSdkVersion & ndkVersion
- Remove flipper initialization & refactor 'MainApplication.kt'
- Rename 'getBundleURL' to 'bundleURL' in 'AppDelegate.mm'
  • Loading branch information
cdn34dd committed Jan 15, 2025
1 parent d3e4599 commit eb99977
Show file tree
Hide file tree
Showing 11 changed files with 338 additions and 345 deletions.
1 change: 1 addition & 0 deletions example-new-architecture/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,4 @@ dependencies {
}
}
}
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,37 @@ import com.facebook.react.ReactApplication
import com.facebook.react.ReactHost
import com.facebook.react.ReactNativeHost
import com.facebook.react.ReactPackage
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.react.flipper.ReactNativeFlipper
import com.facebook.soloader.SoLoader

class MainApplication : Application(), ReactApplication {

override val reactHost: ReactHost?
get() = super.reactHost

private val mReactNativeHost =
object : DefaultReactNativeHost(this) {

override val isNewArchEnabled: Boolean
get() = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED

override val isHermesEnabled: Boolean
get() = BuildConfig.IS_HERMES_ENABLED

override fun getPackages(): MutableList<ReactPackage> {
@SuppressWarnings("UnnecessaryLocalVariable")
val packages = PackageList(this).packages
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage())
return packages
override val reactNativeHost: ReactNativeHost =
object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> =
PackageList(this).packages.apply {
// Packages that cannot be autolinked yet can be added manually here, for example:
// add(MyReactNativePackage())
}

override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
override fun getJSMainModuleName(): String = "index"

override fun getJSMainModuleName(): String {
return "index"
}
}
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG

override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
}

override val reactNativeHost: ReactNativeHost
get() = mReactNativeHost
override val reactHost: ReactHost
get() = getDefaultReactHost(applicationContext, reactNativeHost)

override fun onCreate() {
super.onCreate()
SoLoader.init(this, /* native exopackage */ false)
SoLoader.init(this, false)
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
DefaultNewArchitectureEntryPoint.load()
load()
}
ReactNativeFlipper.initializeFlipper(this, reactNativeHost.reactInstanceManager)
}
}
4 changes: 2 additions & 2 deletions example-new-architecture/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ buildscript {
minSdkVersion = 23
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "25.1.8937393"
kotlinVersion = "1.8.21"
ndkVersion = "26.1.10909125"
kotlinVersion = "1.9.22"
}
repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
20 changes: 10 additions & 10 deletions example-new-architecture/android/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

Expand Down
5 changes: 5 additions & 0 deletions example-new-architecture/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
rootProject.name = 'DdSdkReactNativeExample'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')




Loading

0 comments on commit eb99977

Please sign in to comment.