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

App crash on launch

Open iamvucms opened this issue 2 years ago • 10 comments

Description

App is crashing on android after upgrade to latest react-native-screens

Screenshots

image

Steps To Reproduce

  1. Upgrade react native screens from 2.18.1 to latest version and got this isssue

Expected behavior

Latest react native screens working fine on android

Actual behavior

App crash on launching

Reproduction

app/build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.crashlytics'

import com.android.build.OutputFile

/**
 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
 * and bundleReleaseJsAndAssets).
 * These basically call `react-native bundle` with the correct arguments during the Android build
 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
 * bundle directly from the development server. Below you can see all the possible configurations
 * and their defaults. If you decide to add a configuration block, make sure to add it before the
 * `apply from: "../../node_modules/react-native/react.gradle"` line.
 *
 * project.ext.react = [
 *   // the name of the generated asset file containing your JS bundle
 *   bundleAssetName: "index.android.bundle",
 *
 *   // the entry file for bundle generation
 *   entryFile: "index.android.js",
 *
 *   // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
 *   bundleCommand: "ram-bundle",
 *
 *   // whether to bundle JS and assets in debug mode
 *   bundleInDebug: false,
 *
 *   // whether to bundle JS and assets in release mode
 *   bundleInRelease: true,
 *
 *   // whether to bundle JS and assets in another build variant (if configured).
 *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
 *   // The configuration property can be in the following formats
 *   //         'bundleIn${productFlavor}${buildType}'
 *   //         'bundleIn${buildType}'
 *   // bundleInFreeDebug: true,
 *   // bundleInPaidRelease: true,
 *   // bundleInBeta: true,
 *
 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
 *   // for example: to disable dev mode in the staging build type (if configured)
 *   devDisabledInStaging: true,
 *   // The configuration property can be in the following formats
 *   //         'devDisabledIn${productFlavor}${buildType}'
 *   //         'devDisabledIn${buildType}'
 *
 *   // the root of your project, i.e. where "package.json" lives
 *   root: "../../",
 *
 *   // where to put the JS bundle asset in debug mode
 *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
 *
 *   // where to put the JS bundle asset in release mode
 *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in debug mode
 *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in release mode
 *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
 *
 *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
 *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
 *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
 *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
 *   // for example, you might want to remove it from here.
 *   inputExcludes: ["android/**", "ios/**"],
 *
 *   // override which node gets called and with what additional arguments
 *   nodeExecutableAndArgs: ["node"],
 *
 *   // supply additional arguments to the packager
 *   extraPackagerArgs: []
 * ]
 */

project.ext.react = [
        entryFile: 'index.js',
        enableHermes: true,  // clean and rebuild if changing
]

apply from: '../../node_modules/react-native/react.gradle'
apply from: '../../node_modules/react-native-vector-icons/fonts.gradle'

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = true

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = true

/**
 * The preferred build flavor of JavaScriptCore.
 *
 * For example, to use the international variant, you can use:
 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
 *
 * The international variant includes ICU i18n library and necessary data
 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
 * give correct results when using with locales other than en-US.  Note that
 * this variant is about 6MiB larger per architecture than default.
 */
def jscFlavor = 'org.webkit:android-jsc:+'

/**
 * Whether to enable the Hermes VM.
 *
 * This should be set on project.ext.react and mirrored here.  If it is not set
 * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
 * and the benefits of using Hermes will therefore be sharply reduced.
 */
def enableHermes = project.ext.react.get('enableHermes', false)

/**
 * Architectures to build native code for in debug.
 */
def nativeArchitectures = project.getProperties().get('reactNativeDebugArchitectures')

def billing_version = '4.0.0'

