发表文章

[Objective-C] 即时崩溃的 Android Instantly crashes on Android[react-native-fabric]

GeoffreyPlitt 2017-10-9 272

我已经完成了所有的安装步骤, 包括手动安装 Crashlytics 的 Android 和 iOS, 设置 API 键等。然后我安装了这个包通过 JS 访问的东西。

在 iOS 这一切都奏效了。

在 Android 上, 如果包被包括在内, 它会立即崩溃。我甚至没有调用任何 API 函数。以下代码:

var Fabric = require('react-native-fabric');
var { Crashlytics } = Fabric;

立即导致以下 RN 红色错误屏幕:

undefined is not an object (evaluating SMXCrahslytics.crash)
原文:

I've done all the installation steps, including installing Crashlytics manually as both Android and iOS, setting API key, etc. Then I installed this package to access things via JS.

On iOS this all worked.

On Android, it crashes immediately if the package is included. I'm not even calling any of the API functions. The following code:

var Fabric = require('react-native-fabric');
var { Crashlytics } = Fabric;

Immediately causes the following RN red error screen:

undefined is not an object (evaluating SMXCrahslytics.crash)
相关推荐
最新评论 (19)
npomfret 2017-10-9
1

通常我发现当链接过程不起作用时就会发生这种情况。 检查您的 MainApplication 用于:

@Override
    protected List<ReactPackage> getPackages() {
      reactCBLiteManager = new ReactCBLiteManager();

      return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new FabricPackage(), <- this line
      );
    }

  @Override
  public void onCreate() {
    super.onCreate();
    Fabric.with(this, new Crashlytics()); <- this line
  }

原文:

Usually I find this happens when the linking process hasn't worked. Check your MainApplication for:

@Override
    protected List<ReactPackage> getPackages() {
      reactCBLiteManager = new ReactCBLiteManager();

      return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new FabricPackage(), <- this line
      );
    }

  @Override
  public void onCreate() {
    super.onCreate();
    Fabric.with(this, new Crashlytics()); <- this line
  }

corymsmith 2017-10-9
2

@GeoffreyPlitt你是什么版本的 RN?你把这事解决了?

原文:

@GeoffreyPlitt What version of RN are you on? And did you sort this out?

GeoffreyPlitt 2017-10-9
3

@corymsmith下面是我的版本信息:

vlt236:stardust-app giro$ react-native --version
react-native-cli: 1.0.0
react-native: 0.32.1

现在尝试。我认为部分的问题是, "rnpm 链接反应-原布" 改变 MainActivity. java 而不是 MainApplication。

原文:

@corymsmith here's my version info:

vlt236:stardust-app giro$ react-native --version
react-native-cli: 1.0.0
react-native: 0.32.1

Trying it out now. I think part of the problem is that "rnpm link react-native-fabric" makes changes to MainActivity.java instead of MainApplication.java.

GeoffreyPlitt 2017-10-9
4

@corymsmith 好吧, 所以我已经越过了以前的错误, 现在我得到更多的, 我需要你的帮助。

ExceptionsManager.js:61 Cannot read property 'crash' of undefinedhandleException @ ExceptionsManager.js:61handleError @ InitializeJavaScriptAppEngine.js:115reportFatalError @ error-guard.js:30guardedLoadModule @ require.js:60_require @ require.js:49(anonymous function) @ require-0.js:1executeApplicationScript @ debuggerWorker.js:23message @ debuggerWorker.js:43
ExceptionsManager.js:61 Module AppRegistry is not a registered callable module.
原文:

@corymsmith OK, so I got past my previous errors, and now I get more that I need your help with.

ExceptionsManager.js:61 Cannot read property 'crash' of undefinedhandleException @ ExceptionsManager.js:61handleError @ InitializeJavaScriptAppEngine.js:115reportFatalError @ error-guard.js:30guardedLoadModule @ require.js:60_require @ require.js:49(anonymous function) @ require-0.js:1executeApplicationScript @ debuggerWorker.js:23message @ debuggerWorker.js:43
ExceptionsManager.js:61 Module AppRegistry is not a registered callable module.
GeoffreyPlitt 2017-10-9
5

@corymsmith有什么想法吗?

原文:

@corymsmith Any ideas?

GeoffreyPlitt 2017-10-9
6

@corymsmith@npomfret@jondot@myusuf3在最后期限前工作, 有人能帮忙吗?

原文:

@corymsmith @npomfret @jondot @myusuf3 Working on a deadline, can anyone help?

myusuf3 2017-10-9
7

对不起, 从未见过此错误。

原文:

Sorry never seen this error.

npomfret 2017-10-9
8

您是否检查过链接过程是否有效?你的 MainApplication 看起来像什么?

使用react-native link

原文:

Have you checked that the linking process has worked? What does your MainApplication look like?

use react-native link

GeoffreyPlitt 2017-10-9
9

这是我们的 MainApplication. java:

