react-native - 播放控制台中的 React Native Release 应用程序错误
问题描述
我将我的应用程序发送到了 Play 商店,在下载了一些下载之后,在 Play 控制台中出现了一些错误集群。在我的手机中,这种故障从未发生过。
播放控制台错误:
java.lang.RuntimeException:
at android.app.ActivityThread.handleReceiver (ActivityThread.java:3334)
at android.app.ActivityThread.-wrap17 (Unknown Source)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1725)
at android.os.Handler.dispatchMessage (Handler.java:105)
at android.os.Looper.loop (Looper.java:164)
at android.app.ActivityThread.main (ActivityThread.java:6694)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:240)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:769)
Caused by: java.lang.ClassNotFoundException:
at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass (ClassLoader.java:379)
at java.lang.ClassLoader.loadClass (ClassLoader.java:312)
at android.app.ActivityThread.handleReceiver (ActivityThread.java:3329)
我的设置 Gradle:
rootProject.name = project_name
include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
include ':react-native-snackbar'
project(':react-native-snackbar').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-snackbar/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-text-input-mask'
project(':react-native-text-input-mask').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-text-input- mask/android')
include ':app'
My build.gradle
buildscript {
repositories {
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
mavenLocal()
maven {
url "$rootDir/../node_modules/react-native/android"
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
jcenter()
}
}
ext {
buildToolsVersion = "26.0.3"
minSdkVersion = 16
compileSdkVersion = 26
targetSdkVersion = 26
supportLibVersion = "26.1.0"
}
我的应用程序/build.gradle
...
dependencies {
implementation project(':react-native-firebase')
compile project(':react-native-snackbar')
implementation project(':react-native-vector-icons')
compile project(':react-native-text-input-mask')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
compile "com.facebook.react:react-native:+" // From node_modules
implementation "com.google.android.gms:play-services-base:15.0.1"
implementation "com.google.firebase:firebase-core:16.0.1"
implementation "com.google.firebase:firebase-messaging:17.1.0"
implementation 'me.leolin:ShortcutBadger:1.1.21@aar'
}
我不知道发生了什么以及如何解决它。谁能帮我解决这个问题?
解决方案
这看起来像一个 dex 问题。您需要启用 multidex 支持。
由于您的目标是 minSDKVersion 16,您需要将以下内容添加到您的依赖项中
implementation 'com.android.support:multidex:1.0.3'
您还需要defaultConfig
在您的android/app/build.gradle
defaultConfig {
// there will be other things here like applicationId, minSdkVersion, versionCode etc.
multiDexEnabled true
}
MainApplication.java
您还需要在from中更改以下行
public class MainApplication extends Application implements ReactApplication {
至
public class MainApplication extends MultiDexApplication implements ReactApplication {
您可以在此处阅读有关启用 multidex 的更多信息https://developer.android.com/studio/build/multidexApplication
,因为根据您是否覆盖类,有不同的方法可以启用它。
推荐阅读
- c++ - 吃完 EOF 后重用 std::cin
- python - os.makedirs 不在 Windows 上创建文件夹
- c# - .Net Core 2.1 是否支持 LINQ 和 Lambda 表达式?
- rabbitmq - 如何解决这个 RabbitMQ REST 调用 415 响应问题?
- c++ - clang++ 是否以更轻松的方式处理系统标头?
- comparison - 当测量值大于常数时激活关闭开关(LabVIEW)
- r - 在 igraph 最小生成树中指定根
- javascript - 如果我在代码顶部添加 location.href 脚本条件,php 代码会运行吗?
- javascript - 如何使用较暗的背景并保持 Angular Material Form Field 组件具有白色背景?
- hdfs - 纱线使用的内存量与实际机器使用的内存量不匹配