android {
    dexOptions {
        javaMaxHeapSize '3g'
    }

    ndkVersion rootProject.ext.ndkVersion

    compileSdkVersion rootProject.ext.compileSdkVersion

    defaultConfig {
        missingDimensionStrategy 'react-native-camera', 'general'
        missingDimensionStrategy 'store', 'play'
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
        applicationId 'com.xxxxxx.community'
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 3205
        versionName '3205.0'
    }
    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'
            if (nativeArchitectures) {
                ndk {
                    abiFilters nativeArchitectures.split(',')
                }
            }
        }
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword MYAPP_RELEASE_STORE_PASSWORD
                keyAlias MYAPP_RELEASE_KEY_ALIAS
                keyPassword MYAPP_RELEASE_KEY_PASSWORD
            }
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://facebook.github.io/react-native/docs/signed-apk-android.
            signingConfig signingConfigs.release
            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
            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)
            }
        }
    }

    packagingOptions {
        pickFirst '**/armeabi-v7a/libc++_shared.so'
        pickFirst '**/x86/libc++_shared.so'
        pickFirst '**/arm64-v8a/libc++_shared.so'
        pickFirst '**/x86_64/libc++_shared.so'
        pickFirst '**/x86/libjsc.so'
        pickFirst '**/armeabi-v7a/libjsc.so'
    }
}

configurations.all {
    resolutionStrategy {
        force 'com.facebook.android:facebook-android-sdk:4.22.1'
        force 'com.android.support:support-v4:27.1.0'
    }

    resolutionStrategy.eachDependency { details ->
        def requested = details.requested
        if (requested.group == 'androidx.annotation') {
            details.useVersion '1.0.0'
            exclude group: 'androidx.annotation'
        }

        if (requested.group == 'androidx.arch.core') {
            details.useVersion '2.0.0'
            exclude group: 'androidx.arch.core'
        }
    }
}
dependencies {
    implementation'com.facebook.soloader:soloader:0.10.3+'

    implementation project(':react-native-webview')
    implementation project(':react-native-onesignal')
    implementation project(':react-native-vector-icons')
    implementation project (':react-native-video')
    implementation project(':@react-native-firebase_app')
    implementation project(':@react-native-firebase_analytics')
    implementation project(':react-native-paypal-lib')
    implementation project(':react-native-splash-screen')
    implementation project(':react-native-image-crop-picker')
    implementation platform('com.google.firebase:firebase-bom:29.0.3')
    implementation 'com.google.firebase:firebase-messaging:21.1.0'
    implementation 'com.google.firebase:firebase-perf'

    implementation 'com.google.firebase:firebase-crashlytics'
    implementation "com.android.billingclient:billing:$billing_version"
    implementation project(path: ':@react-native-community_cameraroll')
    compile ('com.google.android.gms:play-services-gcm:10.0.1') {
        force = true
    }

    compile 'com.facebook.fresco:fresco:2.5.0'
    implementation 'com.facebook.fresco:animated-gif:2.5.0'
    compile project(':WebRTCModule')
    implementation project(':react-native-maps')
    implementation project(':react-native-image-picker')
    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-contacts')
    implementation project(':@react-native-community_async-storage')
    implementation project(':react-native-svg')
    implementation project(':react-native-reanimated')
    compile (project(':react-native-push-notification')) {
        exclude group: 'com.google.android.gms', module: 'play-services-gcm'
        exclude group: 'com.google.firebase'
    }
    implementation 'com.google.android.gms:play-services-gcm:17.0.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.google.firebase:firebase-core:17.2.2'
    implementation 'com.android.support:design:27.1.0'
    implementation (project(':tipsi-stripe'))
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.facebook.react:react-native:+'  // From node_modules
    implementation 'androidx.appcompat:appcompat:1.3.0-alpha01'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
    implementation "androidx.appcompat:appcompat:1.0.0"
    //implementation 'com.android.support:appcompat-v7:29.0.0' //supportLibVersion = 29.0.0
//    implementation 'com.android.support:support-v4:+'

    implementation 'com.android.support:support-v13:28.0.0'

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

// 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.implementation
    into 'libs'
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.firebase-perf'

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

android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "30.0.2"
        minSdkVersion = 21
        compileSdkVersion = 30
        targetSdkVersion = 30
        // supportLibVersion = "29.0.0"
        androidXAnnotation = "1.1.0"
        androidXBrowser = "1.0.0"
        firebaseVersion = "17.+"
        googlePlayServicesVersion = "16.+"
        androidMapsUtilsVersion = "+"
        kotlinVersion = "+"
        firebaseMessagingVersion = "21.1.0"
        ndkVersion = "21.4.7075529"
    }
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
        maven { url 'https://plugins.gradle.org/m2/' }
        maven { url 'https://maven.google.com' }

    }
    dependencies {
        classpath('com.android.tools.build:gradle:4.2.2')
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.14.0'
        classpath 'com.google.firebase:perf-plugin:1.4.1'
        
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        // Add jitpack repository (added by tipsi-stripe)
        maven { url "https://jitpack.io" }
        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")
        }
        maven { url 'https://maven.google.com' }
        google()
        jcenter()
      	maven {
      	    url "https://sdks.instabug.com/nexus/repository/instabug-cp"
       	}

      }
}

