React Native 0.59.9应用在Android中崩溃

时间:2019-12-20 09:57:15

标签: javascript android react-native

当我登录并进入主应用程序时,该应用程序崩溃,但是当我进入登录屏幕时却没有任何问题,并且几秒钟后该应用程序都崩溃了。 IOS运行正常并且运行良好。

反应本机环境信息:   系统:       作业系统:Windows 10       CPU:(8)x64 Intel(R)CoreTM i5-8300H CPU @ 2.30GHz       内存:1.19 GB / 7.85 GB     二进制文件:       纱线:1.19.2-C:\ Program Files(x86)\ Yarn \ bin \ yarn.CMD       npm:6.11.2-C:\ Program Files \ nodejs \ npm.CMD

package.json

    {
  "name": "FitnessCapital",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start -- --reset-cache",
    "test": "jest",
    "postinstall": "sh ./fix.sh"
  },
  "dependencies": {
    "@feathersjs/authentication-client": "^1.0.2",
    "@feathersjs/feathers": "^3.1.7",
    "@feathersjs/socketio-client": "^1.1.0",
    "@react-native-community/slider": "^2.0.0",
    "appcenter": "^1.6.0",
    "appcenter-analytics": "^1.6.0",
    "appcenter-crashes": "^1.6.0",
    "axios": "^0.18.0",
    "cloudinary": "^1.13.2",
    "instabug-reactnative": "^8.3.2",
    "mobx": "4.3.1",
    "mobx-react": "5.1.0",
    "moment": "^2.24.0",
    "native-base": "^2.8.0",
    "react": "16.8.3",
    "react-native": "^0.59.9",
    "react-native-amplitude-analytics": "^0.2.6",
    "react-native-easy-grid": "^0.2.0",
    "react-native-extended-stylesheet": "^0.11.1",
    "react-native-fbsdk": "^0.10.0",
    "react-native-fetch-blob": "^0.10.8",
    "react-native-gifted-chat": "^0.4.3",
    "react-native-google-signin": "2.0.0",
    "react-native-image-crop-picker": "^0.24.1",
    "react-native-image-picker": "^0.27.0",
    "react-native-linear-gradient": "^2.5.3",
    "react-native-modal": "^6.5.0",
    "react-native-navigation": "^1.1.493",
    "react-native-permissions": "^1.1.1",
    "react-native-progress": "^3.5.0",
    "react-native-push-notification": "^3.1.2",
    "react-native-share": "^1.2.1",
    "react-native-smtp-mailer": "^1.1.8",
    "react-native-snap-carousel": "^3.7.5",
    "react-native-svg": "^9.4.0",
    "react-native-svg-charts": "^5.2.0",
    "react-native-swiper": "^1.5.13",
    "react-native-vector-icons": "^6.3.0",
    "react-native-video": "^4.0.0",
    "react-native-view-shot": "^2.6.0",
    "react-timer-mixin": "^0.13.4",
    "socket.io-client": "^2.1.1",
    "victory-native": "^31.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.4.4",
    "@babel/plugin-proposal-decorators": "^7.4.4",
    "@babel/preset-flow": "^7.0.0",
    "@babel/runtime": "^7.4.4",
    "babel-eslint": "^8.2.5",
    "babel-jest": "^24.8.0",
    "babel-plugin-transform-decorators-legacy": "^1.3.5",
    "babel-preset-react-native": "^4.0.0",
    "eslint": "^4.19.1",
    "eslint-config-airbnb": "^17.0.0",
    "eslint-plugin-import": "^2.13.0",
    "eslint-plugin-jsx-a11y": "^6.1.0",
    "eslint-plugin-react": "^7.10.0",
    "jest": "^24.8.0",
    "metro-react-native-babel-preset": "^0.54.0",
    "react-test-renderer": "16.8.3"
  },
  "jest": {
    "preset": "react-native",
    "setupFiles": [
      ".\\node_modules\\appcenter\\test\\AppCenterMock.js",
      ".\\node_modules\\appcenter-analytics\\test\\AppCenterAnalyticsMock.js",
      ".\\node_modules\\appcenter-crashes\\test\\AppCenterCrashesMock.js"
    ]
  }
}

adroid / build.gradle

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

def versionOverrides = [
"com.facebook.android:facebook-android-sdk": "4.37.0",
]

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
        googlePlayServicesAuthVersion = "15.0.1"
    }
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath 'com.google.gms:google-services:4.0.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
subprojects {
    if (project.name.contains('react-native-image-picker')) {
    buildscript {
        repositories {
            jcenter()
            maven { url "https://dl.bintray.com/android/android-tools/" }
            }

        }
    }
    afterEvaluate {project ->
    // force libs to use recent buildtools
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion = 28  // change to match your desired version
                buildToolsVersion = "28.0.3" // ....
            }
        }
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        maven { url "https://jitpack.io" }
        maven {
            url "https://sdks.instabug.com/nexus/repository/instabug-cp"
        }
    }

    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def overrideVersion = versionOverrides[details.requested.group + ":" + details.requested.name]

        if (overrideVersion != null && details.requested.version != overrideVersion) {
            details.useVersion overrideVersion
        }
    }
}

}

ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 16
    compileSdkVersion = 28
    targetSdkVersion = 28
    supportLibVersion = "28.0.0"

}

2 个答案:

答案 0 :(得分:0)

您可以在Android Studio的Logcat中检查错误的详细信息。 如果没有针对此错误的解决方法,请在此处发布,我们将尽力帮助您解决此问题

答案 1 :(得分:0)

大多数情况下,调试版本可以正常工作并且应用程序崩溃而发行版本中没有错误,这是由于proguard引起的。在您的android / app / build.gradle上尝试此设置并构建您发布的应用,以测试是否存在这种情况

    buildTypes {
    debug {
        signingConfig signingConfigs.debug
    }
    release {
        signingConfig signingConfigs.release

        // JUST LEAVE THE ABOVE LINE AND COMMENT EVERYTHING ELSE IN THIS BLOCK
        // minifyEnabled enableProguardInReleaseBuilds
        // proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}

并配置您的proguard。通常,您必须添加以下代码行,

-keep class installed.package.identifier.**  { *; }

installed.package.identifier是受proguard影响导致崩溃的软件包。您需要弄清楚可能是哪个软件包引起的,并添加其包标识符,以使proguard不会删除所需的类。