packagecom.stardust;

importandroid.app.Application;
importandroid.util.Log;

importcom.facebook.react.ReactApplication;
importcom.facebook.react.ReactInstanceManager;
importcom.facebook.react.ReactNativeHost;
importcom.facebook.react.ReactPackage;
importcom.facebook.react.shell.MainReactPackage;
importcom.facebook.CallbackManager;
importcom.facebook.FacebookSdk;
importcom.facebook.reactnative.androidsdk.FBSDKPackage;
importcom.facebook.appevents.AppEventsLogger;
importcom.brentvatne.react.ReactVideoPackage;
importcom.rnfs.RNFSPackage;
importcom.imagepicker.ImagePickerPackage;
importcom.BV.LinearGradient.LinearGradientPackage;
importcom.smixx.fabric.FabricPackage;
importio.fabric.sdk.android.Fabric;
importcom.crashlytics.android.Crashlytics;

importjava.util.Arrays;
importjava.util.List;

publicclassMainApplicationextendsApplicationimplementsReactApplication {

  privatefinalReactNativeHost=newReactNativeHost(this) {
    @Override
    protectedbooleangetUseDeveloperSupport() {
      returnBuildConfig.DEBUG;
    }

    @Override
    protectedList<ReactPackage>getPackages() {
      returnArrays.<ReactPackage>asList(
          newMainReactPackage(),
          newFBSDKPackage(mCallbackManager),
          newReactVideoPackage(),
          newRNFSPackage(),
          newImagePickerPackage(),
          newLinearGradientPackage()
      );
    }
  };

  @Override
  publicReactNativeHostgetReactNativeHost() {
      return mReactNativeHost;
  }

  privatestaticCallbackManager=CallbackManager.Factory.create();

  protectedstaticCallbackManagergetCallbackManager() {
    return mCallbackManager;
  }

  @Override
  publicvoidonCreate() {
    super.onCreate();
    Fabric.with(thisnewCrashlytics());
    FacebookSdk.sdkInitialize(getApplicationContext());
    // If you want to use AppEventsLogger to log events.
    AppEventsLogger.activateApp(this);
  }
}

仍然得到 "未定义的不是一个对象/评估 SMXCrashlytics. 崩溃"

原文:

Here's our MainApplication.java:

package com.stardust;

import android.app.Application;
import android.util.Log;

import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.CallbackManager;
import com.facebook.FacebookSdk;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.appevents.AppEventsLogger;
import com.brentvatne.react.ReactVideoPackage;
import com.rnfs.RNFSPackage;
import com.imagepicker.ImagePickerPackage;
import com.BV.LinearGradient.LinearGradientPackage;
import com.smixx.fabric.FabricPackage;
import io.fabric.sdk.android.Fabric;
import com.crashlytics.android.Crashlytics;

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

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    protected boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new FBSDKPackage(mCallbackManager),
          new ReactVideoPackage(),
          new RNFSPackage(),
          new ImagePickerPackage(),
          new LinearGradientPackage()
      );
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
      return mReactNativeHost;
  }

  private static CallbackManager mCallbackManager = CallbackManager.Factory.create();

  protected static CallbackManager getCallbackManager() {
    return mCallbackManager;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    Fabric.with(this, new Crashlytics());
    FacebookSdk.sdkInitialize(getApplicationContext());
    // If you want to use AppEventsLogger to log events.
    AppEventsLogger.activateApp(this);
  }
}

Still getting "undefined is not an object / evaluating SMXCrashlytics.crash"

npomfret 2017-10-9
10

还有你的 js 密码? 如何调用 "崩溃" 功能?

原文:

And your js code? How are you calling the 'crash' function?

GeoffreyPlitt 2017-10-9
11

我不是手动调用崩溃函数, 这一崩溃发生在启动。

原文:

I'm not manually calling a crash function, this crash happens on boot.

GeoffreyPlitt 2017-10-9
12

关于如何进一步解决此问题的任何想法?

原文:

Any ideas on how to troubleshoot this further?

corymsmith 2017-10-9
13

@GeoffreyPlitt在看到此异常之前, Logcat 中是否有其他任何一个?

原文:

@GeoffreyPlitt before you see this exception is there any other one in Logcat?

GeoffreyPlitt 2017-10-9
14

更新: 我已经证明了这个模块是问题。

我创造了一个新的反应-本地0.33 应用程序与 ' 反应-本机 init, 在这里:
https://github.com/GeoffreyPlitt/react_native_minimal

然后在一个新的分支 "crashlytics", 我安装 crashlytics 为 Android, 它建立罚款, 以及运行良好 (没有崩溃的启动)
https://github.com/GeoffreyPlitt/react_native_minimal/tree/crashlytics

然后, 在一个新的分支基于一个所谓的 "react_native_fabric", 我添加了您的模块:
https://github.com/GeoffreyPlitt/react_native_minimal/tree/react_native_fabric

