-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: update kotlin integration with Existing Apps and Fragment #4204
base: main
Are you sure you want to change the base?
docs: update kotlin integration with Existing Apps and Fragment #4204
Conversation
@@ -238,6 +230,8 @@ protected void onCreate(Bundle savedInstanceState) { | |||
|
|||
In the code above `Fragment reactNativeFragment = new ReactFragment.Builder()` creates the ReactFragment and `getSupportFragmentManager().beginTransaction().add()` adds the Fragment to the Frame Layout. | |||
|
|||
We have to implement the `DefaultHardwareBackBtnHandler` interface and override the `invokeDefaultOnBackPressed` method. This is necessary to allow react-native handle the back button press event. | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per the my understanding from react-native repo here, I have added this information. If this seems in correct, feel free to provide the correct one and I will update this PR.
I had to implement DefaultHardwareBackBtnHandler
otherwise the app would crash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the crash? I don't think this is strictly necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a requirement per the ReactDelegate
, otherwise an exception is thrown here:
https://github.com/facebook/react-native/blob/d4d1eb9bb18d66997008988ff0ef48dc754b3fdf/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java#L113-L115
✅ Deploy Preview for react-native ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
plugins { | ||
id("com.android.application") | ||
id("org.jetbrains.kotlin.android") | ||
+ id("com.facebook.react") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although using the plugins{}
block is reccomended by Gradle, in this page we want to suggest a setup that is as close as possible the the existing template so by using the apply:
syntax
Those dependencies are available on `mavenCentral()` so make sure you have it defined in your `repositories{}` block in your `settings.gradle` file. | ||
|
||
```diff | ||
dependencyResolutionManagement { | ||
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) | ||
repositories { | ||
google() | ||
mavenCentral() // This is required, you'll probably have it already | ||
} | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is necessary IMHO
@@ -238,6 +230,8 @@ protected void onCreate(Bundle savedInstanceState) { | |||
|
|||
In the code above `Fragment reactNativeFragment = new ReactFragment.Builder()` creates the ReactFragment and `getSupportFragmentManager().beginTransaction().add()` adds the Fragment to the Frame Layout. | |||
|
|||
We have to implement the `DefaultHardwareBackBtnHandler` interface and override the `invokeDefaultOnBackPressed` method. This is necessary to allow react-native handle the back button press event. | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the crash? I don't think this is strictly necessary
Description:
While following the docs for integrating React Native within a Kotlin App, the docs appeared to be outdated as the build configurations described in the docs were failing. The same case was with the Kotlin integration code snippets.
This might have happened due to the docs for brownfield integration not being up-to-date with latest RN versions.
Hence, I have created this PR after figuring out the build configurations that worked and the updated code snippets. I took some help from build gradle files from react-native repo in order to use the correct build configurations.