物理Android设备上的React-Native应用程序崩溃(按Dev设置时)

时间:2018-07-18 13:30:24

标签: android react-native device

因此,我有一个react-native应用程序,它可以在计算机上的仿真器中正常工作,但是当我想在真实设备中检查它时,会出现错误。

  

1。我运行react-native run-android(应用安装到真实设备上,仅给出有关adb反向的警告,因为cuz设备的android版本是   4.4.2)

     

2。当应用在真实设备中打开时,显示“无法从资产等中加载脚本。”

     

3.Then我尝试打开开发人员设置以按照建议通过wifi连接到捆绑软件,并且我的应用程序崩溃了。..我尝试了2种不同的设备   都崩溃了。

     
      
  1. 我使用android设备监视器对其进行了跟踪,但出现一些错误:

         

    07-18 17:03:24.596:E / AndroidRuntime(1160):   android.view.InflateException:二进制XML文件第19行:错误   膨胀类android.widget.CheckBox 07-18 17:03:24.596:   E / AndroidRuntime(1160):在   android.view.LayoutInflater.createView(LayoutInflater.java:626)07-18   17:03:24.596:E / AndroidRuntime(1160):在   com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)   07-18 17:03:24.596:E / AndroidRuntime(1160):at   android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)   07-18 17:03:24.596:E / AndroidRuntime(1160):at   android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)   07-18 17:03:24.596:E / AndroidRuntime(1160):at   android.view.LayoutInflater.inflate(LayoutInflater.java:470)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.view.LayoutInflater.inflate(LayoutInflater.java:398)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.view.LayoutInflater.inflate(LayoutInflater.java:354)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.preference.Preference.onCreateView(Preference.java:531)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.preference.Preference.getView(Preference.java:494)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.preference.PreferenceGroupAdapter.getView(PreferenceGroupAdapter.java:222)   07-18 17:03:24.596:E / AndroidRuntime(1160):at   android.widget.AbsListView.obtainView(AbsListView.java:2742)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.widget.ListView.makeAndAddView(ListView.java:1811)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.widget.ListView.fillDown(ListView.java:697)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.widget.ListView.fillFromTop(ListView.java:763)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.widget.ListView.layoutChildren(ListView.java:1641)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.widget.AbsListView.onLayout(AbsListView.java:2567)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.view.View.layout(View.java:15819)07-18 17:03:24.596:   E / AndroidRuntime(1160):在   android.view.ViewGroup.layout(ViewGroup.java:4884)07-18 17:03:24.596:   E / AndroidRuntime(1160):在   android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)   07-18 17:03:24.596:E / AndroidRuntime(1160):at   android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)   07-18 17:03:24.596:E / AndroidRuntime(1160):at   android.widget.LinearLayout.onLayout(LinearLayout.java:1440)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.view.View.layout(View.java:15819)07-18 17:03:24.596:   E / AndroidRuntime(1160):在   android.view.ViewGroup.layout(ViewGroup.java:4884)07-18 17:03:24.596:   E / AndroidRuntime(1160):在   android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)   07-18 17:03:24.596:E / AndroidRuntime(1160):at   android.widget.LinearLayout.layoutHorizo​​ntal(LinearLayout.java:1666)   07-18 17:03:24.596:E / AndroidRuntime(1160):at   android.widget.LinearLayout.onLayout(LinearLayout.java:1442)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.view.View.layout(View.java:15819)07-18 17:03:24.596:   E / AndroidRuntime(1160):在   android.view.ViewGroup.layout(ViewGroup.java:4884)07-18 17:03:24.596:   E / AndroidRuntime(1160):在   android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)   07-18 17:03:24.596:E / AndroidRuntime(1160):at   android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)   07-18 17:03:24.596:E / AndroidRuntime(1160):at   android.widget.LinearLayout.onLayout(LinearLayout.java:1440)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.view.View.layout(View.java:15819)07-18 17:03:24.596:   E / AndroidRuntime(1160):在   android.view.ViewGroup.layout(ViewGroup.java:4884)07-18 17:03:24.596:   E / AndroidRuntime(1160):在   android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.widget.FrameLayout.onLayout(FrameLayout.java:388)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.view.View.layout(View.java:15819)07-18 17:03:24.596:   E / AndroidRuntime(1160):在   android.view.ViewGroup.layout(ViewGroup.java:4884)07-18 17:03:24.596:   E / AndroidRuntime(1160):在   android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)   07-18 17:03:24.596:E / AndroidRuntime(1160):at   android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)   07-18 17:03:24.596:E / AndroidRuntime(1160):at   android.widget.LinearLayout.onLayout(LinearLayout.java:1440)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.view.View.layout(View.java:15819)07-18 17:03:24.596:   E / AndroidRuntime(1160):在   android.view.ViewGroup.layout(ViewGroup.java:4884)07-18 17:03:24.596:   E / AndroidRuntime(1160):在   android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.widget.FrameLayout.onLayout(FrameLayout.java:388)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.view.View.layout(View.java:15819)07-18 17:03:24.596:   E / AndroidRuntime(1160):在   android.view.ViewGroup.layout(ViewGroup.java:4884)07-18 17:03:24.596:   E / AndroidRuntime(1160):在   android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2391)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2099)   07-18 17:03:24.596:E / AndroidRuntime(1160):at   android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1270)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.view.ViewRootImpl $ TraversalRunnable.run(ViewRootImpl.java:6721)   07-18 17:03:24.596:E / AndroidRuntime(1160):at   android.view.Choreographer $ CallbackRecord.run(Choreographer.java:812)   07-18 17:03:24.596:E / AndroidRuntime(1160):at   android.view.Choreographer.doCallbacks(Choreographer.java:612)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.view.Choreographer.doFrame(Choreographer.java:582)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.view.Choreographer $ FrameDisplayEventReceiver.run(Choreographer.java:798)   07-18 17:03:24.596:E / AndroidRuntime(1160):at   android.os.Handler.handleCallback(Handler.java:733)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.os.Handler.dispatchMessage(Handler.java:95)07-18   17:03:24.596:E / AndroidRuntime(1160):在   android.os.Looper.loop(Looper.java:146)07-18 17:03:24.596:   E / AndroidRuntime(1160):在   android.app.ActivityThread.main(ActivityThread.java:5641)07-18   17:03:24.596:E / AndroidRuntime(1160):在   java.lang.reflect.Method.invokeNative(本机方法)07-18   17:03:24.596:E / AndroidRuntime(1160):在   java.lang.reflect.Method.invoke(Method.java:515)07-18 17:03:24.596:   E / AndroidRuntime(1160):在   com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1288)   07-18 17:03:24.596:E / AndroidRuntime(1160):at   com.android.internal.os.Zygote 07-18 17:03:24.656:A / libc(1215):致命的   信号13(SIGPIPE)位于0x000004bf(代码= 0),线程1215(正常运行时间)

  2.   

有什么办法可以解决这个问题吗??

app / android / app / build.gradle:

apply plugin: "com.android.application"

import com.android.build.OutputFile

project.ext.react = [
    entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.gotl"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    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"
        }
    }
    // 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 {
    compile project(':react-native-track-player')
    compile project(':react-native-sound-player')
    compile project(':react-native-sound')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
    compile 'com.facebook.fresco:animated-gif:1.3.0'
}

// 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'
}

1 个答案:

答案 0 :(得分:0)

我想分享一点,我注意到它在android 4.4.4版本中崩溃了,但是在5.0版本中没有崩溃..所以有人对此有所了解吗?..

相关问题