stripe-react-native icon indicating copy to clipboard operation
stripe-react-native copied to clipboard

Unable to build on android. IOS is working fine.

Open application-inoviotech opened this issue 1 year ago • 10 comments

**React Native Version : 0.68.2 Stripe Version : 0.25

Gradle version used : classpath('com.android.tools.build:gradle:7.0.2')**

  • What went wrong: Execution failed for task ':app:mergeDebugResources'.

/Users/mac/.gradle/caches/transforms-3/b252794f6e7766bcaaa62afaf00adf95/transformed/material-1.8.0/res/values/values.xml: Error: Can't determine type for tag '?attr/shapeAppearanceCornerSmall'

To Reproduce

  1. npx react-native init --version 0.68.2
  2. npm install @stripe/stripe-react-native
  3. npm run android

Expected behavior The project should work properly but it gives the above error

Screenshots Screenshot 2023-03-01 at 12 38 10 PM

Additional context

When I use Gradle version "classpath('com.android.tools.build:gradle:7.0.2')". It gives me the above error on debug mode but when I upgrade my gradle version to "classpath('com.android.tools.build:gradle:7.2.2')", it starts working on debug mode but on release mode it gives me an error "Failed to get React Application Context".

The main issue, I think is releated to assets merging because of the file react.gradle in react-native library. Please assist if someone has faced this issue or knows a workaround for it.

Currently I am using Stripe Version 0.19 and it is working fine but there are alot of fixes done after this version so I wanted to upgrade my library.

application-inoviotech avatar Mar 01 '23 07:03 application-inoviotech

I'm facing this same issue, it has to do with com.google.android.material:material:1.8.0 not working correctly with gradle tools below 7.2.2, which itself requires react native 0.69+

If you aren't using payment sheets then an easy fix is to force the version to be 1.6.0 like so in your app's dependancy block:

configurations.all {
    resolutionStrategy {
        force 'com.google.android.material:material:1.6.0'
    }
}

DhirenAtodaria avatar Mar 01 '23 12:03 DhirenAtodaria

7.2.2, which itself requires react native 0.69+

@DhirenAtodaria does RN have that requirement? afaik, if your actual gradle version is 7.3.3 (check your gradle-wrapper.properties), you should be able to upgrade to classpath("com.android.tools.build:gradle:7.2.2") in your build.gradle file

charliecruzan-stripe avatar Mar 01 '23 18:03 charliecruzan-stripe

@charliecruzan-stripe yes we're able to upgrade to classpath("com.android.tools.build:gradle:7.2.2") but that doesn't find react application context on release build. I don't know why is that but the issue is with merging assets. It says make sure your app is bundled correctly.

I have also mentioned what happens when I upgrade to classpath("com.android.tools.build:gradle:7.2.2")

application-inoviotech avatar Mar 02 '23 11:03 application-inoviotech

7.2.2, which itself requires react native 0.69+

@DhirenAtodaria does RN have that requirement? afaik, if your actual gradle version is 7.3.3 (check your gradle-wrapper.properties), you should be able to upgrade to classpath("com.android.tools.build:gradle:7.2.2") in your build.gradle file

Yeah sorry, requirement is the wrong word, I'd say 'bugged' is more suitable 😅, but yeah like the poster above, we can upgradle to gradle tools 7.2.2, the problem occurs when you build a release version of the app, apparently there's some issues with the actual bundling of the js and it ends up causing the 'FATAL EXCEPTION: create_react_context' you can read more here: https://stackoverflow.com/questions/72564710/react-native-crash-release-build-fatal-exception-create-react-context

There were some suggested fixes but I deemed it wasn't worth the effort figuring it out and debugging after every release build for a simple library upgrade so ended up just forcing the material version since I don't use payment sheets regardless.

I wouldn't be able to say how many rn versions are affected, but essentially there will be an implicit requirement now for these gradle tools in order to use the latest version.

DhirenAtodaria avatar Mar 02 '23 12:03 DhirenAtodaria

@DhirenAtodaria the issue is with some configuration in react.gradle file present in the react-native library itself. I tried upgrading the react native then everything works fine but I cannot upgrade react native version of my app.

application-inoviotech avatar Mar 02 '23 12:03 application-inoviotech

Got the same issue in "com.android.tools.build:gradle:7.2.1" , "com.google.android.material:material:1.6.0"

BhavikWings avatar Jun 08 '23 05:06 BhavikWings

I'm facing this same issue, it has to do with com.google.android.material:material:1.8.0 not working correctly with gradle tools below 7.2.2, which itself requires react native 0.69+

If you aren't using payment sheets then an easy fix is to force the version to be 1.6.0 like so in your app's dependancy block:

configurations.all {
    resolutionStrategy {
        force 'com.google.android.material:material:1.6.0'
    }
}

where to add this ? which file ?

echolove38 avatar Aug 10 '23 09:08 echolove38

I'm facing this same issue, it has to do with com.google.android.material:material:1.8.0 not working correctly with gradle tools below 7.2.2, which itself requires react native 0.69+ If you aren't using payment sheets then an easy fix is to force the version to be 1.6.0 like so in your app's dependancy block:

configurations.all {
    resolutionStrategy {
        force 'com.google.android.material:material:1.6.0'
    }
}

where to add this ? which file ?

Hey, sorry for the late reply, but this goes in your build.gradle in your dependencies block

DhirenAtodaria avatar Sep 01 '23 14:09 DhirenAtodaria

I resolve this issue by using following configuration ,

android/build.gradle

dependencies {
...
classpath("com.android.tools.build:gradle:7.2.2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10")
...
}

android/app/build.gradle

dependencies {
...
implementation 'com.google.android.material:material:1.6.0'
...
}

NOTE: distribution url in gradle-wrapper.properties must not be lower than distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip

arham1999 avatar Sep 14 '23 00:09 arham1999

I resolve this issue by using following configuration ,

android/build.gradle

dependencies {
...
classpath("com.android.tools.build:gradle:7.2.2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10")
...
}

android/app/build.gradle

dependencies {
...
implementation 'com.google.android.material:material:1.6.0'
...
}

NOTE: distribution url in gradle-wrapper.properties must not be lower than distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip

This solved my issue Thank you

MuhammadHussain-code avatar Sep 14 '23 06:09 MuhammadHussain-code