Closed jaksonfact closed 1 year ago
@jaksonfact It'll be helpful if you can share the relevant crash logcat here.
You might also want to delete the yarn.lock
file and node_modules
folder, then run yarn install
to install the Stripe Android SDK that is shipped with the latest Stripe react-native SDK.
I did this multiple time bro but it din't work. i think i have a problem with my build.gradle. for this scenario i cannot print any log inside the initipaymentsheet. after entering this function my application got crash
Can you run adb logcat -b crash
and see if there are crash logs related to your application? You can learn more about adb logcat
here
@seanzhang-stripe This is my logcat :
05-07 19:04:28.698 14268 14268 E AndroidRuntime: FATAL EXCEPTION: main
05-07 19:04:28.698 14268 14268 E AndroidRuntime: Process: com.medosys, PID: 14268
05-07 19:04:28.698 14268 14268 E AndroidRuntime: java.lang.NoSuchMethodError: No direct method
I noticed that you applied a dependency constraints in your gradle file, so there's a possibility that the Stripe Android SDK version that stripe-react-native SDK uses is incompatible with the version that your constraint specifies (i.e., 20.11.0), and therefore cause the NoSuchMethodError
during runtime.
I'd suggest you to remove the dependency constraint, and let Gradle automatically pick the Stripe Android SDK version that shipped with the stripe-react-native SDK.
Summary
I have used stripe payment sheet for last one year for reactnative mobile application. it was working perfectly but now in ios working fine as expected but in android, whenever i trigger initpaymentsheet function my application get crashing
Code to reproduce
import React, {useState, useEffect} from 'react'; import { StyleSheet, TouchableOpacity, Text, Button, View, Alert, } from 'react-native'; import { CardField, CardFieldInput, useStripe, useGooglePay, } from '@stripe/stripe-react-native'; import AsyncStorage from '@react-native-async-storage/async-storage'; import {useDispatch} from 'react-redux'; import {useNavigation} from '@react-navigation/native'; import LinearGradient from 'react-native-linear-gradient'; import AppConfig from '../../../../navigation/appConfig'; import {Colors} from '../../../../Constants/Colors'; import {commonStyleForContainer} from '../../../../Constants/CommonStyles'; const PaymentInit = ({ totalPay = '', doc_id = '', patient_id = '', appointment_id = '', otp = '', tenantId = '', customerIds, emphemeral_key, secret_intent, }) => { const navigation = useNavigation(); const dispatch = useDispatch(); const [card, setCard] = useState(CardFieldInput.Details | null); // const {confirmPayment, handleCardAction} = useStripe(); const {initPaymentSheet, presentPaymentSheet} = useStripe(); const [loading, setLoading] = useState(false); const {isGooglePaySupported, initGooglePay} = useGooglePay();
const initializePaymentSheet = async () => { console.log('ooooo'); // const logic = await fetchPaymentSheetParams();
}; const openPaymentSheet = async () => { const {error} = await presentPaymentSheet(); console.log('paymentResponse', error); if (error) { Alert.alert(
Error code: ${error.code}
, error.message); } else { Alert.alert('Success', 'Your order is confirmed!', [ { text: 'OK', onPress: () => { navigation.navigate(AppConfig.SCREEN.QUESTIONS_SCREEN, { appointmentId: appointment_id, patientId: patient_id, tenant_Id: tenantId, }); }, }, ]); } }; useEffect(() => { console.log('initializePaymentSheet', 'initializePaymentSheet'); initializePaymentSheet(); }, []); return (); }; export default PaymentInit; const styles = StyleSheet.create({ ...commonStyleForContainer, container: { flex: 1, width: '100%', }, button: { backgroundColor: '#00aeef', borderColor: 'red', borderWidth: 5, borderRadius: 15, }, });
Android version
Platform OS: android Platform Version: 33 old version : 31
Impacted devices
Mobile Application got crashing in only ANDROID
Installation method
yarn add @stripe/stripe-react-native
Dependency Versions
apply plugin: "com.android.application" apply plugin: 'com.google.gms.google-services'
import com.android.build.OutputFile
project.ext.react = [ enableHermes: true, // clean and rebuild if changing ]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
def jscFlavor = 'org.webkit:android-jsc:+'
def enableHermes = project.ext.react.get("enableHermes", false);
def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")
android { ndkVersion rootProject.ext.ndkVersion
} signingConfigs { debug { storeFile file('debug.keystore') storePassword 'android' keyAlias 'androiddebugkey' keyPassword 'android' } } buildTypes { debug { signingConfig signingConfigs.debug if (nativeArchitectures) { ndk { abiFilters nativeArchitectures.split(',') } } } release { // Caution! In production, you need to generate your own keystore file. // see https://reactnative.dev/docs/signed-apk-android.
}
dependencies {
}
implementation 'com.facebook.fresco:animated-base-support:1.3.0'
// For animated GIF support implementation 'com.facebook.fresco:animated-gif:1.3.0'
// For WebP support, including animated WebP implementation 'com.facebook.fresco:animated-webp:1.3.0' implementation 'com.facebook.fresco:webpsupport:1.3.0'
// For WebP support, without animations implementation 'com.facebook.fresco:webpsupport:1.3.0'
}
task copyDownloadableDepsToLibs(type: Copy) { from configurations.implementation into 'libs' }
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
For kotlin: ./gradlew :dependencies | grep kotlin
For stripe-android: ./gradlew :dependencies | grep com.android.tools.build
For Android Gradle Plugin: ./gradlew :dependencies | grep com.stripe:stripe-android
For Gradle version:
Gradle 7.2
Build time: 2021-08-17 09:59:03 UTC Revision: a773786b58bb28710e3dc96c4d1a7063628952ad
Kotlin: 1.5.21 Groovy: 3.0.8 Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020 JVM: 11.0.11 (AdoptOpenJDK 11.0.11+9) OS: Mac OS X 11.3 x86_64
kotlin: stripe-android: Android Gradle Plugin: Gradle:
SDK classes
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
}
allprojects { repositories { exclusiveContent { filter { includeGroup "com.facebook.react" } forRepository { maven { url "$rootDir/../node_modules/react-native/android" } } } maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url("$rootDir/../node_modules/react-native/android") } maven { // Android JSC is installed from npm url("$rootDir/../node_modules/jsc-android/dist") } mavenCentral { // We don't want to fetch react-native from Maven Central as there are // older versions over there. content { excludeGroup "com.facebook.react" } } google() maven { url 'https://maven.google.com' } maven { url 'https://www.jitpack.io' }
}
My reactnative version: "react-native": "0.67.3",
Other information
I have updated latest version of react native and got this issue i hope i have problem with SDK installation version in build.gradle so please help me to get out from this issue. Thanks In Advance