-
Notifications
You must be signed in to change notification settings - Fork 7
Upgrade native sdks to 2.4.0 #75
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
68d6498
upgrade in Android
cdavidsp add6f03
update android
cdavidsp 88bcf62
iOS first version
cdavidsp 5dfed3c
update version
cesar-sosa-hol 8a09c84
fix android compatibility issue with last version of kotlin
cdavidsp 55220ae
fix lint issues
cdavidsp 616be23
fix yarn typecheck
cdavidsp e802073
add app.properties
cdavidsp 31f42c8
fix yarn lint
cdavidsp 552caf4
fix ios version
cdavidsp 16951ae
update statusInfoMap
cdavidsp c81c5eb
clean ios project
cdavidsp 3ebb716
clean build.gradle
cdavidsp ca8afde
fix android details
cesar-sosa-hol 0482c76
- Add Kotlin 2.2.x compatibility workaround docs
Armaxis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| # Kotlin 2.2.x Compatibility Workaround for React Native | ||
|
|
||
| Mobile Payments SDK 2.4.0 requires **Kotlin 2.2.21**, which introduces a breaking change with React Native's Gradle plugin (versions 0.75.x and earlier). The `KotlinTopLevelExtension` class was removed in Kotlin 2.2.x, causing the Android build to fail during Gradle configuration. | ||
|
|
||
| This guide explains how to apply a patch to your project so you can use Mobile Payments SDK 2.4.0 with React Native until React Native itself adds support for Kotlin 2.2.x. | ||
|
|
||
| > **Note:** This workaround is temporary. Once React Native releases a version with Kotlin 2.2.x support, you can remove the patch and `patch-package` dependency. | ||
|
|
||
| ## The Problem | ||
|
|
||
| When building with Kotlin 2.2.21, Android builds fail with an error like: | ||
|
|
||
| ``` | ||
| Unresolved reference: KotlinTopLevelExtension | ||
| ``` | ||
|
|
||
| This happens because React Native's Gradle plugin (`@react-native/gradle-plugin`) references `org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension`, which was removed in Kotlin 2.2.x and replaced with `kotlinExtension`. | ||
|
|
||
| ## Fix: Apply a Patch with `patch-package` | ||
|
|
||
| ### 1. Install `patch-package` | ||
|
|
||
| ```sh | ||
| # npm | ||
| npm install --save-dev patch-package | ||
|
|
||
| # yarn | ||
| yarn add --dev patch-package | ||
| ``` | ||
|
|
||
| ### 2. Add a `postinstall` script | ||
|
|
||
| In your project's `package.json`, add a `postinstall` script so the patch is applied automatically after every install: | ||
|
|
||
| ```json | ||
| { | ||
| "scripts": { | ||
| "postinstall": "patch-package" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| If you already have a `postinstall` script, chain the commands: | ||
|
|
||
| ```json | ||
| { | ||
| "scripts": { | ||
| "postinstall": "your-existing-command && patch-package" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### 3. Create the patch file | ||
|
|
||
| Create the file `patches/@react-native+gradle-plugin+0.75.3.patch` in your project root. | ||
|
|
||
| > **Important:** The version in the filename (`0.75.3`) must match your `react-native` version. If you are on a different version (e.g., `0.75.4`), adjust the filename accordingly. | ||
|
|
||
| ```sh | ||
| mkdir -p patches | ||
| ``` | ||
|
|
||
| Paste the following contents into `patches/@react-native+gradle-plugin+0.75.3.patch`: | ||
|
|
||
| ```diff | ||
| diff --git a/node_modules/@react-native/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/JdkConfiguratorUtils.kt b/node_modules/@react-native/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/JdkConfiguratorUtils.kt | ||
| index 0d55714..e59e9d5 100644 | ||
| --- a/node_modules/@react-native/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/JdkConfiguratorUtils.kt | ||
| +++ b/node_modules/@react-native/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/JdkConfiguratorUtils.kt | ||
| @@ -13,7 +13,7 @@ import org.gradle.api.Action | ||
| import org.gradle.api.JavaVersion | ||
| import org.gradle.api.Project | ||
| import org.gradle.api.plugins.AppliedPlugin | ||
| -import org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension | ||
| +import org.jetbrains.kotlin.gradle.dsl.kotlinExtension | ||
|
|
||
| internal object JdkConfiguratorUtils { | ||
| /** | ||
| @@ -42,10 +42,10 @@ internal object JdkConfiguratorUtils { | ||
| project.pluginManager.withPlugin("com.android.application", action) | ||
| project.pluginManager.withPlugin("com.android.library", action) | ||
| project.pluginManager.withPlugin("org.jetbrains.kotlin.android") { | ||
| - project.extensions.getByType(KotlinTopLevelExtension::class.java).jvmToolchain(17) | ||
| + project.kotlinExtension.jvmToolchain(17) | ||
| } | ||
| project.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") { | ||
| - project.extensions.getByType(KotlinTopLevelExtension::class.java).jvmToolchain(17) | ||
| + project.kotlinExtension.jvmToolchain(17) | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### 4. Run install to apply the patch | ||
|
|
||
| ```sh | ||
| # npm | ||
| npm install | ||
|
|
||
| # yarn | ||
| yarn install | ||
| ``` | ||
|
|
||
| You should see output confirming the patch was applied: | ||
|
|
||
| ``` | ||
| patch-package 8.0.1 | ||
| Applying patches... | ||
| @react-native/gradle-plugin@0.75.3 ✔ | ||
| ``` | ||
|
|
||
| ### 5. Build your project | ||
|
|
||
| Your Android build should now succeed with Kotlin 2.2.21 and Mobile Payments SDK 2.4.0. | ||
|
|
||
| ## Removing the Workaround | ||
|
|
||
| When React Native releases a version that supports Kotlin 2.2.x natively: | ||
|
|
||
| 1. Upgrade your `react-native` dependency to the compatible version | ||
| 2. Delete the `patches/@react-native+gradle-plugin+0.75.3.patch` file | ||
| 3. Remove `patch-package` from your `devDependencies` (if no other patches remain) | ||
| 4. Remove `patch-package` from your `postinstall` script | ||
|
|
||
| ## Reference | ||
|
|
||
| - [Mobile Payments SDK React Native Example](../example/) - see how the patch is applied in the sample project | ||
| - [patch-package documentation](https://github.com/ds300/patch-package) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # You can copy this file to app.properties (lose ".example"), and set the values | ||
| # from https://developer.squareup.com/apps/${app_id}, but .gitignore will keep | ||
| # the "secret" values out of source control. | ||
|
|
||
| # This identifies your application to Square | ||
| APP_ID="INSERT APP_ID HERE" | ||
|
|
||
| # This identifies the merchant. In most cases, OAuth is best for production | ||
| # usage (read https://developer.squareup.com/docs/oauth-api/overview), but that | ||
| # requires a server, and we can't know where or how developers configure that. | ||
| # The dashboard values can be put here for quick test access. | ||
| LOCATION_ID="INSERT LOCATION_ID HERE" | ||
| ACCESS_TOKEN="INSERT ACCESS TOKEN HERE" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are these used somewhere? |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Oh, did we forget to update our changelog for this release?