HostObject :: get中的异常:-React Native Build Android

前端之家收集整理的这篇文章主要介绍了HostObject :: get中的异常:-React Native Build Android 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

将我的React Native应用程序更新为React Native 0.59之后,尝试在调试模式下运行我的应用程序(react-native run-android)或生成软件包并将其安装到设备后,我开始遇到问题.

以下是有关我的问题的信息:

我的环境:

  1. React Native Environment Info:
  2. System:
  3. OS: macOS 10.14.3
  4. cpu: (4) x64 Intel(R) Core(TM) i5-7360U cpu @ 2.30GHz
  5. Memory: 479.23 MB / 8.00 GB
  6. Shell: 3.2.57 - /bin/bash
  7. Binaries:
  8. Node: 8.11.3 - /usr/local/bin/node
  9. Yarn: 1.9.4 - /usr/local/bin/yarn
  10. npm: 5.6.0 - /usr/local/bin/npm
  11. Watchman: 4.9.0 - /usr/local/bin/watchman
  12. SDKs:
  13. iOS SDK:
  14. Platforms: iOS 12.1,macOS 10.14,tvOS 12.1,watchOS 5.1
  15. Android SDK:
  16. API Levels: 26,27,28
  17. Build Tools: 26.0.2,28.0.2,28.0.3
  18. IDEs:
  19. Xcode: 10.1/10B61 - /usr/bin/xcodebuild
  20. npmPackages:
  21. react: 16.8.3 => 16.8.3
  22. react-native: 0.59.1 => 0.59.1
  23. npmGlobalPackages:
  24. create-react-native-app: 1.0.0
  25. react-native-cli: 2.0.1
  26. react-native-git-upgrade: 0.2.7

React Native错误屏幕中的错误

Error screen

在我的Bugsnag上捕获的错误

  1. Error · Module AppRegistry is not a registered callable module (calling runApplication)
  2. http://localhost:8081/index.delta?platform=android&dev=true&minify=false:3954:26invariant
  3. http://localhost:8081/index.delta?platform=android&dev=true&minify=false:4674:18__callFunction
  4. http://localhost:8081/index.delta?platform=android&dev=true&minify=false:4433:31
  5. http://localhost:8081/index.delta?platform=android&dev=true&minify=false:4630:15__guard
  6. http://localhost:8081/index.delta?platform=android&dev=true&minify=false:4432:21callFunctionReturnFlushedQueue
  7. [native code]callFunctionReturnFlushedQueue

我的build.gradle文件

  1. buildscript {
  2. ext {
  3. buildToolsVersion = "28.0.3"
  4. minSdkVersion = 16
  5. compileSdkVersion = 28
  6. targetSdkVersion = 28
  7. supportLibVersion = "28.0.0"
  8. }
  9. repositories {
  10. google()
  11. jcenter()
  12. maven {
  13. url 'https://maven.fabric.io/public'
  14. }
  15. }
  16. dependencies {
  17. classpath 'com.android.tools.build:gradle:3.3.2'
  18. classpath 'com.google.gms:google-services:4.2.0'
  19. classpath 'com.google.firebase:firebase-plugins:1.1.5'
  20. classpath 'io.fabric.tools:gradle:1.26.0'
  21. }
  22. }
  23. allprojects {
  24. repositories {
  25. mavenLocal()
  26. google()
  27. jcenter()
  28. maven {
  29. url "$rootDir/../node_modules/react-native/android"
  30. }
  31. }
  32. }
  33. task wrapper(type: Wrapper) {
  34. gradleVersion = '4.10.2'
  35. distributionUrl = distributionUrl.replace("bin","all")
  36. }

