Fresh Detached Expo + RNFirebase无法在Android上运行 [英] Fresh Detached Expo + RNFirebase not running on Android

查看:85
本文介绍了Fresh Detached Expo + RNFirebase无法在Android上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图使用Detached Expokit和React Native Firebase(v3)启动应用程序

So I'm trying to start an app using the Detached Expokit and React Native Firebase (v3)

我用exp cli做了一个新项目, 遵循 https://invertase.io/react-native-firebase/上的所有说明设置ios,并且运行正常 按照所有说明在Android上进行设置, 在expo依赖和firebase依赖之间经历了一些依赖地狱

I made a fresh project with exp cli, followed all the instructions at https://invertase.io/react-native-firebase/ to set up ios, and it runs fine followed all the instructions to set up on android, went through some dependency hell between the expo dependencies and firebase dependencies

现在不再有警告,也没有错误,但是当我尝试运行应用程序(仿真器或物理应用程序)时,它将js捆绑软件加载到100%,然后崩溃.没有错误或消息,只是崩溃.

And now there are no more warnings, and no more errors, but when i try to run the app (either emulator or physical), it loads the js bundle to 100%, then crashes. No errors, or messages, just crash.

我已经尝试过我能想到的一切(清理,重建,清除缓存,重新安装npm,降级到RNFirebase 2x)

Ive tried everything i can think of (clean, rebuild, clear cache, reinstall npm, downgrading to RNFirebase 2x)

是否有人曾经遇到过此问题,或者知道如何解决? 预先感谢

has anyone run into this issue before, or know how to fix? Thanks in advance

项目信息(如果需要,请询问更多)

project info (ask for more if needed)

package.json:

package.json:

 "dependencies": {
    "expo": "^21.0.0",
    "react": "16.0.0-alpha.12",
    "react-native": "https://github.com/expo/react-native/archive/sdk-21.0.2.tar.gz",
    "react-native-firebase": "^3.0.2"
  }

app.json:

{
  "expo": {
    "name": "xxx",
    "description": "An empty new project",
    "slug": "xxx",
    "privacy": "unlisted",
    "sdkVersion": "20.0.0",
    "version": "1.0.0",
    "orientation": "portrait",
    "primaryColor": "#cccccc",
    "icon": "./assets/icons/app-icon.png",
    "loading": {
      "icon": "./assets/icons/loading-icon.png"
    },
    "packagerOpts": {
      "assetExts": [
        "ttf",
        "mp4"
      ]
    },
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "xxx",
      "publishBundlePath": "ios/xxx/Supporting/shell-app.bundle",
      "publishManifestPath": "ios/xxx/Supporting/shell-app-manifest.json"
    },
    "android": {
      "package": "xxx"
    },
    "isDetached": true,
    "detach": {
      "scheme": "exp7d16843de771498786f3beabce0d6439",
      "iosExpoViewUrl": "https://s3.amazonaws.com/exp-exponent-view-code/ios-v1.20.5-sdk21.0.0-xxx.tar.gz",
      "androidExpoViewUrl": "https://s3.amazonaws.com/exp-exponent-view-code/android-v1.20.0-sdk21.0.0-xxx.tar.gz"
    }
  }
}

项目build.gradle:

project build.gradle:

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

buildscript {
  repositories {
    jcenter()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:2.3.3'
    classpath 'com.google.gms:google-services:3.1.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
  }
}

allprojects {
  repositories {
    mavenLocal()
    jcenter()
    maven {
      // Point to local maven repository
      url "$rootDir/../.expo-source/android/maven"
    }
    maven {
      url 'https://maven.google.com'
    }
    maven {
      url "https://jitpack.io"
    }
  }
}

task clean(type: Delete) {
  delete rootProject.buildDir
}

app build.gradle:

app build.gradle:

apply plugin: 'com.android.application'

