我在应用程序中配置了react-native-firebase和crashlytics。 iOS版本已成功运行。
但是当我第二次运行react-native run-android
时,该应用程序已安装在手机中,但由于以下原因而崩溃了:adb logcat
该应用程序
I / ActivityManager(611):START u0 {act = android.intent.action.MAIN cat = [android.intent.category.LAUNCHER] flg = 0x10200000 cmp = com.company.mobile / .MainActivity(有其他功能) }在显示0的uid 10039中 W / AudioTrack(611):客户端拒绝AUDIO_OUTPUT_FLAG_FAST E / libprocessgroup(4404):无法制作和加/ acct / uid_10059:只读文件系统 W / Zygote(4404):createProcessGroup失败,内核缺少CONFIG_CGROUP_CPUACCT吗? I / art(4404):后启用-Xcheck:jni I / ActivityManager(611):启动proc com.company.mobile进行活动com.company.mobile/.MainActivity:pid = 4404 uid = 10059 gids = {50059,9997,3003} abi = x86 D / AndroidRuntime(4404):关闭VM E / AndroidRuntime(4404):致命异常:主 E / AndroidRuntime(4404):进程:com.company.mobile,PID:4404 E / AndroidRuntime(4404):java.lang.RuntimeException:无法实例化应用com.company.mobile.MainApplication:java.lang.ClassNotFoundException:在路径:DexPathList上找不到类“ com.company.mobile.MainApplication”。 [zip文件“ /data/app/com.company.mobile-2/base.apk"],nativeLibraryDirectories=[/data/app/com.company.mobile-2/lib/x86、/vendor/lib、/system / lib]] E / AndroidRuntime(4404):位于android.app.LoadedApk.makeApplication(LoadedApk.java:563) E / AndroidRuntime(4404):位于android.app.ActivityThread.handleBindApplication(ActivityThread.java:4491) E / AndroidRuntime(4404):位于android.app.ActivityThread.access $ 1500(ActivityThread.java:144) E / AndroidRuntime(4404):位于android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1339) E / AndroidRuntime(4404):位于android.os.Handler.dispatchMessage(Handler.java:102) E / AndroidRuntime(4404):位于android.os.Looper.loop(Looper.java:135) E / AndroidRuntime(4404):位于android.app.ActivityThread.main(ActivityThread.java:5221) E / AndroidRuntime(4404):at java.lang.reflect.Method.invoke(本机方法) E / AndroidRuntime(4404):位于java.lang.reflect.Method.invoke(Method.java:372) E / AndroidRuntime(4404):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:899) E / AndroidRuntime(4404):位于com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) E / AndroidRuntime(4404):由以下原因引起:java.lang.ClassNotFoundException:在路径:DexPathList [[zip文件“ /data/app/com.company.mobile-”中找不到类“ com.company.mobile.MainApplication” 2 / base.apk“],nativeLibraryDirectories = [/ data / app / com.company.mobile-2 / lib / x86,/ vendor / lib,/ system / lib]] E / AndroidRuntime(4404):位于dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) E / AndroidRuntime(4404):位于java.lang.ClassLoader.loadClass(ClassLoader.java:511) E / AndroidRuntime(4404):位于java.lang.ClassLoader.loadClass(ClassLoader.java:469) E / AndroidRuntime(4404):位于android.app.Instrumentation.newApplication(Instrumentation.java:979) E / AndroidRuntime(4404):位于android.app.LoadedApk.makeApplication(LoadedApk.java:558) E / AndroidRuntime(4404):...还有10个 E / AndroidRuntime(4404):禁止:java.lang.ClassNotFoundException:com.company.mobile.MainApplication E / AndroidRuntime(4404):位于java.lang.Class.classForName(本机方法) E / AndroidRuntime(4404):位于java.lang.BootClassLoader.findClass(ClassLoader.java:781) E / AndroidRuntime(4404):位于java.lang.BootClassLoader.loadClass(ClassLoader.java:841) E / AndroidRuntime(4404):位于java.lang.ClassLoader.loadClass(ClassLoader.java:504) E / AndroidRuntime(4404):...还有13个 E / AndroidRuntime(4404):原因:java.lang.NoClassDefFoundError:使用引导类加载器找不到类;没有可用的堆栈 W / ActivityManager(611):强制完成活动com.company.mobile/.MainActivity I / WindowManager(611):屏幕快照最大重试令牌4 {1fd4adee ActivityRecord {3c07bf69 u0 com.company.mobile/.MainActivity t20 f}} appWin = Window {553e925 u0启动com.company.mobile} drawState = 1 E / ActivityManager(611):无效的缩略图尺寸:768x768 W / art(611):使用ActivityManagerService.java中的owner方法= void com.android.server.am.ActivityManagerService.crashApplication(com.android.server.am.ProcessRecord,android.app.ApplicationErrorReport $ CrashInfo)进行长时间监控器争用事件:12038服务员= 0持续325ms I / OpenGLRenderer(611):初始化的EGL,版本1.4 W / art(611):使用所有者方法= int com.android.server.wm.WindowManagerService.relayoutWindow(com.android.server.wm.Session,android.view.IWindow,int,android.view)的长时间监视器争用事件。 WindowManager $ LayoutParams,int,int,int,int,int,android.graphics.Rect,android.graphics.Rect,android.graphics.Rect,android.graphics.Rect,android.graphics.Rect,android.content.res.Configuration, WindowManagerService.java:2977侍者= 0的android.view.Surface)持续574毫秒 I / Choreographer(1497):跳过51帧!该应用程序可能在其主线程上做太多工作。 W / EGL_emulation(611):eglSurfaceAttrib未实现 W / OpenGLRenderer(611):无法在表面0xda5123c0上设置EGL_SWAP_BEHAVIOR,错误= EGL_SUCCESS I / Choreographer(611):跳过96帧!该应用程序可能在其主线程上做太多工作。 W / ActivityManager(611):ActivityRecord {3c07bf69 u0 com.company.mobile/.MainActivity t20 f}的活动暂停超时 I / Choreographer(611):跳过31帧!该应用程序可能在其主线程上做太多工作。 W / EGL_emulation(1497):eglSurfaceAttrib未实现 W / OpenGLRenderer(1497):无法在表面0xdf214c40上设置EGL_SWAP_BEHAVIOR,错误= EGL_SUCCESS
我的AndroidManifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.company.mobile"><uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
-----------主要应用程序-------------
package com.company.mobile;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.reactnativecommunity.webview.RNCWebViewPackage;
import com.microsoft.appcenter.reactnative.crashes.AppCenterReactNativeCrashesPackage;
import com.microsoft.appcenter.reactnative.analytics.AppCenterReactNativeAnalyticsPackage;
import com.microsoft.appcenter.reactnative.appcenter.AppCenterReactNativePackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import io.invertase.firebase.RNFirebasePackage;
import io.invertase.firebase.messaging.RNFirebaseMessagingPackage;
import io.invertase.firebase.fabric.crashlytics.RNFirebaseCrashlyticsPackage;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new AppCenterReactNativeCrashesPackage(MainApplication.this, getResources().getString(R.string.appCenterCrashes_whenToSendCrashes)),
new AppCenterReactNativeAnalyticsPackage(MainApplication.this, getResources().getString(R.string.appCenterAnalytics_whenToEnableAnalytics)),
new AppCenterReactNativePackage(MainApplication.this),
new RNGestureHandlerPackage(),
new RNFirebasePackage(),
new RNFirebaseMessagingPackage(),
new RNFirebaseCrashlyticsPackage(),
new RNCWebViewPackage()
);
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
答案 0 :(得分:0)
修改
<application
android:name=".MainApplication"
到
<application
android:name="com.company.mobile.MainApplication"
如果您修改了程序包名称,则将其替换为一个。
还要确保清单中您要导入正确的软件包
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
xmlns:tools="http://schemas.android.com/tools"
package="com.company.mobile">