我的app / build.gradle文件

  1. apply plugin: "com.android.application"
  2. apply plugin: "com.google.firebase.firebase-perf"
  3. apply plugin: "io.fabric"
  4. import com.android.build.OutputFile
  5. project.ext.react = [
  6. entryFile: "index.js"
  7. ]
  8. apply from: "../../node_modules/react-native/react.gradle"
  9. def enableSeparateBuildPercpuArchitecture = false
  10. /**
  11. * Run Proguard to shrink the Java bytecode in release builds.
  12. */
  13. def enableProguardInReleaseBuilds = false
  14. android {
  15. compileSdkVersion rootProject.ext.compileSdkVersion
  16. defaultConfig {
  17. applicationId "com.projectname"
  18. minSdkVersion rootProject.ext.minSdkVersion
  19. targetSdkVersion rootProject.ext.targetSdkVersion
  20. versionCode 1
  21. versionName "1.0"
  22. ndk {
  23. abiFilters "armeabi-v7a","x86"
  24. }
  25. }
  26. signingConfigs {
  27. release {
  28. if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
  29. storeFile file(MYAPP_RELEASE_STORE_FILE)
  30. storePassword MYAPP_RELEASE_STORE_PASSWORD
  31. keyAlias MYAPP_RELEASE_KEY_ALIAS
  32. keyPassword MYAPP_RELEASE_KEY_PASSWORD
  33. }
  34. }
  35. }
  36. splits {
  37. abi {
  38. reset()
  39. enable enableSeparateBuildPercpuArchitecture
  40. universalApk false // If true,also generate a universal APK
  41. include "armeabi-v7a","x86","arm64-v8a","x86_64"
  42. }
  43. }
  44. buildTypes {
  45. release {
  46. minifyEnabled enableProguardInReleaseBuilds
  47. proguardFiles getDefaultProguardFile("proguard-android.txt"),"proguard-rules.pro"
  48. signingConfig signingConfigs.release
  49. }
  50. }
  51. // applicationVariants are e.g. debug,release
  52. applicationVariants.all { variant ->
  53. variant.outputs.each { output ->
  54. // For each separate APK per architecture,set a unique version code as described here:
  55. // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
  56. def versionCodes = ["armeabi-v7a":1,"x86":2,"arm64-v8a": 3,"x86_64": 4]
  57. def abi = output.getFilter(OutputFile.ABI)
  58. if (abi != null) { // null for the universal-debug,universal-release variants
  59. output.versionCodeOverride =
  60. versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
  61. }
  62. }
  63. }
  64. }
  65. dependencies {
  66. implementation project(':react-native-splash-screen')
  67. implementation project(':@react-native-community_netinfo')
  68. implementation project(':@react-native-community_async-storage')
  69. implementation project(':react-native-linear-gradient')
  70. implementation project(':react-native-svg')
  71. implementation project(':bugsnag-react-native')
  72. implementation 'com.android.support:multidex:1.0.3'
  73. implementation project(':react-native-firebase')
  74. implementation "com.google.android.gms:play-services-base:16.0.1"
  75. implementation "com.google.firebase:firebase-core:16.0.6"
  76. implementation "com.google.firebase:firebase-messaging:17.3.4"
  77. implementation "com.google.firebase:firebase-perf:16.2.3"
  78. implementation('com.crashlytics.sdk.android:crashlytics:2.9.5@aar') {
  79. transitive = true
  80. }
  81. implementation project(':react-native-config')
  82. implementation project(':react-native-device-info')
  83. implementation project(':react-native-i18n')
  84. implementation project(':react-native-vector-icons')
  85. implementation project(':react-native-gesture-handler')
  86. implementation fileTree(dir: "libs",include: ["*.jar"])
  87. implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
  88. implementation "com.facebook.react:react-native:+" // From node_modules
  89. }
  90. // Run this once to be able to run the application with BUCK
  91. // puts all compile dependencies into folder libs for BUCK to use
  92. task copyDownloadableDepsToLibs(type: Copy) {
  93. from configurations.compile
  94. into 'libs'
  95. }
  96. apply plugin: 'com.google.gms.google-services'
  97. com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
  98. configurations.all {
  99. resolutionStrategy.eachDependency { DependencyResolveDetails details ->
  100. if (details.requested.group == 'com.google.android.gms'
  101. && ( (details.requested.name == 'play-services-base') || (details.requested.name == 'play-services-maps') ) ) {
  102. details.useVersion '16.0.1'
  103. }
  104. }
  105. }

在我的Metro-bundler加载100%后发生此错误(并且在Bundle Console屏幕上没有发生错误).

谢谢大家的帮助!

最佳答案
错误是因为您忘记在android中安装某些模块,请检查MainApplication.java,检查是否导入了所有软件包,以及是否将其添加到ReactPackage列表中.

猜你在找的Android相关文章