本机模块中的异常,FirebaseAuth的解析失败

时间:2019-01-06 22:36:42

标签: android firebase react-native react-native-firebase

我已经构建了一个应用程序,它在iPhone上运行正常,但是在Android上却出现了一个奇怪的错误。
我必须退出该应用程序,因为本机模块对于Firefbase(断开连接少)更可靠。
出现以下错误:

Java exception in 'NativeModules'
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/firestore/FieldValue;
io.invertase.firebase.firestore.RNFirebaseFirestore.getConstants
    RNFirebaseFirestore.java:759
com.facebook.react.bridge.JavaModuleWrapper.getConstants
    JavaModuleWrapper.java:138
android.os.Handler.handleCallback
    Handler.java:790
android.os.Handler.dispatchMessage
    Handler.java:99
com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage
    MessageQueueThreadHandler.java:29
moduleAndStatics
    C:\Users\snoof\Documents\project\react-native\node_modules\react-native-firebase\dist\utils\apps.js:190:42
Firebase
    C:\Users\snoof\Documents\project\react-native\node_modules\react-native-firebase\dist\modules\core\firebase.js:39:43
<unknown>
    C:\Users\snoof\Documents\project\react-native\node_modules\react-native-firebase\dist\modules\core\firebase.js:97:20
loadModuleImplementation
    C:\Users\snoof\Documents\project\react-native\node_modules\metro\src\lib\polyfills\require.js:292:12
<unknown>
    C:\Users\snoof\Documents\project\react-native\node_modules\react-native-firebase\dist\index.js:1
loadModuleImplementation
    C:\Users\snoof\Documents\project\react-native\node_modules\metro\src\lib\polyfills\require.js:292:12
<unknown>
    C:\Users\snoof\Documents\project\react-native\src\firebase.ts:1
loadModuleImplementation
    C:\Users\snoof\Documents\project\react-native\node_modules\metro\src\lib\polyfills\require.js:292:12
<unknown>
    C:\Users\snoof\Documents\project\react-native\src\Commons\rx+firebase\withIsSignedIn.ts:1
loadModuleImplementation
    C:\Users\snoof\Documents\project\react-native\node_modules\metro\src\lib\polyfills\require.js:292:12
<unknown>
    C:\Users\snoof\Documents\project\react-native\src\RootRouter.tsx:2
loadModuleImplementation
    C:\Users\snoof\Documents\project\react-native\node_modules\metro\src\lib\polyfills\require.js:292:12
<unknown>
    C:\Users\snoof\Documents\project\react-native\src\App.tsx:12
loadModuleImplementation
    C:\Users\snoof\Documents\project\react-native\node_modules\metro\src\lib\polyfills\require.js:292:12
<unknown>
    C:\Users\snoof\Documents\project\react-native\App.js:2
loadModuleImplementation
    C:\Users\snoof\Documents\project\react-native\node_modules\metro\src\lib\polyfills\require.js:292:12
guardedLoadModule
    C:\Users\snoof\Documents\project\react-native\node_modules\metro\src\lib\polyfills\require.js:179:45
global code

任何人都知道如何解决该问题或进行调查吗?

编辑,带有build.graddle,主要由Expo生成

