Installation failed due to: 'null' - Android Studio 3.5

AndroidAndroid Studio

Android Problem Overview


I have updated Android studio to 3.5, ever since I am running into an APK installation problem. This is the only log it shows:

Installation did not succeed.
The application could not be installed: INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION
Installation failed due to: 'null'
Retry

This happens when trying to install APK on a real device. If I uninstall the app from the device and then rerun the build, it installs only one time and then it keeps throwing this error on the next installation. It runs fine on an emulator but I can not use an emulator for everything.

What I have tried:

  • Deleted Android Studio configuration file.
  • Deleted Gradle files from the project.
  • Invalidated and reset caches.
  • Cleaned/rebuilt the project.
  • Looked for similar problems Stackoverflow(nothing matches my problem)
  • Clean installed(Removed all files including SDKs) Android Studio 3.5

Update

I installed Linux Mint on my machine and tested the AS 3.5 there, for some reason everything is working fine even for Android 7 and below devices.

Previous OS: Windows 10 1903

Current OS: Linux Mint 19.2

I reckon this problem may be originating from Windows machines.

Android Solutions


Solution 1 - Android

Open Run/Debug Configuration dialog (Windows: Run > Edit Configurations)

edit You app > General > Installation Options > Install Flags .

add install flags -r -t.

This flags means adb install -r -t apkpath

screen pic

Solution 2 - Android

You need disable "Use libusb backend" in preferences--> debugger enter image description here

Solution 3 - Android

This issue in Android Studio happens for devices lower then API 26 (Android 8). This is caused by replacement of InstantRun, known now as ApplyChanges.

Seems to be there are only two ways before they fix it in the next update.

  1. Run on API>=26.
  2. After every change in code edit run configuration changing deploy from APK to App bundle and vise-versa. If I correctly understand, this will correctly rebuild app and workaround bug.

Of course, there is an option to manually delete app from device before running app from AndroidStudio.

Solution 4 - Android

Build > Clean project its work's for me. Before change other setting try this first.

Happy coding :)

Solution 5 - Android

For me either uninstalling the app or cleaning project "solves" the problem. To make it less frustrating I added clean job to debug build type like so:

buildTypes {
    ...
    debug {
        clean
    }
    ...
}

Solution 6 - Android

After reading the Release Notes regarding Apply Changes, I finally found a solution here: https://developer.android.com/studio/run#apply-changes-run-fallback

> ## Enable Run fallback for Apply Changes
> > After you've clicked either Apply Changes and Restart Activity or > Apply Code Changes, Android Studio builds a new APK and determines > whether the changes can be applied. If the changes can't be applied > and would cause Apply Changes to fail, Android Studio prompts you to > Run Run icon your app again instead. However, if you don't want to be > prompted every time this occurs, you can configure Android Studio to > automatically rerun your app when changes can't be applied. > > To enable this behavior, follow these steps: > > 1. Open the Settings or Preferences dialog: > - On Windows or Linux, select File > Settings from the menu bar. > - On macOS, select Android Studio > Preferences from the menu bar. > 2. Navigate to Build, Execution, Deployment > Deployment.
> 3. Select the checkboxes to enable automatic Run fallback for either of > the Apply Changes actions. > 4. Click OK.

Screenshot running on Linux

Solution 7 - Android

There is a problem with Lineage OS as stated by Google team in https://issuetracker.google.com/issues/139782879:

> We are able to reproduce it on a device with LineageOS. It does not fully support a system call that we use for DeltaInstall.

There is no apparent solution (other than removing the APK from build folder or uninstalling the application).

>We should have a workaround for it but as it stands right now, LineageOS will not have DeltaInstall and will always need to perform a slower full install.

