很遗憾" App"已经停止

时间:2017-10-11 16:33:54

标签: android react-native

当我进入流程" react-native run-android"我收到一条错误消息:"很遗憾" App"已停止"并且应用程序无法打开。

我在另一台电脑(Mac OS)上试过这个应用程序,它的工作非常完美。在我的电脑上我有Ubuntu 14.04

Adb logcat报告:

10-11 13:23:59.796   985  1126 D hwcomposer: hw_composer sent 104 syncs in 60s
10-11 13:24:00.259  1291  1302 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.rnauth/.MainActivity (has extras)} from uid 10009 on display 0
10-11 13:24:00.268  1291  1311 W BroadcastQueue: Permission Denial: receiving Intent { act=com.android.launcher3.action.LAUNCH flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$GmsExternalReceiver requires com.android.launcher3.permission.RECEIVE_LAUNCH_BROADCASTS due to sender com.android.launcher3 (uid 10009)
10-11 13:24:00.268  1291  1311 W BroadcastQueue: Permission Denial: broadcasting Intent { act=com.android.launcher3.action.LAUNCH flg=0x10 (has extras) } from com.android.launcher3 (pid=1654, uid=10009) requires com.google.android.launcher.permission.RECEIVE_LAUNCH_BROADCASTS due to receiver com.google.android.gms/.icing.proxy.ApplicationLauncherReceiver
10-11 13:24:00.268  1291  1311 W BroadcastQueue: Permission Denial: broadcasting Intent { act=com.android.launcher3.action.LAUNCH flg=0x10 (has extras) } from com.android.launcher3 (pid=1654, uid=10009) requires com.google.android.launcher.permission.RECEIVE_LAUNCH_BROADCASTS due to receiver com.google.android.googlequicksearchbox/com.google.android.search.core.icingsync.ApplicationLaunchReceiver
10-11 13:24:00.274  2845  2845 I art     : Not late-enabling -Xcheck:jni (already on)
10-11 13:24:00.296  1291  1415 I ActivityManager: Start proc 2845:com.rnauth/u0a63 for activity com.rnauth/.MainActivity
10-11 13:24:00.324  2845  2845 D AndroidRuntime: Shutting down VM
10-11 13:24:00.324  2845  2845 E AndroidRuntime: FATAL EXCEPTION: main
10-11 13:24:00.324  2845  2845 E AndroidRuntime: Process: com.rnauth, PID: 2845
10-11 13:24:00.324  2845  2845 E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate application com.rnauth.MainApplication: java.lang.ClassNotFoundException: Didn't find class "com.rnauth.MainApplication" on path: DexPathList[[zip file "/data/app/com.rnauth-2/base.apk"],nativeLibraryDirectories=[/data/app/com.rnauth-2/lib/x86, /data/app/com.rnauth-2/base.apk!/lib/x86, /vendor/lib, /system/lib]]
10-11 13:24:00.324  2845  2845 E AndroidRuntime:        at android.app.LoadedApk.makeApplication(LoadedApk.java:578)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4680)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:        at android.app.ActivityThread.-wrap1(ActivityThread.java)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:102)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:148)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:5417)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
10-11 13:24:00.324  2845  2845 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.rnauth.MainApplication" on path: DexPathList[[zip file "/data/app/com.rnauth-2/base.apk"],nativeLibraryDirectories=[/data/app/com.rnauth-2/lib/x86, /data/app/com.rnauth-2/base.apk!/lib/x86, /vendor/lib, /system/lib]]
10-11 13:24:00.324  2845  2845 E AndroidRuntime:        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:        at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:        at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:        at android.app.Instrumentation.newApplication(Instrumentation.java:981)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:        at android.app.LoadedApk.makeApplication(LoadedApk.java:573)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:        ... 9 more
10-11 13:24:00.324  2845  2845 E AndroidRuntime:        Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.rnauth-2/base.apk
10-11 13:24:00.324  2845  2845 E AndroidRuntime:                at dalvik.system.DexFile.openDexFileNative(Native Method)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:                at dalvik.system.DexFile.openDexFile(DexFile.java:295)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:                at dalvik.system.DexFile.<init>(DexFile.java:80)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:                at dalvik.system.DexFile.<init>(DexFile.java:59)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:                at dalvik.system.DexPathList.loadDexFile(DexPathList.java:279)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:                at dalvik.system.DexPathList.makePathElements(DexPathList.java:248)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:                at dalvik.system.DexPathList.<init>(DexPathList.java:120)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:                at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:48)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:                at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:65)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:                at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:58)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:                at android.app.LoadedApk.getClassLoader(LoadedApk.java:376)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:                at android.app.LoadedApk.makeApplication(LoadedApk.java:568)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:                ... 9 more
10-11 13:24:00.324  2845  2845 E AndroidRuntime:        Suppressed: java.lang.ClassNotFoundException: com.rnauth.MainApplication
10-11 13:24:00.324  2845  2845 E AndroidRuntime:                at java.lang.Class.classForName(Native Method)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:                at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:                at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:                at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
10-11 13:24:00.324  2845  2845 E AndroidRuntime:                ... 12 more
10-11 13:24:00.324  2845  2845 E AndroidRuntime:        Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
10-11 13:24:00.325  1291  1303 W ActivityManager:   Force finishing activity com.rnauth/.MainActivity
10-11 13:24:00.346   985  1857 D gralloc_goldfish: gralloc_alloc: format 1 and usage 0x933 imply creation of host color buffer
10-11 13:24:00.346   985  1857 D         : HostConnection::get() New Host Connection established 0xb25f4640, tid 1857
10-11 13:24:00.394  1291  1316 D         : HostConnection::get() New Host Connection established 0x993b17c0, tid 1316
10-11 13:24:00.656  1291  1303 I WindowManager: Screenshot max retries 4 of Token{1465e14 ActivityRecord{a0b2067 u0 com.rnauth/.MainActivity t25 f}} appWin=Window{bb1b55f u0 Starting com.rnauth} drawState=3
10-11 13:24:00.657  1291  1291 W art     : Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService.crashApplication(com.android.server.am.ProcessRecord, android.app.ApplicationErrorReport$CrashInfo) from ActivityManagerService.java:12502 waiters=0 for 303ms
10-11 13:24:00.682  1291  2470 I AccountManagerService: getTypesVisibleToCaller: isPermitted? true
10-11 13:24:00.734  1291  2807 I OpenGLRenderer: Initialized EGL, version 1.4
10-11 13:24:00.894   985  1857 D gralloc_goldfish: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
10-11 13:24:00.947  1291  2807 E EGL_emulation: tid 2807: eglSurfaceAttrib(1165): error 0x3009 (EGL_BAD_MATCH)
10-11 13:24:00.947  1291  2807 W OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x995cc8e0, error=EGL_BAD_MATCH
10-11 13:24:00.955   985  1335 D gralloc_goldfish: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
10-11 13:24:00.962   985  1335 D gralloc_goldfish: gralloc_alloc: format 1 and usage 0x900 imply creation of host color buffer
10-11 13:24:01.170  1291  1311 W ActivityManager: Activity pause timeout for ActivityRecord{a0b2067 u0 com.rnauth/.MainActivity t25 f}
10-11 13:24:02.517  1291  1312 I Choreographer: Skipped 92 frames!  The application may be doing too much work on its main thread.
10-11 13:24:02.581  1291  1316 D gralloc_goldfish: gralloc_unregister_buffer: exiting HostConnection (is buffer-handling thread)
10-11 13:24:05.737  2070  2859 W PlatformStatsUtil: Could not retrieve Usage & Diagnostics setting. Giving up.
10-11 13:24:12.796  1291  1311 W ActivityManager: Activity destroy timeout for ActivityRecord{a0b2067 u0 com.rnauth/.MainActivity t25 f}

的AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.rnauth"
    android:versionCode="2"
    android:versionName="2.0">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="22" />

    <application
      android:name=".MainApplication"
      android:allowBackup="true"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:theme="@style/AppTheme">
      <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
        <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>

</manifest>

Build.grandle:

apply plugin: "com.android.application"

import com.android.build.OutputFile



apply from: "../../node_modules/react-native/react.gradle"

def enableSeparateBuildPerCPUArchitecture = false


def enableProguardInReleaseBuilds = false

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.rnauth"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 2
        versionName "2.0"
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }
    buildTypes {
        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:
            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
            def versionCodes = ["armeabi-v7a":1, "x86":2]
            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 {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
}


task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}

1 个答案:

答案 0 :(得分:-1)

您是否尝试在app gradle上启用multidex?如果你不这样做,试试这个:

defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...

// Enabling multidex support.
multiDexEnabled true
}

 dependencies {
     compile 'com.android.support:multidex:1.0.0'
 }