简体   繁体   中英

My app has successfully been installed on Android, but crashes as soon as it loads

My apk is successfully pushed onto my Android device which is a Huawei Y6. My ant build is successful, as is my ndk-build. When i press my apps icon a black screen is loaded onto the phone. This lasts a few seconds before crashing. Here is a copy of my AndroidManifest.xml

  <?xml version="1.0" encoding="utf-8"?>

  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
            package="com.tutorial.game"
            android:versionCode="1"
            android:versionName="1.0"
            android:installLocation="auto">

  <!-- Android 2.3.3 -->
  <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="25" />

  <!-- OpenGL ES 3.0 -->
  <uses-feature android:glEsVersion="0x00030000" />

  <!-- Allow writing to external storage -->
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />


<application android:label="@string/app_name"
             android:icon="@drawable/ic_launcher"
             android:allowBackup="true"
             android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
             android:debuggable="true"
             android:hardwareAccelerated="true" >
    <activity android:name="HelloSDL2Activity"
              android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
                    android:configChanges="orientation|keyboard|keyboardHidden|screenLayout"
              android:screenOrientation="sensorLandscape"
              android:launchMode="singleTask" android:hardwareAccelerated="true" android:enabled="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

     </activity>
  </application>

</manifest> 

I ran this from the command line to create a logfile:

adb logcat -V long *:W *:E *:F > log.txt

and here is a snippet of what was logged:

  [ 03-31 20:32:36.129   820:28542 W/ActivityManager ]

  Force finishing activity 1 com.tutorial.game/.HelloSDL2Activity



  [ 03-31 20:32:36.239   820:28542 W/ActivityManager ]

  Exception thrown during pause

  android.os.TransactionTooLargeException

at android.os.BinderProxy.transactNative(Native Method)

at android.os.BinderProxy.transact(Binder.java:496)

at android.app.ApplicationThreadProxy.schedulePauseActivity(ApplicationThreadNative.java:715)

at com.android.server.am.ActivityStack.startPausingLocked(ActivityStack.java:1012)

at com.android.server.am.ActivityStack.finishActivityLocked(ActivityStack.java:3393)

at com.android.server.am.ActivityStack.finishTopRunningActivityLocked(ActivityStack.java:3223)

at com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked(ActivityStackSupervisor.java:3026)

at com.android.server.am.ActivityManagerService.handleAppCrashLocked(ActivityManagerService.java:12440)

at com.android.server.am.ActivityManagerService.makeAppCrashingLocked(ActivityManagerService.java:12337)

at com.android.server.am.ActivityManagerService.crashApplication(ActivityManagerService.java:13066)

at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:12547)

at com.android.server.am.NativeCrashListener$NativeCrashReporter.run(NativeCrashListener.java:86)

Can anyone make sense of any of this. I've been searching Google for how to understand the logfile messages, but with little success.

Here is another snippet from the logfile:

 [ 03-31 20:37:05.049   820:29426 W/ActivityManager ]

 Exception thrown during pause

android.os.DeadObjectException

at android.os.BinderProxy.transactNative(Native Method)

at android.os.BinderProxy.transact(Binder.java:496)

at android.app.ApplicationThreadProxy.schedulePauseActivity(ApplicationThreadNative.java:715)

at com.android.server.am.ActivityStack.startPausingLocked(ActivityStack.java:1012)

at com.android.server.am.ActivityStack.finishActivityLocked(ActivityStack.java:3393)

at com.android.server.am.ActivityStack.finishTopRunningActivityLocked(ActivityStack.java:3223)

at com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked(ActivityStackSupervisor.java:3026)

at com.android.server.am.ActivityManagerService.handleAppCrashLocked(ActivityManagerService.java:12440)

at com.android.server.am.ActivityManagerService.makeAppCrashingLocked(ActivityManagerService.java:12337)

at com.android.server.am.ActivityManagerService.crashApplication(ActivityManagerService.java:13066)

at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:12547)

at com.android.server.am.NativeCrashListener$NativeCrashReporter.run(NativeCrashListener.java:86)

You are getting TransactionTooLargeException which could be because you are trying to load 5.25mb of data.

Sharing data via intents/bundles uses binder whose maximum limit at an instance is 1mb.

You screen is getting black because you may be trying to do heavy tasks while application is getting created.

So the first bug that I've managed to solve is to do with the icon. icon.png is located in the drawable file which is in the jni folder. I inserted an icon that had dimensions 500 x 726 into this file. Now even though you get your image displayed as the icon on your Android device, this actually causes the app to crash - hence the black page being displayed. There are actually five sizes of launcher icon, 48 × 48 (mdpi) 72 × 72 (hdpi) 96 × 96 (xhdpi) 144 × 144 (xxhdpi) 192 × 192 (xxxhdpi) 512 × 512 (Google Play store) Notice that both width and height have to be the same size. Anway having placed an icon with the correct dimensions in the drawable file causes my app to no longer crash out after a few seconds. It hasn't solved the entire problem however! More debugging to do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM