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

7d7tgy0s  于 2021-06-27  发布在  Java
关注(0)|答案(0)|浏览(418)

热释光;博士

非expo react本机应用程序0.63在设备“debug”变体上完美构建和运行,但当更改为“release”变体时,它会崩溃,在metro上绝对不会抛出错误,而是只显示一个可疑的异常堆栈:

硬掌踏步 react-native run android --variant="debug" ->作品

./gradlew clean react-native run android --variant="release" ->停止工作
./gradlew clean react-native run android --variant="debug" ->又起作用了

logcat公司

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

构建.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'

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题