stripe / stripe-react-native

React Native library for Stripe.
https://stripe.dev/stripe-react-native
MIT License
1.26k stars 260 forks source link

React native App Crashes after start. #483

Closed vivekmahato26 closed 3 years ago

vivekmahato26 commented 3 years ago

Describe the bug I am building an eCommerce app with Pure React Native without Expo. The app runs perfectly until I install the stripe/stripe-react-native package. The Gradle build works fine along with the meteor server but the app crashes immediately without any warnings or errors. when I ran adb logcat the following error message was there: - "java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbq;"

After removing the package the app runs properly again without any crashes or errors.

To Reproduce Steps to reproduce the behavior: create a react native project with react-native CLI install stripe/stripe-react-native run:- npm run android

Expected behavior there shouldn't be any crashes;

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

My gradle file: - buildscript { ext { buildToolsVersion = "29.0.3" minSdkVersion = 21 compileSdkVersion = 29 targetSdkVersion = 29 ndkVersion = "20.1.5948944" } repositories { google() jcenter() } dependencies { classpath("com.android.tools.build:gradle:4.1.0") // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } }

allprojects { repositories { mavenLocal() 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") }

    google()
    jcenter()
    maven { url 'https://www.jitpack.io' }
}

}

My app/build.gradle file: - apply plugin: "com.android.application"

import com.android.build.OutputFile

/**

project.ext.react = [ enableHermes: false, // clean and rebuild if changing ]

apply from: "../../node_modules/react-native/react.gradle" /**

/**

/**

/**

android { ndkVersion rootProject.ext.ndkVersion

compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
    applicationId "com.vevibes"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    manifestPlaceholders = [
        tipsiStripeRedirectScheme: "CUSTOM_SCHEME"
    ]
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
    }
}
signingConfigs {
    debug {
        storeFile file('debug.keystore')
        storePassword 'android'
        keyAlias 'androiddebugkey'
        keyPassword 'android'
    }
}
buildTypes {
    debug {
        signingConfig signingConfigs.debug
    }
    release {
        // Caution! In production, you need to generate your own keystore file.
        // see https://reactnative.dev/docs/signed-apk-android.
        signingConfig signingConfigs.debug
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}

// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
    variant.outputs.each { output ->
        // For each separate APK per architecture, set a unique version code as described here:
        // https://developer.android.com/studio/build/configure-apk-splits.html
        // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
        def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, universal-release variants
            output.versionCodeOverride =
                    defaultConfig.versionCode * 1000 + versionCodes.get(abi)
        }

    }
}

}

dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules

implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"

debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
  exclude group:'com.facebook.fbjni'
}

debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.flipper'
    exclude group:'com.squareup.okhttp3', module:'okhttp'
}

debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.flipper'
}

if (enableHermes) {
    def hermesPath = "../../node_modules/hermes-engine/android/";
    debugImplementation files(hermesPath + "hermes-debug.aar")
    releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
    implementation jscFlavor
}

}

// Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) { from configurations.compile into 'libs' }

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

My Package.json file: -

{ "name": "vevibes", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint ." }, "dependencies": { "@react-native-async-storage/async-storage": "^1.15.5", "@react-native-community/geolocation": "^2.0.2", "@react-native-community/masked-view": "^0.1.11", "@react-navigation/drawer": "^5.12.5", "@react-navigation/native": "^5.9.4", "@react-navigation/stack": "^5.14.5", "algoliasearch": "^4.10.3", "axios": "^0.21.1", "graphql": "^15.5.1", "graphql-request": "^3.4.0", "moment": "^2.29.1", "react": "17.0.1", "react-devtools": "^4.13.5", "react-is": "^17.0.2", "react-native": "0.64.2", "react-native-animatable": "^1.3.3", "react-native-collapsible": "^1.6.0", "react-native-dash": "0.0.11", "react-native-date-picker": "^3.3.2", "react-native-elements": "^3.4.2", "react-native-fs": "^2.18.0", "react-native-gesture-handler": "^1.10.3", "react-native-image-picker": "^4.0.6", "react-native-keychain": "^7.0.0", "react-native-linear-gradient": "^2.5.6", "react-native-modalize": "^2.0.8", "react-native-otp-textinput": "0.0.8", "react-native-paper": "^4.9.2", "react-native-paper-dropdown": "1.0.3", "react-native-permissions": "^3.0.4", "react-native-reanimated": "^2.2.0", "react-native-safe-area-context": "^3.2.0", "react-native-screens": "^3.3.0", "react-native-vector-icons": "^8.1.0", "react-native-windows": "^0.64.14", "tipsi-stripe": "^9.0.0", "toggle-switch-react-native": "^3.2.0", "tsutils": "^3.21.0", "typescript": "^4.3.5" }, "devDependencies": { "@babel/core": "^7.12.9", "@babel/runtime": "^7.12.5", "@react-native-community/eslint-config": "^2.0.0", "babel-jest": "^26.6.3", "eslint": "7.14.0", "jest": "^26.6.3", "metro-react-native-babel-preset": "^0.64.0", "react-test-renderer": "17.0.1" }, "jest": { "preset": "react-native" } }

alexbubly commented 3 years ago

I do have same problem with both iOS and Android projects

arekkubaczkowski commented 3 years ago

@vivekmahato26 does your project meet all sdk's requirements https://github.com/stripe/stripe-react-native#android ? if so, please provide some more information about your error since

"java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbq;"

doesn't say much and seems to be not related to the SDK.

@alexbubly what is your exact problem? this issue is related only to android and you can't run it on both platforms. Please create another issue using our template.

arekkubaczkowski commented 3 years ago

closing due to inactivity, please reopen if you still having issues.