buildscript {
    repositories {
        google()
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'

    defaultConfig {
        applicationId 'com.yamble.k'
        targetSdkVersion 26
        versionCode 1
        versionName '0.7.0'
        ndk {
            abiFilters 'armeabi-v7a', 'x86'
        }
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        // Deprecated. Used by net.openid:appauth
        manifestPlaceholders = [
                'appAuthRedirectScheme': 'host.exp.exponent'
        ]
    }
    dexOptions {
        javaMaxHeapSize System.getenv("DISABLE_DEX_MAX_HEAP") ? null : "8g"
    }

    flavorDimensions 'minSdk', 'remoteKernel'
    productFlavors {
        devKernel {
            dimension 'remoteKernel'
        }
        prodKernel {
            dimension 'remoteKernel'
        }
        devMinSdk {
            dimension 'minSdk'
            // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
            // to pre-dex each module and produce an APK that can be tested on
            // Android Lollipop without time consuming dex merging processes.
            minSdkVersion 21
        }
        prodMinSdk {
            dimension 'minSdk'
            minSdkVersion 21
        }
    }
    signingConfigs {
        debug {
            storeFile file('../debug.keystore')
        }
        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 {
            debuggable true
            ext.enableCrashlytics = false
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            zipAlignEnabled true
            signingConfig signingConfigs.release
        }
    }

    lintOptions {
        abortOnError false
    }
    packagingOptions {
        pickFirst "**"
    }
    configurations.all {
        resolutionStrategy.force 'com.android.support:design:27.1.0'
        resolutionStrategy.force 'com.android.support:support-v4:27.1.0'
    }
}


configurations.all {
    resolutionStrategy {
        force 'org.webkit:android-jsc:r224109'
    }
}


apply from: 'expo.gradle'


dependencies {
    implementation project(':react-native-firebase')
    implementation project(':react-native-contacts')
    implementation project(':instabug-reactnative')
    implementation project(':react-native-flurry-sdk')
    implementation project(':react-native-vector-icons')

    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.android.support:multidex:1.0.1'

    // Our dependencies
    implementation 'com.android.support:appcompat-v7:27.1.1'

    // Our dependencies from ExpoView
    // DON'T ADD ANYTHING HERE THAT ISN'T IN EXPOVIEW. ONLY COPY THINGS FROM EXPOVIEW TO HERE.
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.facebook.android:facebook-android-sdk:4.37.0'
    implementation('com.facebook.android:audience-network-sdk:4.99.0') {
        exclude module: 'play-services-ads'
    }
    compileOnly 'org.glassfish:javax.annotation:3.1.1'
    implementation 'com.jakewharton:butterknife:8.4.0'
    implementation 'de.greenrobot:eventbus:2.4.0'
    implementation 'com.amplitude:android-sdk:2.9.2'
    // Be careful when upgrading! Upgrading might break experience scoping. Check with Jesse. See Analytics.resetAmplitudeDatabaseHelper
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.google.android.gms:play-services-gcm:15.0.1'
    implementation 'com.google.android.gms:play-services-analytics:16.0.1'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.google.android.gms:play-services-auth:15.0.1'
    implementation 'com.google.android.gms:play-services-location:15.0.1'
    implementation 'com.google.android.gms:play-services-ads:15.0.1'
    annotationProcessor 'com.raizlabs.android:DBFlow-Compiler:2.2.1'
    implementation "com.raizlabs.android:DBFlow-Core:2.2.1"
    implementation "com.raizlabs.android:DBFlow:2.2.1"
    implementation "com.madgag.spongycastle:core:1.53.0.0"
    implementation "com.madgag.spongycastle:prov:1.53.0.0"
    debugImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
    // debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.4-beta1'
    releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
    implementation 'com.facebook.device.yearclass:yearclass:1.0.1'
    implementation 'commons-io:commons-io:1.3.2'
    implementation 'me.leolin:ShortcutBadger:1.1.4@aar'
    implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.7'
    implementation 'com.yqritc:android-scalablevideoview:1.0.1'
    implementation 'commons-codec:commons-codec:1.10'
    implementation 'com.segment.analytics.android:analytics:4.3.0'
    implementation 'com.google.zxing:core:3.2.1'
    implementation 'net.openid:appauth:0.4.1'
    implementation('com.airbnb.android:lottie:2.5.5') {
        exclude group: 'com.android.support', module: 'appcompat-v7'
    }
    implementation 'io.branch.sdk.android:library:2.17.1'
    implementation('io.nlopez.smartlocation:library:3.2.11') {
        transitive = false
    }
    implementation 'com.android.support:exifinterface:27.1.1'
    implementation 'com.squareup.okio:okio:1.9.0'
    implementation 'com.facebook.soloader:soloader:0.5.1'

    implementation 'com.google.android.exoplayer:exoplayer:2.6.1'
    implementation 'expolib_v1.com.google.android.exoplayer:expolib_v1-extension-okhttp:2.6.1@aar'

    // expo-file-system
    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
    implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.10.0'

    // Testing
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    // We use a modified build of com.android.support.test:runner:1.0.1. Explanation in maven-test/README
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support:support-annotations:27.1.1'
    androidTestImplementation 'com.google.code.findbugs:jsr305:3.0.0'
    androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
    androidTestImplementation 'com.azimolabs.conditionwatcher:conditionwatcher:0.2'

    testImplementation 'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-core:1.10.19'
    testImplementation 'org.robolectric:robolectric:3.8'
    testImplementation 'com.android.support.test:runner:1.0.2-alpha1'
    testImplementation 'com.android.support.test:rules:1.0.2-alpha1'


    implementation('host.exp.exponent:expoview:31.0.0@aar') {
        transitive = true
        exclude group: 'com.squareup.okhttp3', module: 'okhttp'
        exclude group: 'com.squareup.okhttp3', module: 'okhttp-urlconnection'
    }


}

// This has to be down here for some reason
apply plugin: 'com.google.gms.google-services'

在react-native-firebase中,我有一个(由expo生成):

buildscript {
  repositories {
    google()
    jcenter()
    maven {
      url 'https://maven.fabric.io/public'
    }
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:3.2.0'
  }
}

apply plugin: 'com.android.library'

def DEFAULT_COMPILE_SDK_VERSION = 27
def DEFAULT_BUILD_TOOLS_VERSION = "28.0.2"
def DEFAULT_TARGET_SDK_VERSION = 27
def DEFAULT_SUPPORT_LIB_VERSION = "27.1.1"

android {
  compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
  buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
  defaultConfig {
    minSdkVersion 16
    targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
  }
  buildTypes {
    release {
      minifyEnabled false
    }
  }
  productFlavors {
  }
  lintOptions {
    disable 'GradleCompatible'
  }
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
}

rootProject.gradle.buildFinished { buildResult ->
  if (buildResult.getFailure() != null) {
    //noinspection GroovyUnusedCatchParameter
    try {
      String message = buildResult.getFailure().properties.get("reportableCauses").toString()
      if (message.contains("com.android.dex.DexException: Multiple dex files define Lcom/google/") ||
        message.contains("java.util.zip.ZipException: duplicate entry: com/google/android/gms/")) {
        logger.log(LogLevel.ERROR, "")
        logger.log(LogLevel.ERROR, " -----------------------------------------------------------")
        logger.log(LogLevel.ERROR, "|                    REACT NATIVE FIREBASE                  |")
        logger.log(LogLevel.ERROR, " ----------------------------------------------------------- ")
        logger.log(LogLevel.ERROR, "|                                                           |")
        logger.log(LogLevel.ERROR, "|  This is a common build error when using libraries that   |")
        logger.log(LogLevel.ERROR, "|  require google play services.                            |")
        logger.log(LogLevel.ERROR, "|                                                           |")
        logger.log(LogLevel.ERROR, "|  This error occurs because different versions of google   |")
        logger.log(LogLevel.ERROR, "|  play services or google play services modules are being  |")
        logger.log(LogLevel.ERROR, "|  required by different libraries.                         |")
        logger.log(LogLevel.ERROR, "|                                                           |")
        logger.log(LogLevel.ERROR, "|  A temporary fix would be to set:                         |")
        logger.log(LogLevel.ERROR, "|                                                           |")
        logger.log(LogLevel.ERROR, "|             android { multiDexEnabled true }              |")
        logger.log(LogLevel.ERROR, "|                                                           |")
        logger.log(LogLevel.ERROR, "|  inside your build gradle, however it is recommended for  |")
        logger.log(LogLevel.ERROR, "|  your prod build that you de-duplicate these to minimize  |")
        logger.log(LogLevel.ERROR, "|  bundle size.                                             |")
        logger.log(LogLevel.ERROR, "|                                                           |")
        logger.log(LogLevel.ERROR, "|  See http://invertase.link/dupe-dex for how to do this.   |")
        logger.log(LogLevel.ERROR, "|                                                           |")
        logger.log(LogLevel.ERROR, " ----------------------------------------------------------- ")
      }
    } catch (Exception exception) {
    }
  }
}

repositories {
  google()
  jcenter()

  def found = false
  def parentDir = rootProject.projectDir
  def androidSourcesName = 'React Native sources'
  def androidPrebuiltBinaryName = 'React Native prebuilt binary'

  1.upto(4, {
    if (found) return true
    parentDir = parentDir.parentFile

    // Running React Native from sources locally or for ExpoKit
    def androidSourcesDir = new File(
      parentDir,
      'node_modules/react-native'
    )

    // Official releases of React Native come with a prebuilt version of Android sources
    // in ./android, e.g. react-native/android/**/react-native-0.57.1.aar
    def androidPrebuiltBinaryDir = new File(
      parentDir,
      'node_modules/react-native/android'
    )

    if (androidPrebuiltBinaryDir.exists()) {
      maven {
        url androidPrebuiltBinaryDir.toString()
        name androidPrebuiltBinaryName
      }

      println "${project.name}: using ${androidPrebuiltBinaryName} from ${androidPrebuiltBinaryDir.toString()}"
      found = true
    } else if (androidSourcesDir.exists()) {
      maven {
        url androidSourcesDir.toString()
        name androidSourcesName
      }

      println "${project.name}: using ${androidSourcesName} from ${androidSourcesDir.toString()}"
      found = true
    }
  })

  if (!found) {
    throw new GradleException(
      "${project.name}: unable to locate React Native android sources or prebuilt binary. " +
        "Ensure you have you installed React Native as a dependency in your project and try again."
    )
  }
}

def supportVersion = rootProject.hasProperty('supportLibVersion') ? rootProject.supportLibVersion : DEFAULT_SUPPORT_LIB_VERSION

dependencies {
  //noinspection GradleDynamicVersion
  api "com.facebook.react:react-native:+"

  /* ----------------------------
   *    REACT NATIVE FIREBASE
   * ---------------------------- */

  // Required dependencies
  //noinspection GradleCompatible
  compileOnly "com.google.firebase:firebase-core:16.0.4"
  compileOnly "com.google.android.gms:play-services-base:16.0.1"

  /* -------------------------
   *   OPTIONAL FIREBASE SDKS
   * ------------------------- */

  // Ads
  compileOnly('com.google.firebase:firebase-ads:15.0.1') {
    // exclude `customtabs` as the support lib version is out of date
    // we manually add it as a dependency below with a custom version
    exclude group: 'com.android.support', module: 'customtabs'
  }
  // Authentication
  compileOnly "com.google.firebase:firebase-auth:16.0.5"
  // Analytics
  compileOnly "com.google.firebase:firebase-analytics:16.0.4"
  // Performance Monitoring
  compileOnly "com.google.firebase:firebase-perf:16.2.0"
  // Remote Config
  compileOnly "com.google.firebase:firebase-config:16.1.0"
  // Cloud Storage
  compileOnly "com.google.firebase:firebase-storage:16.0.4"
  // Invites
  compileOnly "com.google.firebase:firebase-invites:16.0.4"
  // Dynamic Links
  compileOnly "com.google.firebase:firebase-dynamic-links:16.1.2"
  // Real-time Database
  compileOnly "com.google.firebase:firebase-database:16.0.4"
  // Cloud Functions
  compileOnly "com.google.firebase:firebase-functions:16.1.2"
  // Cloud Firestore
  compileOnly "com.google.firebase:firebase-firestore:17.1.2"
  // Cloud Messaging / FCM
  compileOnly "com.google.firebase:firebase-messaging:17.3.4"
  // Crashlytics
  compileOnly('com.crashlytics.sdk.android:crashlytics:2.9.5@aar') {
    transitive = true
  }
  /* --------------------------------
   *  OPTIONAL SUPPORT LIBS
   * -------------------------------- */

  // For Firebase Ads
  compileOnly "com.android.support:customtabs:$supportVersion"

  // For React Native Firebase Notifications
  api "com.android.support:support-v4:$supportVersion"

  // For React Native Firebase Notifications
  compileOnly 'me.leolin:ShortcutBadger:1.1.21@aar'
}

这是Mainapplication.java文件:

public List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
        // Add your own packages here!
        // TODO: add native modules!

        // Needed for `react-native link`
        // new MainReactPackage(),
            new RNFirebasePackage(),
            new ReactNativeContacts(),
                    new RNInstabugReactnativePackage.Builder("ID",MainApplication.this)
                            .setInvocationEvent("shake")
                            .setPrimaryColor("#1D82DC")
                            .setFloatingEdge("left")
                            .setFloatingButtonOffsetFromTop(250)
                            .build(),
            new FlurryPackage(),
            new VectorIconsPackage(),
            new RNFirebaseAuthPackage(),
            new RNFirebaseMessagingPackage(),
            new RNFirebaseNotificationsPackage()
    );
  }

0 个答案:

没有答案