com.facebook.react.common.JavascriptException:错误:元素类型无效

时间:2021-01-05 01:31:59

标签: java react-native crash logcat

TL;DR

Non-Expo React Native 应用程序 0.63 在设备“调试”变体上构建并完美运行,但是当更改为“发布”变体时,它崩溃了,在 Metro 中绝对没有抛出错误,而只显示一个可疑的异常堆栈:

用力捂脸的步骤

  • react-native run android --variant="debug" -> 作品
  • ./gradlew clean
  • react-native run android --variant="release" -> 停止工作
  • ./gradlew clean
  • react-native run android --variant="debug" -> 再次工作

日志猫

adb logcat AndroidRuntime:V *:S

--------- beginning of main
01-04 22:04:26.538 18552 18552 D AndroidRuntime: Calling main entry com.android.commands.pm.Pm
01-04 22:04:57.786 18552 18552 I AndroidRuntime: VM exiting with result code 0.
01-04 22:04:59.513 18630 18630 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 2000 <<<<<<
01-04 22:04:59.525 18630 18630 D AndroidRuntime: CheckJNI is OFF
01-04 22:04:59.771 18630 18630 D AndroidRuntime: Calling main entry com.android.commands.am.Am
01-04 22:04:59.858 18630 18630 D AndroidRuntime: Shutting down VM
01-04 22:05:04.076 18675 18695 E AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
01-04 22:05:04.076 18675 18695 E AndroidRuntime: Process: com.trique.app, PID: 18675
01-04 22:05:04.076 18675 18695 E AndroidRuntime: com.facebook.react.common.JavascriptException: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: number.
01-04 22:05:04.076 18675 18695 E AndroidRuntime: 
01-04 22:05:04.076 18675 18695 E AndroidRuntime: This error is located at:
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in RCTView
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in View
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in k
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in ForwardRef
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in O
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in ForwardRef
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in b
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in RCTView
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in View
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in w
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in RCTView
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in View
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in RCTScrollView
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in y
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in ScrollView
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in RCTView
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in View
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in x
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in RCTView
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in View
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in RCTView
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in View
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in RCTView
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in View
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in ForwardRef
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in RCTView
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in View
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in k
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in ForwardRef
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in PanGestureHandler
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in RCTView
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in View
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in k
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in ForwardRef
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in RCTView
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in View
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in G
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in RCTView
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in View
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in RCTView
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in View
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in w
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in h
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in GestureHandlerRootView
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in G
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in p
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in ForwardRef
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in ForwardRef
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in c
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in RCTView
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in View
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Portal.Host
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in E
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in c
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in RCTView
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in View
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in RNCSafeAreaView
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in Unknown
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in RCTView
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in View
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in RCTView
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in View
01-04 22:05:04.076 18675 18695 E AndroidRuntime:     in C, stack:
01-04 22:05:04.076 18675 18695 E AndroidRuntime: Xl@93:86688
01-04 22:05:04.076 18675 18695 E AndroidRuntime: <unknown>@93:36589
01-04 22:05:04.076 18675 18695 E AndroidRuntime: jr@93:46349
01-04 22:05:04.076 18675 18695 E AndroidRuntime: Ci@93:81373
01-04 22:05:04.076 18675 18695 E AndroidRuntime: Cl@93:75314
01-04 22:05:04.076 18675 18695 E AndroidRuntime: Rl@93:75239
01-04 22:05:04.076 18675 18695 E AndroidRuntime: Pl@93:75006
01-04 22:05:04.076 18675 18695 E AndroidRuntime: Tl@93:72139
01-04 22:05:04.076 18675 18695 E AndroidRuntime: Tl@-1
01-04 22:05:04.076 18675 18695 E AndroidRuntime: <unknown>@93:24153
01-04 22:05:04.076 18675 18695 E AndroidRuntime: unstable_runWithPriority@202:3882
01-04 22:05:04.076 18675 18695 E AndroidRuntime: an@93:24100
01-04 22:05:04.076 18675 18695 E AndroidRuntime: ln@93:24035
01-04 22:05:04.076 18675 18695 E AndroidRuntime: xe@93:89844
01-04 22:05:04.076 18675 18695 E AndroidRuntime: Ee@93:12419
01-04 22:05:04.076 18675 18695 E AndroidRuntime: Re@93:12808
01-04 22:05:04.076 18675 18695 E AndroidRuntime: receiveEvent@93:13217
01-04 22:05:04.076 18675 18695 E AndroidRuntime: value@27:3350
01-04 22:05:04.076 18675 18695 E AndroidRuntime: <unknown>@27:747
01-04 22:05:04.076 18675 18695 E AndroidRuntime: value@27:2610
01-04 22:05:04.076 18675 18695 E AndroidRuntime: value@27:719
01-04 22:05:04.076 18675 18695 E AndroidRuntime: value@-1
01-04 22:05:04.076 18675 18695 E AndroidRuntime: 
01-04 22:05:04.076 18675 18695 E AndroidRuntime:    at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:83)
01-04 22:05:04.076 18675 18695 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
01-04 22:05:04.076 18675 18695 E AndroidRuntime:    at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
01-04 22:05:04.076 18675 18695 E AndroidRuntime:    at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151)
01-04 22:05:04.076 18675 18695 E AndroidRuntime:    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
01-04 22:05:04.076 18675 18695 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:746)
01-04 22:05:04.076 18675 18695 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:95)
01-04 22:05:04.076 18675 18695 E AndroidRuntime:    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
01-04 22:05:04.076 18675 18695 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:148)
01-04 22:05:04.076 18675 18695 E AndroidRuntime:    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
01-04 22:05:04.076 18675 18695 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:818)

