运行发布版本时反应原生 + 火碱崩溃



我在我的应用程序中使用了react-native和firebase/firestore。在开发时一切正常,但是当我收集 android 的发布版本时,它在应用程序启动时崩溃。发生错误。该应用程序在启动后立即关闭...

当我添加以下行时,会发生这种情况:

import * as Firebase from 'firebase';

我没有为 android 构建应用程序的经验,我很难理解我错过或做错了什么。

My build.gradle:

buildscript {
ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 16
    compileSdkVersion = 28
    targetSdkVersion = 27
    supportLibVersion = "28.0.0"
}
repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
    classpath 'com.google.gms:google-services:4.2.0' 
}
}
allprojects {
repositories {
    mavenLocal()
    google()
    jcenter()
    maven {
        url "$rootDir/../node_modules/react-native/android"
    }
}
}
task wrapper(type: Wrapper) {
    gradleVersion = '4.7'
    distributionUrl = distributionUrl.replace("bin", "all")
}

My App/build.gradle

apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
    entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
    applicationId "com.alcoexpert"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}
signingConfigs {
    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
        }
    }
}
splits {
    abi {
        reset()
        enable enableSeparateBuildPerCPUArchitecture
        universalApk false  // If true, also generate a universal APK
        include "armeabi-v7a", "x86", "arm64-v8a"
    }
}
buildTypes {
    release {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), 
"proguard-rules.pro"
        signingConfig signingConfigs.release
    }
}
// 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:
        // http://tools.android.com/tech-docs/new-build-system/user- 
guide/apk-splits
        def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3]
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {  // null for the universal-debug, 
universal-release variants
            output.versionCodeOverride =
                    versionCodes.get(abi) * 1048576 + 
defaultConfig.versionCode
        }
    }
}
}
dependencies {
implementation project(':react-native-gesture-handler')
implementation project(':react-native-i18n')
implementation project(':react-native-vector-icons')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat- 
v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+"  // From 
node_modules
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-firestore:17.1.5'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
}
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'

我自己已经为此苦苦挣扎了一段时间。拯救我的是添加import '@firebase/database'命名空间。你将不得不npm install事情才能让 eslint 安静下来。这是我的完整片段:

import firebase from '@firebase/app'
import '@firebase/database'
import '@firebase/auth'

相关内容

  • 没有找到相关文章

最新更新