configurations.all {
    resolutionStrategy {
        force 'com.facebook.android:facebook-android-sdk:4.22.1'
    }
    resolutionStrategy.eachDependency {details ->
        def requested = details.requested
        if (requested.group == 'com.google.android.gms') {
            details.useVersion '12.0.1'
        }
        if (requested.group == 'com.google.firebase') {
            details.useVersion '12.0.1'
        }
    }
}

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 29
                buildToolsVersion "29.0.3"
            }
        }
        if (project.name.contains('react-native-image-picker')) {
            buildscript {
                repositories {
                    maven { url "https://dl.bintray.com/android/android-tools/"  }
                    jcenter()
                }
            }
        }
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

Platform

  • [ ] iOS
  • [x ] Android
  • [ ] Web
  • [ ] Windows
  • [ ] tvOS

Workflow

  • [ ] Managed workflow
  • [ x] Bare workflow

Package versions

package version
react-native 0.66.1
@react-navigation/native latest 6.x
@react-navigation/native-stack latest 6.x
react-native-screens 3.13.1
react-native-safe-area-context 3.2.0
react-native-gesture-handler ^1.10.3
react-native-reanimated 2.3.0-beta.3
expo

iamvucms avatar Mar 25 '22 08:03 iamvucms

Hey! 👋

It looks like you've omitted a few important sections from the issue template.

Please complete Reproduction section.

github-actions[bot] avatar Mar 25 '22 08:03 github-actions[bot]

The top of the stack trace suggests not finding some class which does not seem related to react-native-screens. Did you clear all the caches etc.? There were many changes related to the new architecture so it is for sure good to do it. If it doesn't work, please try and provide a minimal repro as suggested by github bot.

WoLewicki avatar Mar 28 '22 07:03 WoLewicki

@WoLewicki Hmm, I just think android project settings isn't compatible with new react native screens. Actually it was working fine after I reverted back to old version. Not sure why

iamvucms avatar Mar 28 '22 11:03 iamvucms

Did you try to setup a fresh project with your version of RN and react-native-screens and check if it works there? Maybe there is something specific in your project that causes this crash. If not, we will need a simple repo with reproduction to be able to say more.

WoLewicki avatar Mar 28 '22 11:03 WoLewicki

Yes, it's working on fresh project. Going to reproduce the bug here

iamvucms avatar Mar 28 '22 12:03 iamvucms

Hey @WoLewicki. So sorry for late, I've just created reproduction of the crash issue in this repo : https://github.com/iamvucms/rn-screens-reproduce-crash-android.

iamvucms avatar Mar 30 '22 09:03 iamvucms

@iamvucms I tested the repo you provided and it is true that the current version of library leads to the crash and 2.18.1 version doesn't. Still, I think the crash is not a product of react-native-screens since the crash message is such: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/arch/core/executor/ArchTaskExecutor;, meaning there are problems with project configuration. I cannot help much more with this and I am not sure if there is anything we can do on the side of react-native-screens. Did you look for the solutions of this exact error?

WoLewicki avatar Apr 12 '22 13:04 WoLewicki

@WoLewicki Thank you so much for checking my repo. I will back to this issue after find solution.

iamvucms avatar Apr 12 '22 16:04 iamvucms

@iamvucms

hello did you find solution ??

thank you

ferasabufares avatar May 10 '22 12:05 ferasabufares

@ferasabufares Sorry, I did not. I'm still keeping using old version. Not sure what is conflicting in my android config vs rn screens

iamvucms avatar May 10 '22 15:05 iamvucms