注册护士信息

⟩ react-native info
info Fetching system and libraries information...
System:
    OS: Linux 4.19 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (4) x64 Intel(R) Core(TM) i3-3240 CPU @ 3.40GHz
    Memory: 846.02 MB / 11.68 GB
    Shell: 3.0.2 - /usr/bin/fish
  Binaries:
    Node: 12.13.0 - ~/.nvm/versions/node/v12.13.0/bin/node
    Yarn: 1.22.5 - ~/.yarn/bin/yarn
    npm: 6.12.0 - ~/.nvm/versions/node/v12.13.0/bin/npm
    Watchman: 4.9.0 - /home/linuxbrew/.linuxbrew/bin/watchman
  SDKs:
    Android SDK:
      API Levels: 26, 28, 29
      Build Tools: 26.0.3, 28.0.3, 29.0.2, 30.0.0
      System Images: android-26 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: Not Found
  Languages:
    Java: 1.8.0_232 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: Not Found
    react-native: 0.63.2 => 0.63.2 
  npmGlobalPackages:
    *react-native*: Not Found

gradle.properties

android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

# (Pra3t05) Increased JVM Heap size @see https://stackoverflow.com/questions/47208618/execution-of-compression-failed-error-when-building-project-in-android-studio
# org.gradle.jvmargs=-Xmx4608M

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.37.0
MYAPP_UPLOAD_STORE_FILE=my-upload-key.keystore
MYAPP_UPLOAD_KEY_ALIAS=app-key
MYAPP_UPLOAD_STORE_PASSWORD=password
MYAPP_UPLOAD_KEY_PASSWORD=password

build.gradle

apply plugin: 'com.android.application'

import com.android.build.OutputFile

project.ext.react = [
        entryFile: 'packages/mobile/index.js',
        root: '../../../../',
        enableHermes: false,
]
apply from: '../../../../node_modules/react-native/react.gradle'
// project.ext.vectoricons = [
//     iconFontNames: [ 'Ionicons.ttf' ]
// ]
// apply from: "../../../../node_modules/@ovaeasy/react-native-vector-icons/fonts.gradle"
project.ext.vectoricons = [
    iconFontsDir: '../../../..',
    iconFontNames: [
        'node_modules/react-native-vector-icons/Fonts/Ionicons.ttf',
        'node_modules/react-native-vector-icons/Fonts/MaterialCommunityIcons.tts',
        'node_modules/react-native-vector-icons/Fonts/FontAwesome.tts',
        'node_modules/react-native-vector-icons/Fonts/MaterialIcons.ttf',
        'node_modules/react-native-vector-icons/Fonts/Octicons.ttf',
    // 'packages/components/src/libs/vector-icons/fonts/octicons2/generated/Octicons2.ttf'
    ],
]
apply from: '../../../../node_modules/react-native-vector-icons/fonts.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

