I'm trying to create my first android application. For this purposes I use Android Studio 2.2.3. I have created the simple app with the single activity and which does nothing, just empty screen and no more else.
I'm developing on Meizu MX6 and I switched ON the next options:
Security App -> USB installation monitor
Settings -> Fingerprint and securiry -> Unknown sources
Settings -> Accessibility -> Developer Options -> USB debugging
Also have configured udev rules.
When I press the Run button I see this message:
Installation failed with message INSTALL_FAILED_USER_RESTRICTED.
It is possible that this issue is resolved by uninstalling an existing version of the apk if it is present, and then re-installing.
WARNING: Uninstalling will remove the application data!
Do you want to uninstall the existing application?
And after pressing OK this log appears in the console output:
$ adb push /home/***/dev/android/HelloAndroid/app/build/outputs/apk/app-debug.apk /data/local/tmp/com.android.hello.helloandroid
$ adb shell pm install -r "/data/local/tmp/com.android.hello.helloandroid"
pkg: /data/local/tmp/com.android.hello.helloandroid
Failure [INSTALL_FAILED_USER_RESTRICTED]
$ adb shell pm uninstall com.android.hello.helloandroid
DELETE_FAILED_INTERNAL_ERROR
Error while Installing APK
Can somebody explain how to fix this?
Check if current user have root access. And enable developer mode if you didn't do this yet.
Please build once again, after clearing temp folder and remove build directory in project.
Related
hi I am new to app programing, I have a Redmi 1s phone. so to load my app fro android studio I connected y phone and clicked the play button. everything looked good but the app didn't install giving the following error.
if the app is already there uninstall it, even though this was the first time I clicked play, any how I clicked on uninstall and checked the error report I showed me this .
06/19 10:36:55: Launching app
$ adb push C:\Users\ubrbcca\AndroidStudioProjects\HAPPYBIRTHDAYAADHYA\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.example.android.happybirthdayaadhya
$ adb shell pm install -r "/data/local/tmp/com.example.android.happybirthdayaadhya"
open: Permission denied
open: Permission denied
pkg: /data/local/tmp/com.example.android.happybirthdayaadhya
Failure [INSTALL_CANCELED_BY_USER]
Error while Installing APK
plz help me out
Check the followings:
Go to Settings -> Permissions -> Install via USB: Uncheck your App if it's listed.
Go to Settings -> Additional Settings -> Privacy: Check the Unknown Sources option.
Finally go to Settings -> Additional Settings -> Developer options: Check the Install via USB option.
And
Turn off Miui Optimizations on Developer Settings, then Restart the phone.
I'm following some tutorials about building apps in Android Studio, but for some reason it's not launching/installing the latest version of my app when I click 'run'. I have to manually uninstall the app on the phone and then click run after making changes in Android Studio for the app to get updated. Any ideas?
Here is the console output:
Waiting for device.
Target device: htc-htc_one_m8
Uploading file
local path: /home/brandon/AndroidStudioProjects/JustJava/app/build/outputs/apk/app-debug.apk
remote path: /data/local/tmp/com.example.android.justjava
No apk changes detected. Skipping file upload, force stopping package instead.
DEVICE SHELL COMMAND: am force-stop com.example.android.justjava
Launching application: com.example.android.justjava/com.example.android.justjava.MainActivity.
DEVICE SHELL COMMAND: am start -D -n "com.example.android.justjava/com.example.android.justjava.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.android.justjava/.MainActivity }
Waiting for process: com.example.android.justjava
Connected to the target VM, address: 'localhost:8638', transport: 'socket'
Disconnected from the target VM, address: 'localhost:8638', transport: 'socket'
No apk changes detected. Skipping file upload, force stopping package instead.
Android Studio thinks that there are no changes and doesn't install the new APK. A workaround is to disable the "Skip installation if APK has not changed" option in Run > Edit Configurations.
I'm using Android Studio 1.4
Source: https://code.google.com/p/android/issues/detail?id=160901
Android Studio thinks that there are no changes and doesn't install the new APK. A workaround is to disable the "Skip installation if APK has not changed" option in Run > Edit Configurations >Android Application > app >Miscellaneous .
Then uncheck "Skip installation if APK has not changed".
Another problem like this is instant Run you can manage it by :- Just go to "File -> Settings -> Build, Execution, Deployement -> Instant Run" and just disable it. With this Android Studio builds from scratch each time but it's better than not building it right.
This is actually a bug
you can find more info Android Open Source Project - Issue Tracker
Disabling instant run option in edit configuration and adding -r flag to the install flags is best work around for now.!
option in Run > Edit Configurations >Android Application > app >Miscellaneous . Then uncheck "Skip installation if APK has not changed".
THEN --> option in Build > clean project and rebuild project
and reinstall APK in your device.
THIS WORKS FINE FOR ME, HOPE THIS HELP OTHER ALSO
Another reason why the app might fail to install/start is if you've set up a "work profile".
The app might still be installed in your "work" profile and thus won't be re-installed nor uninstalled when starting through Android Studio. The "main"-profile portion of the app is "disabled" though and thus the activity can't be started.
Solution: manually uninstall the work-app, then redeploy from Android Studio.
Sometimes when I get this I just kill the app on the device, then run it. Throw in a log statement to clarify you're on the right build, just something that you know you changed for this build.
I have tried all of above solution but didn't work for me.
I solved by Opening a new project or some other existing project (being in current project) in a new window and then I closed the previous one..
I opened again the previous one and clicked on run and it worked for me like a charm..:)
Run on a Phone
Set up your device as follows:
Connect your device to your development machine with a USB cable. If you're developing on Windows, you might need to install the appropriate USB driver for your device. For help installing drivers, see the OEM USB Drivers document.
Enable USB debugging on your device by going to Settings > Developer options.
Note: On Android 4.2 and newer, Developer options is hidden by default. To make it available, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options.
Run the app from Android Studio as follows:
In Android Studio, click the app module in the Project window and then select Run > Run (or click Run in the toolbar).
In the Select Deployment Target window, select your device, and click OK.
Please refer the link
I've built a silly app to share among a few friends. No need to put it up on the app-store.
I built the first apk (signed), uploaded it to a web-server and all worked well.
A small issue arose, I fixed it, re-built, signed with the same keystore and uploaded it again. It now seems that I am unable to install from the new apk. The debugger tells me:
signatures do not match the previously installed version
So I uninstalled the old version by opening the app drawer and dragging it onto the "uninstall" button. When opening "Settings -> Apps", I don't see it anywhere anymore. I don't see any traces of the app on my device.
Yet I still get the above error message.
Is it possible some information still lingers on the device somewhere? Is there any way I can verify that?
Yes It is possible if somehow your old application is not removed 100% or its data is not removed.
Try:
adb uninstall "com.yourapp.yourapp"
If you don't know exactly what to put as replacement for "com.yourapp.yourapp", then you just open Android studio, Run your app while it is connected to a device and then look at Debug window.
It says:
Waiting for device.
Target device: samsung-sm_t531-xxxxxxxxx
Uploading file
local path: C:\Users\myapp\app\build\outputs\apk\myapp.apk
remote path: /data/local/tmp/com.myapp.myapp
Installing com.myapp.myapp
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.myapp.myapp"
pkg: /data/local/tmp/com.myapp.myapp
Success
com.myapp.myapp in this case is the name of the package you must use to uninstall.
I had the same issue and the adb uninstall solution did not work for me.
What worked was
On your device go to to Settings->Apps
Select your app, and in the menu select "Uninstall for all users"
Even if I had previously uninstalled the app it was still in the list there.
To me, if the app is meant to be distributed, the adb solution is a no-go: you can't ask one's friend to have the android sdk installed on their machine !
The way to go here is to edit the AndroidManifest.xml and to increment the android:versionCodeattribute in the <manifest>tag (which is the root element).
This would update your installed application
If you are seeing this while conducting connected tests, make sure to include .test when uninstalling via adb because uninstalling via app -> settings does not get rid of the test package
adb uninstall your.broken.package.test
if you just uninstall via
adb uninstall your.broken.package
your test package will still be there. This was only something i noticed while using the gradle command line, haven't come across this problem within android studio
Uninstall the old app from your phone or emulator and try to run again.
I got that error while trying to install release while signing it's certificate.
fixed with the :app Gradle task uninstallRelease and then installRelease again
If you are going in install the same app with a different signature, you may want to uninstall but keep the app's data.
adb -d shell pm uninstall -k <packageName>
adb -d install -r -t -d app.apk
For Unity users who come to this question, the best answer is indeed the one above by #Ehsan
adb uninstall "com.yourapp.yourapp"
I had already installed a previous version on my Android device then selected Development Build in Unity > Build Settings which caused the APK to use a different signature. If you install through the Android GUI it doesn't actually remove everything so you have to use ADB.
I had face same problem With POCO Mobile and Moto G30 Mobile while developing application in flutter
My Solution is:
I have open android project which automatically create in your project, in android studio and run project in connected device. It will automatically ask to uninstall old app with same package name and different signature. After click ok button it will install app.
Im trying to run an application on my GS5 from android studio and Im getting this:
Waiting for device.
Target device: samsung-sm_g900v-f3af9744
Uploading file
local path: D:\Android\Projects\TestProject\build\outputs\apk\TestProject-debug.apk
remote path: /data/local/tmp/com.brian.testproject
Installing com.datascan.mobilescripts
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.brian.testproject"
Aborted
It seems to be copying the file to the device, I can see it in the /data/local/tmp directory. Its just failing at the "pm install" stage.
On the phone I turned on USB Debugging and authorized the computer. Here is what I get when I run ADB devices:
D:\Android\sdk\platform-tools>adb devices
List of devices attached
f3af9744 device
So that seems to be correct. Im not really sure what the problem is. Google search on the problem didnt give me any relevant results.
Does anyone know how to get more information beyond "Aborted"? Any help is appreciated, Thanks!
EDIT:
As suggested by #AlexP. I ran "adb logcat -d -s PackageManager:*", this was the result:
D:\Android\sdk\platform-tools>adb logcat -d -s PackageManager:*
--------- beginning of main
--------- beginning of system
Not much help, but I did decide to watch the logcat as the pm install was being run and I found this error entry:
Tag=appproc | Text= ERROR: Could not find class 'com.android.commands.pm.Pm'
Tag=art | Text= art.runtime/thread.cc:1105] No pending exeption expected: java.lang.ClassNotFoundException: Didn't find class "com.android.commands.pm.Pm" on path: DexPathList[[zip file "/system/framework/pm.jar"],nativeLibraryDirectories=]/vendor/lib, /system/lib]]
Followed by a whole slew of art error entries.
So it seems as though my phone is missing something, maybe?
The reason that Android Studio fails on Galaxy S5 is because the adbd (ADB service on the phone not your PC), on rooted version of this phone does not run as root, which is a security measure. You can verify this by manually trying to execute the Android Studio apk and execute commands on the device and finding out that they are failing to execute, but retrying them using "su ..." and see that the app installs and starts on the device. There are three options to resolve this and unblock Android Studio:
Options:
Flash a ROM that includes the modification - not desired as from my understanding you would like to stay on the stock image; also a good security measure not to have adbd running as root all the time. Older roms fall in this category as well, but then you are missing Stock Rom updates and security patches.
Create a custom boot.img and flash it to your phone - this is basically a custom kernel and not desired for a similar reasons than above option 1.
Restart adbd on your device with root privileges when doing app development - preferred and achievable fairly easy thru various methods including:
Preferred Solution:
a. Restart adbd with root privileges (insecure mode) by killing the service on the phone and using a terminal app or so to restart it using "su". After you are done with your app development, restart your phone and adbd will be back in secure mode, restoring the security measures.
b. Use Chainfire's ADB insecure app, which is free on XDA (download/link below) or pay for it on Google Play to support his work. You can toggle the mode in the app. In the app, you also have an option to auto re-enable the insecure mode on reboots.
References:
https://android.stackexchange.com/questions/5884/is-there-a-way-for-me-to-run-adb-shell-as-root-without-typing-in-su
http://forum.xda-developers.com/showthread.php?t=1687590 (includes free download link)
https://play.google.com/store/apps/details?id=eu.chainfire.adbd (for supporting Chainfire's work)
Possible Solutions :
1. Check if your app had left any datas :
First if the app is already installed, then clean cache data and uninstall it
Under "System Settings" then "Application Manager"
http://i.stack.imgur.com/b3oys.jpg
Then
Force uninstall by running & adb shell pm uninstall com.brian.testproject
Check "/data/data/com.brian.testproject/" and delete it
Remove any entries of your package on /data/system/packages.xml
Remove any entries of your package on /data/system/packages.list
Also you could install SDMaiD and clean your device, especially with "CorpseFinder" and "AppCleaner"
2. Try to install the app manually and debug the result :
In your case you have an issue with pm over android studio... install it manually to have a more detailed message over command line
$ adb push D:\Android\..\TestProject-debug.apk /sdcard/myapp.apk
$ adb shell pm install /sdcard/myapp.apk
3. Check Android Studio and your app sources
Change the targeted api level :
Right click on your app dir + Open Module Settings + app + check sdk version + change target and minimum under "Flavor"
Sync gradle button
Rebuild project
https://www.youtube.com/watch?v=v4b7C6Q-9dI
Update your android studio if you don't have the last release
If your app use libraries, you have to recompile them.
4. Check System Settings :
Check BOOTCLASSPATH of your init.rc. BOOTCLASSPATH must include /system/framework/ext.jar and /system/framework/framework.jar and so on.
Check DEXPREOPT_BOOT_JARS of build/core/dex_preopt.mk. DEXPREOPT_BOOT_JARS must include ext and framework and so on.
The order of all items on BOOTCLASSPATH must be equal to the order of all items on DEXPREOPT_BOOT_JARS.
5. Try pm command directly on the device :
if pm command does not work try that command with a terminal directly on the phone to see if it's a connection issue between pc and phone
pm install /sdcard/myapp.apk
6. Reinstall your rom once again (just reinstall it) no need to erase.
For anyone having this same issue, unfortunately the only solution that I could find was to downgrade my ROM version (to OA8). Once I did that, adb works perfectly. If anyone finds a better solution I'd be definitely like to know.
Android Studio
step 1: Go to file--> invalidate and restart.
step 2: Clean and rebuild project.
step 3: go to project folder run
gradle clean
step 4: restart phone/Emulator.
Done !!!
I try installing my app for the first time on a Nexus 5.
The android studio then tells me I need to uninstall my app inorder to install it (The app never exsited on the phone) and then asks me to unistall the app, I agree and he tries to unistall but an error occurs:
Waiting for device.
Target device: lge-nexus_5-08a9df88021f8ec8
Uploading file
local path: D:\USER\Desktop\Yoav\AndroidProject\Example\app\build\outputs\apk\app-debug.apk
remote path: /data/local/tmp/com.example.user.example
Installing com.example.user.example
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.example.user.example"
pkg: /data/local/tmp/com.example.user.example
Failure [INSTALL_FAILED_DEXOPT]
At this part the studio asks me to uninstall after pressing ok:
DEVICE SHELL COMMAND: pm uninstall com.example.user.example
Unknown failure
I think it's because the app does not exsit on the phone, but if the app does not exsit why does it even want me to delete it?
It might be because of the package name. Check weather is there any app with the same package name that you created before. com.example is not a good practice to use for you practice projects even.
I may be not right but from the information provided this is what I can say.
It happenes because the .apk you built and are trying to install is missing the classes.dex file. This can happen for various reasons but most of the time (for me) the build process gets stuck somehow.
Open Task Manager and kill all following processes:
cmd.exe
conhost.exe
find_java.exe
Then clean and build your project.
Also make sure you use latest Build tools (now 21.1.1).
I had the same problem. I finally had to reboot the device to solve it.