Changing to Nothing as pointed out by OP will not deploy the APK to the device (that's why an error will not be displayed), so it will not solve the problem.

Edit:

This has been fixed in Android Studio 3.6.

>Thanks for the feedback. This should be fixed in the latest versions of 3.6.

Solution 8 - Android

I got the solution in the code edit run configuration changing in Deploy select Default APK and install flag =-r -t and then Apply for the run. The app will run in all devices and emulator. I was testest in OPPO 1 plus, Samsung Tab, Emulator Also.

Please Go thought the Edit Run configuration near to run button in Android Studio

edit app > general ==> installation options ==> Install flags

add install flags -r -t

-r means "replace existing application". -t means "allow test packages"

[![enter image description here][1]][1] [1]: https://i.stack.imgur.com/dd0HR.png

Solution 9 - Android

1-clean project from Build -> CleanProject

2-delete folder outputs from ProjectPath/app/build/outputs

3-then build gradle and run app

Solution 10 - Android

I too am having this same problem after upgrading to 3.5. I was wondering if you have had any luck getting 'Run' to work with a connected device?

UPDATE: I was am to get this to work by Setting "APK from app bundle" under Installation Options in the "Run/Debug Configurations" dialog

Solution 11 - Android

I also got this error when I ran the application on real xiaomi pocophone 1 and solved this problem by running the application first on the emulator, and then on my xiaomi pocophone 1

Solution 12 - Android

I got this because the device was locked and required user to accept permissions in order to install it. (Huawei Harmony OS)

Unlocking the phone to prepare for the installation process solved the issue.

Solution 13 - Android

Deleting/uninstalling the app from the device fixed the problem for me.

Solution 14 - Android

Add a "clean" gradle task dependency before installing/running your apks using below configuration.

project.afterEvaluate {
    android.applicationVariants.all { variant ->
        variant.outputs.each { output ->
            def capitalizedVariant = variant.name.capitalize()
            def assembleVariantTask = project.tasks."assemble${capitalizedVariant}"
            assembleVariantTask.dependsOn clean
        }
    }
}

Copy and paste above code into your app/build.gradle file, this works for all the build variants.

In specifically, above code will be equivalent to below if you only have debug and release build types:

assembleDebug.dependsOn clean
assembleRelease.dependsOn clean

Solution 15 - Android

What Worked for me to remove old application, then rerun the project. In that case old sign certificate does not bother.

Solution 16 - Android

splits {
    abi {
        enable true
        reset()
        include 'x86', 'armeabi-v7a','x86_64'
        universalApk true
    }
}

Due to the different constructions such as 'armeabi', 'x86', 'armeabi-v7a', 'x86_64', and 'arm64-v8a', we have to add the configuration above into build.gradle file.

Solution 17 - Android

For me I added accidentally new BlankActivity which is inherited from Wearable Activity. Then I deleted the activity code and layout file. But I forgot to delete the wearable related tag in App Manifest.xml file. This is the main problem for someone like me.

Solution 18 - Android

If your app targets Android 12 or higher, you must declare these attribution tags in your app's manifest file. If the app component includes the LAUNCHER category, set android:exported to true.

 <activity
    android:name="com.test.activity.SplashActivity"
    android:clearTaskOnLaunch="true"
    android:label="@string/app_name"
    android:launchMode="singleTop"
    android:noHistory="true"
    android:screenOrientation="portrait"
    android:theme="@style/AppTheme.NoActionBar"
    android:exported="true">

Also check receiver or service in Androidmanifest, if you are using any receiver or service set android:exported="true" or false according requirement.

<receiver
    android:name="com.test.receiver.ShareReceiver"
    android:exported="true">
    <intent-filter>
        <action android:name="com.test.fcm.android.action.broadcast" />
    </intent-filter>
</receiver>

 <service
    android:name="com.google.android.gms.tagmanager.InstallReferrerService"
    android:exported="true" />

Also update all your gradle dependency. I have updated following dependency as per requirement.

testImplementation 'junit:junit:4.13.2' 
androidTestImplementation 'androidx.test:runner:1.4.0'


androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.razorpay:checkout:1.6.15'

Hope it will help you as well.

Solution 19 - Android

At last, I found the solution

just set v2SigningEnabled true

 signingConfigs {
    release {
        v2SigningEnabled true
    }
}

Solution 20 - Android

I did not face the problem myself. However, previously we had some problems with the Instant Run of the Android Studio. I would like to suggest checking the following settings in your Android Studio and uncheck the settings to check if your code works now.

Go to the Android Studio -> Preference and then uncheck the following under the Deployments.

enter image description here

Here's what is new in Android Studio 3.5 regarding this which will help you to understand the feature better.

enter image description here

Solution 21 - Android

Try to run the command "adb devices", if the output is empty, then reconnect the device. This helped me with the same error. Android studio 3.5 does not determine that the device has disconnected.

Solution 22 - Android

It bug still have on my mac os, when i get new real device and try install apk from android studio 3.5 - and I find ugly way how it fix - open terminal in studio and follow:

cd app/build/outputs/apk/debug
adb install -r -t your_app_name.apk

And it need to do with each project and each device!!

Edited:

I eventually installed

> Android Studio 3.6 Canary

  • it's more working version than 3.5

But stiil need add into install flags -r -t

Solution 23 - Android

I uninstalled the app from emulator, ran and everything went back to normal

Solution 24 - Android

For me minSdkVer = 22, tarSdkVer = 28,run Gradle -> app -> Tasks -> build -> clean && cleanBuildCache action, problem solved.

Solution 25 - Android

I pressed the hammer icon to rebuild the app then it installed. So I don't know? The whole android hack job platform sucks.

All that money yet google can't hire or find programmers good enough to come up with their own true operating system.

Solution 26 - Android

In my case, it only works by disabling the APK signature verification:

$ adb shell settings put global verifier_verify_adb_installs 0

And using the -r -t flags mentioned above

Solution 27 - Android

I also faced the same issue , i followed the following steps

  1. Clean Project
  2. Rebuilt Project

This solved my problem

Solution 28 - Android

In my case, I can't solve with all of the above answers so that I find another way. Finally, I found the solution. Just find the correct drivers of phone. My development phone is Samsung Galaxy Note 2 (MODEL : GT-N7105 / Android 4.1.2). I just share my solution to how I solved it. Hope save your time.

Solution 29 - Android

The problem occurs when you are testing a new module. First, you write it individually, and then add it to the main app. When you add it to the main app, delete your "test_app" from your phone.

Solution 30 - Android

Run -> Edit Configuration -> install flags: -r -t -> Apply -> Ok

Solution 31 - Android

I got this problem a few minutes ago when I tried running my app on real device and stopped gradle build before it finished. What I just did was to uninstall the app on device and rerun the app on both AVD and real device (simultaneously) and it worked. Hope this works for you too

Solution 32 - Android

Main Solution

  1. File -> Settings -> Build, Execution, Deployment -> Debugger > Disable Use libusb backend

  2. Gradle (Flap to the right of the IDE) -> android -> app -> Tasks -> install -> uninstallAll or you can also do it by console in the following way:

    $ ./gradlew uninstallAll



Other Tips:
  • Delete and create the app again in Run/Debug Configuration

    • Installation Options -> Check Install for all users
  • Run/Debug Configuration -> Launch Options > Launch: Specified Activity > Choose an Activity

  • Install app using another physical device, version of the IDE or PC

  • Reinstall IDE and delete .android

  • Retry with the main solution


If you want to install and open the app you can use adb with the following commands:

$ adb install -r -t absolute-path.apk

$ adb shell am start -n "com.package.flavor.env/.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER

GL

Source

Solution 33 - Android

For me the issue started when I created a new blank activity and Android studio created a Wearable activity for some reason. Once I removed all mentions to wearable activity from the manifest and I deleted the class everything went back to normal.

Solution 34 - Android

try to chang android:appComponentFactory="" to android:appComponentFactory="new","new" can be any words

Solution 35 - Android

Finally, I got the solution in the code edit run configuration changing in Installation option DEPLOY--> from select 4th option -->(Nothing) option --> Apply And the app works properly in android studio 3.5. In mobile and emulator also. This work properly in android version 9 also This is a permanent solution.

Solution 36 - Android

gradle.properties -> android.enableAapt2=false

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTaseer AhmadView Question on Stackoverflow
Solution 1 - Android胡晟昊View Answer on Stackoverflow
Solution 2 - AndroidHoussin BoullaView Answer on Stackoverflow
Solution 3 - AndroidmohaxView Answer on Stackoverflow
Solution 4 - Androidhappy_codingView Answer on Stackoverflow
Solution 5 - AndroidSanchoView Answer on Stackoverflow
Solution 6 - AndroidMuhammad Baja AkshaView Answer on Stackoverflow
Solution 7 - AndroidPedro OliveiraView Answer on Stackoverflow
Solution 8 - AndroidSuyog DorlikarView Answer on Stackoverflow
Solution 9 - AndroidFarid Sharif MoghaddamView Answer on Stackoverflow
Solution 10 - AndroidChoovenView Answer on Stackoverflow
Solution 11 - Androidch13mobView Answer on Stackoverflow
Solution 12 - AndroidhtafoyaView Answer on Stackoverflow
Solution 13 - AndroidAlex SagView Answer on Stackoverflow
Solution 14 - AndroidshizhenView Answer on Stackoverflow
Solution 15 - AndroidAzamat MahkamovView Answer on Stackoverflow
Solution 16 - Androiduser9973657View Answer on Stackoverflow
Solution 17 - AndroidWai YanView Answer on Stackoverflow
Solution 18 - AndroidKishan ThakkarView Answer on Stackoverflow
Solution 19 - AndroidyefengView Answer on Stackoverflow
Solution 20 - AndroidReaz MurshedView Answer on Stackoverflow
Solution 21 - AndroidBoris TimofeevView Answer on Stackoverflow
Solution 22 - Androidnicolas asinovichView Answer on Stackoverflow
Solution 23 - AndroidWozView Answer on Stackoverflow
Solution 24 - AndroidShanksiscoolView Answer on Stackoverflow
Solution 25 - Androiddcarl661View Answer on Stackoverflow
Solution 26 - AndroidlgallardView Answer on Stackoverflow
Solution 27 - AndroidVivekView Answer on Stackoverflow
Solution 28 - AndroidB MView Answer on Stackoverflow
Solution 29 - AndroidСтанислав ГордеевView Answer on Stackoverflow
Solution 30 - AndroidSavita SharmaView Answer on Stackoverflow
Solution 31 - AndroidRichierichView Answer on Stackoverflow
Solution 32 - AndroidBraian CoronelView Answer on Stackoverflow
Solution 33 - AndroidEddieView Answer on Stackoverflow
Solution 34 - Androidsh_ZJView Answer on Stackoverflow
Solution 35 - AndroidSuyog DorlikarView Answer on Stackoverflow
Solution 36 - AndroidsapegView Answer on Stackoverflow