发布版本因java.lang.RuntimeException而失败:无法启动活动ComponentInfo-React Native-Android

时间:2019-06-30 18:58:49

标签: android react-native android-gradle

我的android应用程序抛出以下错误。调试版本运行良好,而发行版本运行失败并出现以下错误。

这是使用react native构建的。

此错误是通过logcat记录的。

06-30 22:40:57.562 17107 17107 E AndroidRuntime: Process: com.myapp.enterprise, PID: 17107
06-30 22:40:57.562 17107 17107 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.enterprise/com.myapp.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f09001e type #0x1 is not valid
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2793)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2864)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at android.app.ActivityThread.-wrap12(ActivityThread.java)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1567)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:105)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:156)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:6517)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
06-30 22:40:57.562 17107 17107 E AndroidRuntime: Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f09001e type #0x1 is not valid
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at android.content.res.Resources.loadXmlResourceParser(Resources.java:2192)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at android.content.res.Resources.getLayout(Resources.java:1178)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at android.view.LayoutInflater.inflate(LayoutInflater.java:424)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:454)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at com.android.internal.policy.HwPhoneWindow.setContentView(HwPhoneWindow.java:284)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at android.app.Dialog.setContentView(Dialog.java:647)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at org.devio.rn.splashscreen.SplashScreen$1.run(SplashScreen.java:32)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at android.app.Activity.runOnUiThread(Activity.java:6096)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at org.devio.rn.splashscreen.SplashScreen.show(SplashScreen.java:27)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at org.devio.rn.splashscreen.SplashScreen.show(SplashScreen.java:49)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at org.devio.rn.splashscreen.SplashScreen.show(SplashScreen.java:56)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at com.myapp.MainActivity.onCreate(MainActivity.java:18)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at android.app.Activity.performCreate(Activity.java:6915)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2746)
06-30 22:40:57.562 17107 17107 E AndroidRuntime:    ... 9 more
06-30 22:40:58.623 17127 17127 E AndroidRuntime: FATAL EXCEPTION: main

以下是我的MainActivity.java代码。

package com.myapp;

import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.os.Environment;
import android.webkit.WebView;
import android.widget.ImageView;
import org.devio.rn.splashscreen.SplashScreen;

import com.facebook.react.ReactActivity;

public class MainActivity extends ReactActivity {

    private WebView webView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        SplashScreen.show(this);
        super.onCreate(savedInstanceState);
    }

    @Override
    protected String getMainComponentName() {
        return "myapp";
    }
}

我不知道错误在哪里。而且错误对于我来说还不够清楚。请帮助我继续解决此错误。这很烦人。

我可以发布任何对问题有帮助的其他内容。

1 个答案:

答案 0 :(得分:0)

自从我发现发生了什么之后,我在这里回答自己的问题。

从android方面来看这不是问题。我正在仔细检查android代码和gradle版本以使其正确。

最后我发现这是库react-native-splash-screen抛出的错误。在他们的show()函数中,他们有一个错误,当将false传递给该函数时,该错误将无法启动。

请参阅此github问题。 https://github.com/crazycodeboy/react-native-splash-screen/issues/167