【问题标题】:Firebase react-native can not accessFirebase react-native 无法访问
【发布时间】:2018-05-13 11:51:13
【问题描述】:

我将 firebase 添加到我的 react 本机应用程序中。我正在尝试在android中编译它,但我们遇到了问题。我团队的其他成员没有任何问题,他们中的一些人无法运行它并且他们正在收到消息。

 basePerformance.java:39: error: cannot access zze
    getOrCreateTrace(identifier).start();
                            ^
 class file for com.google.android.gms.internal.firebase-perf.zze not found

这听起来像是一个依赖问题或类似的问题。我们现在正在挣扎一天,对此我们一无所知。有人可以帮忙吗?这是我们的毕业典礼

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"

    defaultConfig {
        applicationId "com.ourApp"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 10
        versionName "0.1.6"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    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"
        }
    }
    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]
            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 fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:27.1.1"
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation project(':react-native-i18n')
    implementation project(':react-native-mail')
    implementation project(':react-native-image-picker')
    implementation project(':react-native-fast-image')

    implementation(project(':react-native-firebase')) {
        transitive = false
    }

    // Firebase dependencies
    implementation "com.google.android.gms:play-services-base:15.0.1"
    implementation "com.google.firebase:firebase-core:15.0.2"
    implementation "com.google.firebase:firebase-messaging:15.0.2"
    implementation "com.google.firebase:firebase-analytics:15.0.2"
    implementation 'me.leolin:ShortcutBadger:1.1.21@aar'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
        transitive = true
    }
}

// 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: "../../node_modules/react-native-vector-icons/fonts.gradle"
apply plugin: 'com.google.gms.google-services'

【问题讨论】:

    标签: android firebase react-native


    【解决方案1】:

    最后我解决了这个问题。这是用于编译的 Java SDK 的问题。如果您使用 SDK 9 或 10,您将面临此错误。我将其更改为 Java 8,现在可以使用了。

    【讨论】:

    • 嗨,我在这里遇到了同样的错误。您是如何设法更改构建时使用的 java SDK 版本的? (我在 mac 上)我已经安装了 Java SE Development Kit 8u171,导出 JAVA_HOME 以指向 usr/libexec/java_home -v 1.8.0_171 并从 echo $JAVA_HOME 获取“usr/libexec/java_home -v 1.8.0_171”。但是......仍然得到同样的错误:/看起来项目中链接到JAVA SKD或JAVA版本在我的情况下不是问题:/
    • 嗨,我正在使用 Windows,我卸载了 SDK 10 并更改了 JAVA_HOME。我不知道它在mac中是如何工作的,但至少在用户中你有系统环境变量和用户环境变量,我改变了两者。使用您尝试使用的 java 版本对我有用
    • 感谢您的回复。我通过手动删除所有 Java 9 文件来解决我的问题。对于遇到此特定问题的 Mac 用户: 1. 安装 Java 8 2. 从 /Library/Java/JavaVirtualMachines/ 中删除与 Java 较新版本相关的所有文件 3. 使用“java -version”检查当前的 Java 版本跨度>
    • 大家都这么说,但是怎么改SDK呢?
    【解决方案2】:

    固定更改为 Java 8

    检查你正在使用的版本java -version

    mac 用户

    export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-17
      • 2019-02-07
      • 1970-01-01
      • 2021-08-02
      • 1970-01-01
      • 1970-01-01
      • 2020-01-13
      • 2016-07-27
      相关资源
      最近更新 更多