/**
 * The preferred build flavor of JavaScriptCore.
 *
 * For example, to use the international variant, you can use:
 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
 *
 * The international variant includes ICU i18n library and necessary data
 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
 * give correct results when using with locales other than en-US.  Note that
 * this variant is about 6MiB larger per architecture than default.
 */
def jscFlavor = 'org.webkit:android-jsc:+'

/**
 * Whether to enable the Hermes VM.
 *
 * This should be set on project.ext.react and mirrored here.  If it is not set
 * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
 * and the benefits of using Hermes will therefore be sharply reduced.
 */
def enableHermes = project.ext.react.get('enableHermes', false)

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId 'com.trique.app'
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName '1.0'
        multiDexEnabled true
    }

    // dexOptions {
    //     javaMaxHeapSize '4g'
    // }

    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include 'armeabi-v7a', 'x86', 'arm64-v8a', 'x86_64'
        }
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
        release {
            if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
                storeFile file(MYAPP_UPLOAD_STORE_FILE)
                storePassword MYAPP_UPLOAD_STORE_PASSWORD
                keyAlias MYAPP_UPLOAD_KEY_ALIAS
                keyPassword MYAPP_UPLOAD_KEY_PASSWORD
            }
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            signingConfig signingConfigs.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:
            // https://developer.android.com/studio/build/configure-apk-splits.html
            def versionCodes = ['armeabi-v7a': 1, 'x86': 2, 'arm64-v8a': 3, 'x86_64': 4]
            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 {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleDynamicVersion
    implementation 'com.facebook.react:react-native:+'  // From node_modules

    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
    implementation 'androidx.multidex:multidex:2.0.1'

    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.fbjni'
    }

    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }

    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
    }
    implementation(project(':react-native-google-signin'))
    if (enableHermes) {
        def hermesPath = '../../../node_modules/hermes-engine/android/'
        debugImplementation files(hermesPath + 'hermes-debug.aar')
        releaseImplementation files(hermesPath + 'hermes-release.aar')
    } else {
        implementation jscFlavor
    }
}
// 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'
}

apply from: file('../../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle'); applyNativeModulesAppBuildGradle(project)
apply plugin: 'com.google.gms.google-services'

1 个答案:

答案 0 :(得分:0)

简而言之

禁用由缩小的 javascript 引起的混淆,像这样更新 android build.gradle

project.ext.react = [
        entryFile: 'packages/mobile/index.js',
        root: '../../../../',
        enableHermes: false,
        extraPackagerArgs: [ '--minify=false' ], //Add this!
]

然后使用 ./gradlew clean 清理 android 项目,并在将应用部署到设备后运行:

adb logcat AndroidRuntime:V *:S

并打开应用程序,错误将被正确登录。

备案

该问题与 this issue 相关,正如之前混淆的错误所揭示的:

