Maaz Zindani

Loading the index…

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

Android refuses an APK with app not installed, package appears to be invalid

Your error

App not installed as package appears to be invalid.1 more line it can show

Fix it fast

Most common cause, 1 of 4

The APK is a test-only build made by Android Studio Run

On your own test device, pass -t so adb accepts a test APK.

Fix
# your own device
adb install -t app-debug.apk
# an APK to share
./gradlew assembleRelease
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

App not installed as package appears to be invalid is one dialog for several install failures: a test-only APK from Android Studio Run, an unsigned release build, a v1-only signature on Android 11 or newer, or a lower versionCode than the installed copy. Run adb install on the same file to read the real failure code, then fix that cause.

  • Applies to Android 11 to Android 17, Android Gradle plugin 9.5, Android SDK Platform-Tools (adb, apksigner)
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

The phone's dialog hides the reason. Connect the device with USB debugging on and install the same file with adb: the failure code it prints (TEST_ONLY, NO_CERTIFICATES, VERSION_DOWNGRADE and so on) names the cause.

Run this first
adb install path/to/app.apk

Then find the line you see in this list and open its fix:

  1. 1The APK is a test-only build made by Android Studio Runadb reports INSTALL_FAILED_TEST_ONLY, and the file was taken from the build folder after pressing Run or Debug
  2. 2The release APK was never signedadb reports INSTALL_PARSE_FAILED_NO_CERTIFICATES, or apksigner verify fails on the file
  3. 3The APK has only a v1 (JAR) signature and targets API 30 or higherThe APK was signed by an older tool or a custom script, installs on Android 10, and fails on Android 11 and newer
  4. 4A newer version of the same app is already on the phoneadb reports INSTALL_FAILED_VERSION_DOWNGRADE; the same APK installs fine on a clean emulator

What does the error look like?

  • App not installed as package appears to be invalid.
  • App not installed.

Cause 1 of 4

The APK is a test-only build made by Android Studio Run

You seeadb reports INSTALL_FAILED_TEST_ONLY, and the file was taken from the build folder after pressing Run or Debug

Check

The installer says the package appears to be invalid because the APK carries android:testOnly. Android's adb guide says Gradle makes such a test APK when you only run or debug the app, and the manifest reference says this kind of APK installs only through adb.

Check
adb install app-debug.apk

Fix

On your own test device, pass -t so adb accepts a test APK. To give the app to anyone else, build a signed release APK instead of copying the Run output.

Fix
# your own device
adb install -t app-debug.apk
# an APK to share
./gradlew assembleRelease

Verify

The install command ends without a failure code and the app icon appears on the device.

Verify
adb shell pm list packages com.example.myapp

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 4

The release APK was never signed

You seeadb reports INSTALL_PARSE_FAILED_NO_CERTIFICATES, or apksigner verify fails on the file

Check

A release build with no signingConfig comes out without any certificate. AOSP maps the no-certificates parse failure to the invalid status, so the phone shows the package appears to be invalid. The Android build guide says a release APK must be signed with your private key.

Check
apksigner verify app-release.apk

Fix

Add a signingConfigs block to the module build.gradle.kts and point the release build type at it, then rebuild. Keep the passwords out of the file in real projects.

Fix
android {
    signingConfigs {
        create("release") {
            storeFile = file("my-release-key.jks")
            storePassword = "password"
            keyAlias = "my-alias"
            keyPassword = "password"
        }
    }
    buildTypes {
        getByName("release") {
            signingConfig = signingConfigs.getByName("release")
        }
    }
}

Verify

apksigner verify finishes without an error and adb install no longer reports a failure code.

Verify
apksigner verify app-release.apk && adb install app-release.apk

Confirmed by developer.android.com

Did this fix it?

Cause 3 of 4

The APK has only a v1 (JAR) signature and targets API 30 or higher

You seeThe APK was signed by an older tool or a custom script, installs on Android 10, and fails on Android 11 and newer

Check

Android 11 behavior changes say apps targeting API level 30 that are signed only with APK Signature Scheme v1 cannot be installed or updated on Android 11 devices. Print the signature details in verbose mode to see which schemes are present.

Check
apksigner verify -v app-release.apk

Fix

Sign the APK with apksigner, which picks the schemes from the min and max SDK levels, instead of jarsigner. Align it with zipalign before signing.

Fix
zipalign -v -p 4 my-app-unsigned.apk my-app-unsigned-aligned.apk
apksigner sign --ks my-release-key.jks --out my-app-release.apk my-app-unsigned-aligned.apk

Verify

The verbose check now reports v2 or a later scheme, and the APK installs on an Android 11+ phone.

Verify
apksigner verify -v my-app-release.apk

Confirmed by developer.android.com

Did this fix it?

Cause 4 of 4

A newer version of the same app is already on the phone

You seeadb reports INSTALL_FAILED_VERSION_DOWNGRADE; the same APK installs fine on a clean emulator

Check

Android compares versionCode and blocks an APK whose number is lower than the installed copy. AOSP's install status table sends that downgrade failure to the same invalid-package dialog, which is why the message looks unrelated.

Check
adb shell pm list packages com.example.myapp

Fix

Raise versionCode in defaultConfig above the installed build, or remove the installed copy first. Uninstalling deletes that app's data on the device.

Fix
# option 1: build.gradle.kts, defaultConfig { versionCode = 42 }
# option 2: remove the installed copy, then install again
adb shell pm uninstall com.example.myapp
adb install app-release.apk

Verify

The install completes and the app opens at the new version.

Verify
adb install app-release.apk

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Share builds only from a signed release variant or an internal testing track, never from the folder Android Studio Run writes to.
  • Run apksigner verify -v on every APK in CI before it is uploaded or sent to testers.
  • Increase versionCode on every build you hand out, so a tester's phone never holds a higher number than the new file.

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 on the same stack: QistLock, Nuclear Home Video.

Next step

Want this handled for good?

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