android {
  compileSdkVersion 25
  buildToolsVersion '25.0.2'

  defaultConfig {
    applicationId "xxx"
    minSdkVersion 19
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
    ndk {
      abiFilters 'armeabi-v7a', 'x86'
    }
    manifestPlaceholders = [
      'appAuthRedirectScheme': 'xxx'
    ]
  }
  buildTypes {
    release {
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }
  dexOptions {
    javaMaxHeapSize "8g"
  }
  packagingOptions {
    pickFirst 'META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.properties'
    pickFirst 'META-INF/maven/com.fasterxml.jackson.core/jackson-core/pom.xml'
    pickFirst 'META-INF/services/com.fasterxml.jackson.core.JsonFactory'
    pickFirst 'META-INF/maven/com.squareup.okhttp/okhttp/pom.properties'
    pickFirst 'META-INF/maven/com.squareup.okhttp/okhttp/pom.xml'
    pickFirst 'META-INF/maven/com.squareup.okio/okio/pom.properties'
    pickFirst 'META-INF/maven/com.squareup.okio/okio/pom.xml'
    pickFirst 'META-INF/LICENSE'
  }
}

task exponentPrebuildStep(type: Exec) {
  workingDir '../../'

  if (System.getProperty('os.name').toLowerCase().contains('windows')) {
    commandLine 'cmd', '/c', '.\\.expo-source\\android\\detach-scripts\\prepare-detached-build.bat'
  } else {
    commandLine './.expo-source/android/detach-scripts/prepare-detached-build.sh'
  }
}
preBuild.dependsOn exponentPrebuildStep

repositories{
  flatDir{
    dirs 'libs'
  }
  mavenLocal()
  maven { url 'https://maven.fabric.io/public' }
}

dependencies {
  compile(project(':react-native-firebase')) {
    // exclude group: 'com.google.android.gms'
    // exclude group: 'com.google.firebase'
    transitive = false
  }

  // RNFirebase required dependencies
  compile "com.google.firebase:firebase-core:11.4.2"

  // RNFirebase optional dependencies
  // compile "com.google.firebase:firebase-ads:11.4.2"
  // compile "com.google.firebase:firebase-auth:11.4.2"
  // compile "com.google.firebase:firebase-config:11.4.2"
  // compile "com.google.firebase:firebase-crash:11.4.2"
  compile "com.google.firebase:firebase-database:11.4.2"
  // compile "com.google.firebase:firebase-firestore:11.4.2"
  // compile "com.google.firebase:firebase-messaging:11.4.2"
  // compile "com.google.firebase:firebase-perf:11.4.2"
  // compile "com.google.firebase:firebase-storage:11.4.2"

  compile fileTree(dir: 'libs', include: ['*.jar'])
  testCompile 'junit:junit:4.12'
  compile ('com.android.support:appcompat-v7:25.3.1') {
    force = true
  }
  compile ('com.android.support:recyclerview-v7:25.3.1') {
    force= true
  }
  compile ('com.android.support:animated-vector-drawable:25.3.1') {
    force= true
  }
//  compile 'com.android.support:multidex:1.0.1'


  compile('host.exp.exponent:expoview:21.0.0@aar') {
    exclude group: 'com.google.android.gms'
    exclude group: 'com.facebook.android', module: 'facebook-android-sdk'
    exclude group: 'com.facebook.android', module: 'audience-network-sdk'
    exclude group: 'io.nlopez.smartlocation', module: 'library'
    transitive = true;
  }

  compile ("com.google.android.gms:play-services-base:11.4.2") {
    force = true
  }
  compile ("com.google.android.gms:play-services-maps:11.4.2") {
    force = true
  }
  compile ('com.facebook.android:facebook-android-sdk:4.+') {
    exclude module: 'bolts-android'
  }
  compile('com.facebook.android:audience-network-sdk:4.+') {
    exclude module: 'play-services-ads'
  }
  compile('io.nlopez.smartlocation:library:3.2.11') {
    transitive = false
  }

}

apply plugin: 'com.google.gms.google-services'

mainApplication.java:

mainApplication.java:

package xxx;

import android.support.multidex.MultiDexApplication;

import com.facebook.react.ReactPackage;

import java.util.Arrays;
import java.util.List;

// Needed for `react-native link`
// import com.facebook.react.ReactApplication;

// React Native Firebase
import io.invertase.firebase.RNFirebasePackage; // <-- This should be added already
// Optional packages - add as appropriate
// import io.invertase.firebase.admob.RNFirebaseAdMobPackage; //Firebase AdMob
// import io.invertase.firebase.analytics.RNFirebaseAnalyticsPackage; // Firebase Analytics
// import io.invertase.firebase.auth.RNFirebaseAuthPackage; // Firebase Auth
// import io.invertase.firebase.config.RNFirebaseRemoteConfigPackage; // Firebase Remote Config
// import io.invertase.firebase.crash.RNFirebaseCrashPackage; // Firebase Crash Reporting
import io.invertase.firebase.database.RNFirebaseDatabasePackage; // Firebase Realtime Database
// import io.invertase.firebase.firestore.RNFirebaseFirestorePackage; // Firebase Firestore
// import io.invertase.firebase.messaging.RNFirebaseMessagingPackage; // Firebase Cloud Messaging
// import io.invertase.firebase.perf.RNFirebasePerformancePackage; // Firebase Performance
// import io.invertase.firebase.storage.RNFirebaseStoragePackage; // Firebase Storage

public class MainApplication extends MultiDexApplication {

  // Needed for `react-native link`
  public List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
        // Add your own packages here!
        // TODO: add cool native modules

        // Needed for `react-native link`
        // new MainReactPackage(),
        new RNFirebasePackage(),
        // Add these packages as appropriate
        // new RNFirebaseAdMobPackage(),
        // new RNFirebaseAnalyticsPackage(),
        // new RNFirebaseAuthPackage(),
        // new RNFirebaseRemoteConfigPackage(),
        // new RNFirebaseCrashPackage(),
        new RNFirebaseDatabasePackage()
        // new RNFirebaseFirestorePackage(),
        // new RNFirebaseMessagingPackage(),
        // new RNFirebasePerformancePackage(),
        // new RNFirebaseStoragePackage()
    );
  }
}

推荐答案

经过几天的摆弄,我终于让它运行了!

after days of fiddling, i finally got it to run!

诀窍是,我必须手动编译每个版本不匹配的Google Play服务模块.

The trick was, i had to manually compile each google play service modules that had a version mismatch.

(当您将鼠标悬停在依赖项上时,您会看到版本不匹配的警告)

(You can see the version mismatches as a warning when you hover over the dependency)

  compile "com.google.android.gms:play-services-base:11.4.2"
  compile "com.google.android.gms:play-services-base-license:11.4.2"
  compile "com.google.android.gms:play-services-ads:11.4.2"
  compile "com.google.android.gms:play-services-ads-lite:11.4.2"
  compile "com.google.android.gms:play-services-ads-license:11.4.2"
  compile "com.google.android.gms:play-services-analytics:11.4.2"
  compile "com.google.android.gms:play-services-analytics-impl:11.4.2"
  compile "com.google.android.gms:play-services-auth:11.4.2"
  compile "com.google.android.gms:play-services-auth-base:11.4.2"
  compile "com.google.android.gms:play-services-fitness:11.4.2"
  compile "com.google.android.gms:play-services-gcm:11.4.2"
  compile "com.google.android.gms:play-services-identity:11.4.2"
  compile "com.google.android.gms:play-services-maps:11.4.2"
  compile "com.google.android.gms:play-services-wallet:11.4.2"

这篇关于Fresh Detached Expo + RNFirebase无法在Android上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