01-04 22:56:19.527 22500 22522 E AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
01-04 22:56:19.527 22500 22522 E AndroidRuntime: Process: com.trique.app, PID: 22500
01-04 22:56:19.527 22500 22522 E AndroidRuntime: com.facebook.react.common.JavascriptException: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: number.
01-04 22:56:19.527 22500 22522 E AndroidRuntime: 
01-04 22:56:19.527 22500 22522 E AndroidRuntime: This error is located at:
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in Icons
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in RCTView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in View
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in AnimatedComponent
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in ForwardRef(AnimatedComponentWrapper)
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in TouchableOpacity
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in ForwardRef
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in GoogleSigninButton
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in RCTView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in View
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in KeyboardAvoidingView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in RCTView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in View
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in RCTScrollView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in ScrollView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in ScrollView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in RCTView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in View
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in LoginScreen
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in StaticContainer
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in StaticContainer
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in EnsureSingleNavigator
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in SceneView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in RCTView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in View
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in RCTView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in View
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in RCTView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in View
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in ForwardRef(CardSheet)
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in RCTView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in View
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in AnimatedComponent
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in ForwardRef(AnimatedComponentWrapper)
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in PanGestureHandler
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in PanGestureHandler
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in RCTView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in View
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in AnimatedComponent
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in ForwardRef(AnimatedComponentWrapper)
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in RCTView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in View
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in Card
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in CardContainer
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in RCTView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in View
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in MaybeScreen
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in RCTView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in View
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in MaybeScreenContainer
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in CardStack
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in KeyboardManager
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in SafeAreaProviderCompat
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in GestureHandlerRootView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in GestureHandlerRootView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in StackView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in StackNavigator
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in AuthStack
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in EnsureSingleNavigator
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in ForwardRef(BaseNavigationContainer)
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in ThemeProvider
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in ForwardRef(NavigationContainer)
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in RootNavigator
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in ThemeProvider
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in RCTView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in View
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in Portal.Host
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in Provider
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in Main
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in Provider
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in Provider
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in RCTView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in View
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in FallbackAppearanceProvider
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in AppearanceProvider
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in RNCSafeAreaView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in SafeAreaProvider
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in App
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in RCTView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in View
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in RCTView
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in View
01-04 22:56:19.527 22500 22522 E AndroidRuntime:     in AppContainer, stack:
01-04 22:56:19.527 22500 22522 E AndroidRuntime: createFiberFromTypeAndProps@10553:19
01-04 22:56:19.527 22500 22522 E AndroidRuntime: <unknown>@7592:291
01-04 22:56:19.527 22500 22522 E AndroidRuntime: reconcileChildren@8231:62
01-04 22:56:19.527 22500 22522 E AndroidRuntime: beginWork$1@10260:56
01-04 22:56:19.527 22500 22522 E AndroidRuntime: performUnitOfWork@9855:26
01-04 22:56:19.527 22500 22522 E AndroidRuntime: workLoopSync@9844:40
01-04 22:56:19.527 22500 22522 E AndroidRuntime: renderRootSync@9827:20
01-04 22:56:19.527 22500 22522 E AndroidRuntime: performSyncWorkOnRoot@9605:35
01-04 22:56:19.527 22500 22522 E AndroidRuntime: performSyncWorkOnRoot@-1
01-04 22:56:19.527 22500 22522 E AndroidRuntime: <unknown>@6892:33
01-04 22:56:19.527 22500 22522 E AndroidRuntime: unstable_runWithPriority@20213:14
01-04 22:56:19.527 22500 22522 E AndroidRuntime: flushSyncCallbackQueueImpl@6887:23
01-04 22:56:19.527 22500 22522 E AndroidRuntime: flushSyncCallbackQueue@6877:30
01-04 22:56:19.527 22500 22522 E AndroidRuntime: batchedUpdatesImpl@10724:103
01-04 22:56:19.527 22500 22522 E AndroidRuntime: batchedUpdates@6194:31
01-04 22:56:19.527 22500 22522 E AndroidRuntime: _receiveRootNodeIDEvent@6222:18
01-04 22:56:19.527 22500 22522 E AndroidRuntime: receiveEvent@6245:29
01-04 22:56:19.527 22500 22522 E AndroidRuntime: __callFunction@2014:35
01-04 22:56:19.527 22500 22522 E AndroidRuntime: <unknown>@1835:30
01-04 22:56:19.527 22500 22522 E AndroidRuntime: __guard@1968:14
01-04 22:56:19.527 22500 22522 E AndroidRuntime: callFunctionReturnFlushedQueue@1834:20
01-04 22:56:19.527 22500 22522 E AndroidRuntime: callFunctionReturnFlushedQueue@-1
01-04 22:56:19.527 22500 22522 E AndroidRuntime: 
01-04 22:56:19.527 22500 22522 E AndroidRuntime:    at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:83)
01-04 22:56:19.527 22500 22522 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
01-04 22:56:19.527 22500 22522 E AndroidRuntime:    at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
01-04 22:56:19.527 22500 22522 E AndroidRuntime:    at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151)
01-04 22:56:19.527 22500 22522 E AndroidRuntime:    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
01-04 22:56:19.527 22500 22522 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:746)
01-04 22:56:19.527 22500 22522 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:95)
01-04 22:56:19.527 22500 22522 E AndroidRuntime:    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
01-04 22:56:19.527 22500 22522 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:148)
01-04 22:56:19.527 22500 22522 E AndroidRuntime:    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
01-04 22:56:19.527 22500 22522 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:818)

使用 @svgr/cli 从运行时转换的 svg 资产迁移到纯 jsx 组件修复了该问题。 I'm leaving a link to their very awesome playground, i case you wanna try the cli