The step that all android developers are always looking forward to is publishing the app on a mobile device or google play store so as to view how the code that you have written is working
As a developer, while developing applications I do tend to test the functionality at every stage other than waiting to complete the whole application.
Running an application and installing it on a mobile device successfully motivates a developer since you are guaranteed that the app that you are building has no errors in structure or configuration in android studio. The only errors can be only found if your code is not working properly.
If you are running your application and installing it on your mobile device using the USB (Universal Serial Bus), sometimes you may come across this error
Session 'app': Installation did not succeed. The application could not be installed: INSTALL_FAILED_USER_RESTRICTED Retry
When the above error occurs that the application could not be installed, it means you have to look for a way to fix the error or you install your application through different means
How to install an application without using a USB
If you do not have a USB that will install the application directly to your mobile phone or you want to share a build of the application with another user to test the features, you can use this method to install the app to a mobile device without using a USB.
- In the android studio, click build, then build bundle/apk then build apk
- Wait for Gradle build to build and finish
- Click locate after the build has completed to open where the apk has been saved in your computer
- share the application in your device or to another using any sharing media including WhatsApp and email
- Click the apk once sharing has been completed to install the application
In this article, we shall focus on how to solve the error the application could not be installed: INSTALL_FAILED_USER_RESTRICTED so that you can run your app directly from android studio to your device
The error mostly occurs when your mobile phone or device is not configured to allow installation through USB
Note that the procedure we are going to share is not the same with all mobile phones since different phone brands have different layouts of items (am using Redmi 9A from Xiaomi)
- open settings in your phone
- First, you will need to enable developer options in your device if you are not a developer by
Navigating to about phone after opening settings
Tap the build number for 7 times
The developer will be enabled
- Once you are a developer, you will need to allow USB debugging by turning it on
To turn USB debugging on;
In the settings tab, click on additional settings
Scroll down to developer options and click it which will be visible after enabling developer options
In the debugging section, turn on USB debugging and that should be it
How to run install the app using a USB
To run the app directly from android studio to your mobile device;
- Ensure your phone is connected to the laptop using the USB cable
- Ensure USB debugging is allowed by agreeing to the popup that will be presented on your mobile device the first time you connect to the laptop using USB
- Click RUN in android studio
- Wait for the build to finish and your app will be installed to your app and the first or launcher activity will be opened
Conclusion
Testing an application in a real environment to test whether it’s working is the dream of every android developer
Having an easier way to run and install the application to the mobile phone is considered the fastest method of debugging
In the above discussion, we have highlighted how to allow developer options and setting USB debugging on so as to fix the error INSTALL_FAILED_USER_RESTRICTED