Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

intent.resolveActivity() returns null although the other app is installed

Errorintent.resolveActivity(packageManager) returns null

Short answer

From Android 11 (API 30) the system hides most other apps from your app unless your manifest says which ones it needs. So resolveActivity returns null for an app that is installed. Add a queries block to the manifest: list a package name, or an intent signature that matches the apps you want to reach.

  • Applies to Android 11 (API 30) and newer, targetSdk 30 and higher, Android Gradle Plugin 8.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check whether your app targets API 30 or higher and whether the manifest has any queries element. No queries element plus a null result points at package visibility.

    grep -n "targetSdk" app/build.gradle*
    grep -n "<queries" app/src/main/AndroidManifest.xml
  2. 2Match what you see, then jump to its fix

    1. 1resolveActivity is null for one specific app (a payment app, a map app, a social app) that is installed on the deviceYou know the target app, but its package is not declaredFix
    2. 2resolveActivity is null for a SEND, VIEW or similar intent with a MIME type or schemeYou target a kind of app (browser, mail, image sharing), not one packageFix
    3. 3The failing code resolves or binds to a provider through its authority stringThe query is for a content provider you only know by authorityFix

What does the error look like?

  • intent.resolveActivity(packageManager) returns null
  • startActivity fails or does nothing for an installed app after targetSdk was raised to 30

Cause 1 of 3

You know the target app, but its package is not declared

1Check

The system filters out other apps by default when your app targets Android 11 or higher. Apps you did not declare are not visible to PackageManager queries.

grep -n -A6 "<queries" app/src/main/AndroidManifest.xml

2Fix

Name the packages inside a queries element, as a child of the manifest element.

<manifest ...>
    <queries>
        <package android:name="com.example.store" />
    </queries>
    <application ...>
</manifest>

3Verify

Rebuild, install, and call resolveActivity again for the same intent. It returns a component name instead of null.

./gradlew installDebug

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 3

You target a kind of app (browser, mail, image sharing), not one package

1Check

When you do not know the package names, an intent signature in queries makes every app with a matching intent filter visible. Each intent element needs exactly one action.

grep -n -B2 -A8 "<intent>" app/src/main/AndroidManifest.xml

2Fix

Declare an intent element that matches the intent you build in code.

<queries>
    <intent>
        <action android:name="android.intent.action.SEND" />
        <data android:mimeType="image/jpeg" />
    </intent>
</queries>

3Verify

Install the build and run the intent check again, on a device with a matching app.

./gradlew installDebug

Confirmed by developer.android.com

Did this fix it?

Cause 3 of 3

The query is for a content provider you only know by authority

1Check

Provider authorities are a third way to make an app visible. Look for authority strings in the code that fails.

grep -rn "authorit" app/src/main/java app/src/main/AndroidManifest.xml

2Fix

Declare the authority in queries.

<queries>
    <provider android:authorities="com.example.settings.files" />
</queries>

3Verify

Rebuild and repeat the call that failed.

./gradlew installDebug

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Declare the smallest set of packages or intent signatures your app needs. Google treats broad package visibility as a privacy cost.
  • Avoid QUERY_ALL_PACKAGES unless your app is of a kind the docs list, such as a browser, antivirus or accessibility app.
  • When you write a library that talks to other apps, put the queries element in the library manifest so every host app gets it.
  • Treat a null result as a state to handle: show a message or an install link, do not crash.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Mobile apps

Android Studio cannot pair the phone over Wi-Fi

The Pair devices over Wi-Fi dialog lists no device

Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.

4 causes, each with a fix

Mobile apps

adb tcpip 5555 fails because no device is found

adb: more than one device/emulator

adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.