运行这最后一个在启动时立即崩溃。红色 RN 错误消息说 "未定义的不是一个对象 (评估 SMXCrashlytics. 崩溃)"

所以, 我们已经有了一个完整的源代码库来证明这一崩溃, 以及在那里我们可以得到这个工作。请克隆或叉我的回购, 测试自己, 让我知道, 谢谢。

原文:

Update: I've proven this module is the problem.

I created a fresh React-Native 0.33 app with 'react-native init", here:
https://github.com/GeoffreyPlitt/react_native_minimal

Then in a new branch "crashlytics", I installed Crashlytics for Android, and it builds fine, as well as runs fine (no crash on startup)
https://github.com/GeoffreyPlitt/react_native_minimal/tree/crashlytics

Then in a new branch based off that one called "react_native_fabric", I added your module:
https://github.com/GeoffreyPlitt/react_native_minimal/tree/react_native_fabric

Running this last one crashes immediately on startup. The red RN error message says "undefined is not an object (evaluating SMXCrashlytics.crash)"

So, we've got a complete source codebase proving the crash, and where we can get this working. Please clone or fork my repo, test yourselves, and let me know, thanks.

GeoffreyPlitt 2017-10-9
15

这里是我的日志-没有错误或例外之前, 这一个, 我可以告诉。
http://pastebin.com/Cnq8DTEA

原文:

And here are my logs-- no errors or exceptions before this one, from what I can tell.
http://pastebin.com/Cnq8DTEA

corymsmith 2017-10-9
16

此模块在您的 MainApplication 中根本没有注册, 这就是该函数显示为未定义的原因。

https://github.com/GeoffreyPlitt/react_native_minimal/blob/react_native_fabric/android/app/src/main/java/com/react_native_minimal/MainApplication.java

getPackages () 也应该有new FabricPackage()

原文:

This module isn't being registered at all in your MainApplication which is why that function is showing as undefined.

https://github.com/GeoffreyPlitt/react_native_minimal/blob/react_native_fabric/android/app/src/main/java/com/react_native_minimal/MainApplication.java

getPackages() should also have new FabricPackage()

GeoffreyPlitt 2017-10-9
17

大!这显然不是由 "rnpm 安装" 或 "反应-本地链接", 这是令人沮丧的。

现在, 我能够完成在导入过程中通过崩溃这一问题。

但当我这样做:

var=require('react-native-fabric')
var= Fabric;
Crashlytics.crash();

我得到一个红色 RN 错误的 indexOutOfBounds ("length=2;index=10 ") 在 CrashTest. java:30。我在我的 Crashlytics 仪表板上没有任何崩溃。因此, 这似乎不像崩溃的聚会是相当工作。看起来像是核心 Crashlytics SDK (Java) 的问题。这是你们熟悉的错误, 还是我应该对它们进行故障排除?

原文:

Great! That apparently wasn't done by either "rnpm install" or "react-native link" which is frustrating.

Now I'm able to complete get past this issue of crashing during imports.

But when I do:

var Fabric = require('react-native-fabric')
var { Crashlytics } = Fabric;
Crashlytics.crash();

I get a red RN error of indexOutOfBounds ("length=2; index=10") at CrashTest.java:30. And I do NOT get any crashes in my Crashlytics dashboard. So it doesn't seem like the crash gathering is quite working. Seems like an issue with the core Crashlytics SDK (Java). Is that an error familiar to you guys, or should I troubleshoot with them?

GeoffreyPlitt 2017-10-9
18

最后, 我意识到这最后一部分是怎么回事。我希望这是更有记载的。

您必须在发布模式下运行 (https://facebook.github.io/react-native/docs/signed-apk-android.html, 也需要密钥库) 才能将崩溃报告发送到 crashlytics。

原文:

And finally I realize what's going on with this last part. I wish this was more well-documented.

You have to run in release mode (https://facebook.github.io/react-native/docs/signed-apk-android.html, needs a keystore too) to actually send the crash reports to crashlytics.

GeoffreyPlitt 2017-10-9
19

所以: 我相信我已经克服了这个问题, 代码位于https://github.com/GeoffreyPlitt/react_native_minimal/tree/react_native_fabric, 我正在处理另一个问题 (https://twittercommunity.com/t/android-crash-report-was-sent-but-does-not-show-in-my-dashboard/74641) 这可能是相关的, 但我现在将关闭这个。

谢谢你的帮助!

原文:

So: I believe I've gotten past this problem, code is at https://github.com/GeoffreyPlitt/react_native_minimal/tree/react_native_fabric, and I'm working on another issue (https://twittercommunity.com/t/android-crash-report-was-sent-but-does-not-show-in-my-dashboard/74641) that may be related but I'll close this for now.

Thanks for all your help!

返回
发表文章
GeoffreyPlitt
文章数
2
评论数
24
注册排名
13911