What could be causing the error "App isn't available" after Back click?

1

I open the app (using the Navigation Component) from the Launcher, it (correctly) shows the Start destination Fragment in the Activity NavHost. When I press Android's Back button, I am returned to the Launcher as expected.

But if I then open the app switcher UI, although I can see the app's task preview in the list, if I try to select it I see the error (as a toast) "App isn't available". So if I leave my app's Start Destination using Back, and then try to return to the app I see this error.

Activity class:

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
    val nav = findNavController(R.id.nav_host)
    NavigationUI.setupActionBarWithNavController(this, nav)
}

override fun onSupportNavigateUp(): Boolean {
    return Navigation.findNavController(this, R.id.nav_host).navigateUp()
}

Activity layout:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".ui.MainActivity">

    <fragment
            android:id="@+id/nav_host"
            android:name="androidx.navigation.fragment.NavHostFragment"
            android:layout_width="0dp"
            android:layout_height="0dp"
            app:navGraph="@navigation/nav_graph"
            app:defaultNavHost="true"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            />

</androidx.constraintlayout.widget.ConstraintLayout>

Navigation Graph

<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/nav_graph.xml"
            app:startDestination="@id/dashboardFragment"
        >
    <fragment
            android:id="@+id/dashboardFragment"
            android:name="com.blah.DashboardFragment"
            android:label="@string/title_dashboard"
            tools:layout="@layout/fragment_dashboard"
            >
        <action
                android:id="@+id/action_Dashboard_to_settingsFragment"
                app:destination="@id/settingsFragment"
                />
        <action
                android:id="@+id/action_dashboardFragment_to_attendFragment"
                app:destination="@id/attendFragment"
                />
        <action
                android:id="@+id/action_dashboardFragment_to_tutorialFragment"
                app:destination="@id/tutorialFragment"
                >
            <argument
                    android:name="showSkipOption"
                    android:defaultValue="true"
                    app:argType="boolean"
                    />
        </action>
    </fragment>
...

enter image description here

UPDATE: I initially thought this error to be related to the Navigation Component, but that is NOT the case. Prompted by Ian Lake's comment I removed the Navigation Component entirely, and the error persisted.

The app uses an Activity alias in the manifest:

    <activity-alias
            android:name=".Launcher"
            android:targetActivity=".ui.MainActivity"
            >
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity-alias>

Removing the Activity alias resolves the issue. I should mention that the error occurs when starting the app from Android Studio over ADB, so it looks as if this might possibly be an Android Studio v3.3 issue with the way it handles Activity aliases so I will report a bug.

On two instances of this error I saw logcat entries that differed but apparently were produced at the time of the errors:

Scenario 1

W/ziparchive: Unable to open '/data/app/com.blah.debug-zJeRYvYpxcoUYWHwCip1sg==/base.apk': No such file or directory
E/s.nexuslaunche: Failed to open APK '/data/app/com.blah.debug-zJeRYvYpxcoUYWHwCip1sg==/base.apk' I/O error
E/ResourcesManager: failed to add asset path /data/app/com.blah.debug-zJeRYvYpxcoUYWHwCip1sg==/base.apk
W/PackageManager: Failure retrieving resources for com.blah.debug

Scenario 2

W/SurfaceFlinger: Attempting to destroy on removed layer: AppWindowToken{6e5b26b token=Token{93243ba ActivityRecord{ee21ce5 u0 com.blah.debug/com.blah.Launcher t5941}}}#0
I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10100000 cmp=com.blah.debug/com.blah.ui.MainActivity} from uid 2000
W/ActivityManager: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10100000 cmp=com.blah.debug/com.blah.ui.MainActivity } from null (pid=-1, uid=2000) not exported from uid 10223
W/QuickScrubController: Failed to launch task (task=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.blah.debug/com.blah.ui.MainActivity } userId=0)

I've renamed this question and updated the tags to remove the Navigation Component as that was not the cause.

android
asked on Stack Overflow Jan 24, 2019 by Ollie C • edited Jan 25, 2019 by Ollie C

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0