Cannot run installDebug target - "Unable to upload some APKs" - android

I have created a blank activity project in Android Studio on Ubuntu 14.04. I can do a gradle build and install it to my device in one step using the installDebug target.
I wanted to work with the Nest API though, and I can't get the installDebug target to work. As a start, I downloaded their sample project and tried to build and install it in one go. I get this:
:testapp:installDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':testapp:installDebug'.
> com.android.builder.testing.api.DeviceException:com.android.ddmlib.InstallException: Unable to upload some APKs
I created an app largely based off of this sample which also isn't working. Does anyone know how to fix this? What's weird is - it used to work at some point!!
I tried blowing away my Android SDK and re-installing everything, and also re-cloning the project from Nest's git repo and starting over. It's not working anymore.

I am extremely pleased I have figured out a solution to this problem.
I started to notice something was more seriously up with my adb connection because adb shell for example would just hang.
I neglected to mention it, but I was using Ubuntu 14.04 in Oracle Virtualbox as the guest to a Windows 10 host. I think that may have something to do with it.
In VirtualBox, I went to Devices > USB > USB Settings and under Enable USB Controller I enabled USB 2.0 (EHCI) Controller. Previously this was set to 1.1.
My guess is if the application is large enough, USB 1.1 is too slow to transfer all of the data in a timely manner.
I hope this helps someone in the future.

it could be because of three things:
If you are using a device, your device is not plugged in correctly. Make sure you can see it when you run adb devices on the commandline.
If you are using an emulator,the emulator is not running or it has not booted up yet.
Your app is configured to use a buggy version of gradle. Version 1.3.1 is well known to cause this problem.
The most likely cause of this problem will gradle version 1.3.1.
In my experience, upgrading gradle did not fix the problem. To fix it, I had to downgrade it to a rather memorable version of 1.2.3.
Look for com.android.tools.build:gradle:1.3.1 in the android/build.gradle, and update it to com.android.tools.build:gradle:1.2.3.

I had another program that was using the adb and was interfering with the build.

Related

Android studio - not able to install apk

I am trying to install apk from android studio. Initially I got below error:
So I disable instant run as suggested in many post on stackoverflow like this How To Stop Installation of Multiple Slice APK In Android Studio 2.3.
Now I am getting below error after disabling instant run:
java.io.IOException: An established connection was aborted by the
software in your host machine Error while Installing APK
I have only one instance of android studio running when I got this error.
Android studio version is 3.3.1. What can be cause of above error.
Also I am not able to install apk using adb install command. I am getting message failed to install apk with no detail message.
You can restart Android Studio : File -> Invalidate caches/restart
And i think you install ADB-Idea pluggin to uninstall or clear app data very easy with shortcut.
ADB-Idea pluggin :
Link
So I found out why I was not able to install apk from studio or from adb install command. Issue was due to my pc usb port was blocked by network administrator of our organization as my usb port usage period expired. So if anyone facing issue of not able to install apk and getting error as mentioned in question and no solution working for you than please check if your pc ports are not blocked by your organization network admin. I took approval to use usb port and it is working now.
You have got the first error because of :
You are testing your project_A on a emulator_E
As you had the app project_A, installed on the emulator_E, in previous run.
Now you started the execution of your project_A, again on the emulator_E.
The Android_Studio and emulator_E, both came to know that, the apk is already on the emulator_E, so just, whatever the new changes are, will be synchronised, within the, already available project_A apk, on the emulator_E.
But as the whole process takes some time, you uninstalled the apk of project_A on a emulator_E.
And now project_A on a emulator_E is not there, but Android_Studio tried to synchronised it, which leads you to the ERROR_1
Solution
You are following many approaches, for the same thing.
You are starting your project, project_A on the emulator_E by :-
via ADB INSTALL from the command line too
With Instant Run too
With Instant Run too
And you are not keeping the previous apk as it is there on the emulator_E, after starting the execution too.
Uninstall it from emulator_E, but before you start the execution for emulator_E. Which lead to your Android Studio to some dangerous STATE_A and, Android Studio is not tested by google for such types users
It may seem harsh, and obviously it is not the answer, but this is the exact problem, which is leading you to the such case.

Android Studio 3.0.1 Gradle issue (Error: The first result from the daemon was empty. Most likely the process died immediately after connection)

I have recently been encountering this issue to the point where I cannot continue working. When starting Android Studio Gradle builds as normal but as soon as daemon starts it fails and I get the Error:
The first result from the daemon was empty. Most likely the process died immediately after connection.
I have done a number of different things and I have searched all over the internet trying to find a solution for this issue so I can work on some projects I have but so far I have not had any luck. A few of the links I tried using to find a solution are:
Android Studio gradle build error: 'The first result of the daemon was empty.Most likely the process died immediately after connection'
Gradle sync failed: The first result from the daemon was empty. Most likely the process died immediately after connection
https://teamtreehouse.com/community/first-result-from-daemon-was-empty-gradle-build-continues-to-fail
https://www.jianshu.com/p/5891e7d46f6c
I have tried everything in those links and no matter what I do it does not work. I was so desperate to the point where I uninstalled Android Studio Gradle and all the SDK hoping that would fix it and that didn't do it either. I figured hey maybe it's another issue so I thought doing a clean install would do the trick and guess what it worked for a day or two and right after that back to the same place I started at now... (Worst part is I had to download over 200gb for the clean install due to all of the things I had to reinstall).
I am attaching a picture below in case anyone wants to see the original Gradle:
Android Studio Gradle Screenshot
I found the solution after installing and reinstalling the operating system and everything on it about 4 different times. So the issue was the network driver and the software it seems like. Every time after the network driver is updated using driver website it crashes and renders the network useless.
After a while looking at the logs I finally noticed a pattern that Gradle was having issues with something involving the actual network adapters and so what I did was uninstall the network software and uninstall all of my network adapters driver and restarted the computer and had Windows 10 reinstall the drivers. I opened the Android Studio and it works flawlessly. So at the end of the day, the basics saved the day.
In case anyone is wondering which network devices I have they are the:
Killer E2500 Gigabit Ethernet & Killer Wireless-n AC 1535 Network Adapter
The software is the killer network manager.
I had the same problem with the Killer network interface. The motherboard I'm using has 2 gigabit NICs and a wireless adapter built into it. One of the two gigabit ports is Intel.
I believe the problem is with the Killer gigabit port/ Drivers. To get around it I just disabled the Killer E2500 Gigabit Ethernet port and restarted Windows. Gradle and Android Studio are now working without issues.
Also the mobo I'm using is a Gigabyte X299 Aorus Gaming 7.
Seems they fixed it with the latest Killer driver:
"KillerPerformanceSuite_1.5.1847_Win7_Win81_Win10_x64"
Just tested it and it seems to be working.
Had the same issue, and the culprit was also Killer-related software as mentioned in the other answers, after uninstall the software (from Store and through the Control Panel), then uninstalling the drivers, then restarting.
Then, it started to work again, but I just randomly decided to try installing the Killer Drivers+Software again through KillerPerformanceSuite_2.0.1175_UWD_x64, but it broke Gradle again, so I decide to do all those steps again, but after uninstalling the software (through Control Panel), I decided to check Android Studio if it would sync properly this time, and it did.
So the culprit might actually just be the software (Killer Network Manager).

Session 'app' error while installing APK

I am having difficulty importing a project written on Android Studio 1.1 into Android Studio 2.1.2. I keep getting this error whenever the gradle is building before testing the app on a tablet. Below is a screen shot of the error. Does anyone know what the problem could be?
I have tried adb kill-server followed by adb start-server as well as some other gradle versions compatible with the project. Other than this, I have not been able to find many more suggested solutions to the problem ("session 'app': error installing APK").
Additionally, I have tried uploading a basic Hello World project which successfully built the gradle.
Error message from Grable Build
I was facing similar kind of problem.There is image of error attached.Error is highlighted in red.
Turning off the Instant run removed error for Android Studio 2.3 and 3.1.4.
Best step to resolve this error is-
Uncheck the instant run in File >Settings >Build,Execution,Deployment > Instant Run
Note: The top answers recommend to disable Instant Run. Try this before exploring my listed solutions to prevent wasting more time than needed.
Here are some possible solutions:
1) Make sure that your phone is properly connected to your PC with a USB cable: Before going over these fixes, make sure that you have at least connected your phone to your computer properly. If it's properly connected, your phone should be charging.
2) Make sure that your device's driver software is up-to-date: Simply go to your File Explorer and then right click Computer. Then, select Manage (requires administrator privileges). In your Computer Management window, find a tab on the left pane that says Device or Device Manager. Search for your device from there. Mine was under Portable Devices and the name started with SAMSUNG, so finding your device shouldn't be too hard. Right click the device, and then select Update Driver Software.... I chose the Search automatically for updated driver software option, since it's much easier.
3) Enable USB debugging under your Developer Options: For my Samsung Galaxy S9, I found mine under Settings > Developer Options. From there, enable USB Debugging. If you can't find your Developer Options, find your build number within the settings and tap it 7 times consecutively. I found mine under Settings > About Phone > Software information.
4) Make sure you've allowed USB debugging for your specific computer: Although you may have your USB Debugging option enabled, you still need to allow USB debugging for your specific computer. A popup should appear asking Allow USB debugging? and providing the computer's RSA key fingerprint. Before pressing OK, make sure your check Always allow from this computer, so that you don't have to go through this again in the future. If you think you've done this but yet your device is still marked as OFFLINE, select the Revoke USB debugging authorization option in 'Developer Options'. Then, re-allow your computer for USB Debugging. If the popup doesn't appear, reconnect your phone to the Computer (pull the cable out and put it back into your Phone).
5) Trying cleaning AND rebuilding your project: In Android Studio, open up the Build tab at the top left and try both the Clean and Rebuild options.
If none of the above works out: Reinstall Android Studio by Uninstalling the program and re-downloading the setup file here. Scan for any viruses that may be affecting your computer. Check for any sort of error while reinstalling Android Studio. If none of the methods presented in this answer work, fetch for support here.
Good luck.
Follow this steps to overcome the issue.
Disconnect all devices connected to System/Close all emulators
running on System.
Turn Off Instant Run feature from settings.
Perform a clean build.
Turn ON Instant Run feature from settings.
Perform a clean build.
Connect your device/start your Emulator and ensure it is online.
Run the Project by selecting the device/emulator.
NOTE:-
1) You should not have different instances of Android Debug Bridge(adb) running on system.
2) If using Genymotion then make sure that you use the custom sdk path mentioned in the Genymotion settings the which you mentioned in the settings of Android Studio.
Follow all the steps and I am sure you will get the issue fix.
You can clean your project with gradle wrapper of your project. In linux:
$./gradlew clean
In windows:
>gradlew.bat clean
This error happens due to Gradle not synced with the project. go to Tools- Android- Sync Project with Gradle files. Then Run it again.
On newer Android Studio versions, go to File-> Sync project with gradle files
Very Simple.
Follow this :
Build -> Clean Project
Then
Build -> Rebuild Project.
This is a terrible problem, i have facing it so much time, First of all when you run on emulator or real device please make sure that it is not show device is offline in Android monitor, see picture below due to bad cable connection device is showing offline, so make sure first that it is online.
If it's Okay then clean your project and Rebuild your project. You can do it from Build -> clean project / Build-> Rebuild project
Still problem occurs then try to Restart android studio. This is generous error happens due to above cases.But i solve it this way as described.
None of the above worked for me, the simplest solution was to go to
File > invalidate caches/restart > invalidate and restart
This issue seems to be bug in Android Studio.
I tried all other workarounds but the issue was appearing randomly.
I also have custom named apk for output. But Android studio was randomly picking custom apk name and default apk name.
Adding Gradle-aware Make solved the issue.
Following are the steps.
Menu Run -> Edit Configuration
Select "app" configuration
Add Gradle-aware Make to Before Launch actions
You are done.
Following article helped me in finding the solution
https://android.jlelse.eu/android-studio-3-1-how-to-fix-it-b49f72eb054f
It's a bit late for reply but, i've figured out how to solve this problem on Android Studio 3.1.
You can have "Instant Run" checked, what you need to do it's just to build an APK
and then retry to Run your app.
Hope this help!
In my case, my project location contained the special character.
E:\Android_Projects\T&PUIET,KUK\app\build\outputs\apk\app-debug.apk
close android studio > rename folder containing the special character(here T&PUIET,KUK ) > restart android studio.
Hope this Solution helps!
Clean and Rebuild is working fine for this problem and it is good also than other solutions.
In my case my device didn't have enough memory. After trying out a number of the suggestions here, I finally noticed the notification on my phone about low memory. The notification had been there for hours apparently.
I could install app on Nexus, but couldn't on Samsung. Nothing helped me except the change of the USB cable.
mi users if you are facing this type of issue follow these steps:
Step 1 : generate developer options as follow
Settings>>About Device>>Click 7 times on MIUI Version>> It will Generate Developer Options.
Now Enable Following...
Step 2: Setting>Additional setting> Developer options> Enable USB Debugging
Step 3: Setting>Additional setting> Developer options> Enable Install via USB
Note: Its Will get Enable Only If You Insert SIM In MI Device/Phone.
Step 4: Setting>Additional setting> Developer options> Enable Verify apps over USB.
all done now run the project and test....
non mi user:
just enable once instant run options from the settings--> Build,Execution, Deployment-->Select Instant Run and Enable Check Click On OK...
Its Will Work....
Try to this way :
1) In Instance Run is Enable then desable it.
2) Save it and Rebuild the project.
3) Check devices is online or USB debugging On your device.
4) Then Run It App On your devices.
Note :
If you use mobile device is MI (Xiaomi) Then Check :
=> setting>Additional setting> Developer options> Install via USB (ON it)
=> setting>Additional setting> Developer options> USB debugging (ON it)
=> setting>Additional setting> Developer options> Verify apps over USB (ON/Off it)
Trying cleaning AND rebuilding your project: In Android Studio, open up the Build tab at the top left and try both the Clean and Rebuild options.
This problem occurs when you copy paste class and didn't change package name.
Means Package name are different. Build has no problem to build but its problem to install.
After trying the different solutions from the different answers, I tried changing the USB debugging cable, and the problem resolved finally.
In my case, going to Settings>Build, Execution, Development>Compiler>Command-line options and removing the --dry-run flag fixed it for me. Not sure why that was there in the first place, but it solved it for me.
I was facing same problem.Tried every think mentioned here in blog.
But it was basic error to permit device "allow installing app from USB" which did it for me.
I had similar problem. In my device I have two accounts and the app was remained installed in another account. I have deleted app from both of the accounts and it was done.
I was able to resolve it simply by opening the notification bar of the android phone , clicking on "tap for more options" and selecting PTP
i was also getting the same error repeatedly but could not solve it as i am complete new to android development.
But then it came to my mind that the error is appearing because its not able to install the apk in the device as the error says.
So i make sure that my Oneplus3 is in debugging mode and also allowing file transfer when connected via USB.
And this solved the problem.
Also previously it was not doing the instant run but now it does.
So check whether your android device is allowed to transfer files while connected via USB. This might help.
Here is gradle console updates:
5:01 PM Gradle build finished in 1s 252ms
5:13 PM Executing tasks: [:app:assembleDebug]
5:13 PM Gradle build finished with 15 error(s) in 1s 125ms
5:15 PM Executing tasks: [:app:assembleDebug]
5:15 PM Gradle build finished with 13 error(s) in 1s 608ms
5:16 PM Executing tasks: [:app:assembleDebug]
Turning off the instant run(File >>Settings >>Build,Execution,Deployment >> Instant Run), solved my issue
I was using CyanogenMod 12.1 and was building with libgdx when I met with the same error.
Rebuilding didn't work for me.
My phone was connected as UMS or USB mass storage to my PC when I ran the app. Just changed the USB configuration from mass storage to MTP and it fixed my problem.
Looking at the error message, Android Studio tried to install older version of apk (lets say 0.5.1) while current version is lets say 0.5.2. Android Studio builds 0.5.2 but tries to install 0.5.1 for some reason.
I have turned off Instant Run, invalidated and restarted, rebuilt project and didn't help.
Solution worked for me is to uninstall the app, then change the current branch on VCS to some other branch. Then come again to latest branch and Rebuilt, Install the APK again.
You just need to restart your adb.
Instruction for that is given in this Link

GameMaker: Studio Android fail to build ProcessException

I've been trying for the last several days to build and run the GameMaker: Studio Android Google Mobile Ads app demo on my Samsung Galaxy S6. I finally have all the correct things installed I believe, and I've managed to solve a few other build errors before this, but I've hit a brick wall and despite all my searching I have not found an answer. My problem is very similar to this post's which poster said he solved by setting the build tools to the latest version. I don't know what he means by that.
The full compile form is too long to fit in a StackOverflow question, but I believe the only really relevant bit is the exception line:
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\gunna_000\AppData\Local\Android\sdk\build-tools\23.0.1\aapt.exe'' finished with non-zero exit value 1
I've been pulling my hair out with this and any help would be immensely appreciated.
I followed the GameMaker: Studio Android instructions perfectly, with the only hiccup being the local IP address, which is supposed to be in the format xxx.xxx.xxx.0/24 such as 192.168.1.0/24. My IPv4 adress is 10.0.1.129. Not knowing what to do, I entered 10.0.1.0/24 into the Web Server IP allowed list, ignoring the last number. However I do not believe that really has anything to do with this problem, as I'm trying to run the GM:S app on my Android device over USB cable.
I believe I have all the right modules installed in the Android SDK Manager:
And my JDK, SDK, NDK, and Keystore are all accepted it seems:
I've been able to run and install Android apps made in Android Studio from this computer to this Android device (Android version 6.0.1), but GameMaker: Studio is just not having it. (And just to verify, I have bought GameMaker: Studio Professional and Android)
I don't have any weird extensions or plugins. I'm simply trying to run a GameMaker: Studio application on my Android device. Please help. Thank you.
If you still haven't solved this:
Make sure your PC doesn't have a pending Windows update (if you use Windows).
Make sure your phone is in the right mode to accept files and install from GameMaker.
Try to run a very simple project with only an empty room.
Make sure to have all packages up-to-date.
Potentially reinstall the hole Android SDK lib.
Make sure that your device is connected and is found by the ADB.
If GameMaker tries to start the network connection between your PC and the Android device, it means that it failed doing so over the cable.

Gradle gets stuck at either 'build' or 'assembleDebug' when using the 64bit or 32bit version of Android Studio

The issue I've had over the past few months is that Android Studio would often get stuck on Gradle: build, as seen here. Android Studio itself would stay responsive but the build simply wouldn't progress. It also never generates any kind of error, so I can't really post any useful information. Once in a blue moon it might suddenly work, but nothing reliable.
Recently I found a post here on Stack Overflow where someone's Android Studio would get stuck on Gradle: build when he tried to create a new project, and he noticed that this issue didn't exist in the 32-bit version of Android. So I thought, why not try that. Turns out that building isn't an issue anymore, but assembleDebug is, when trying to build the application. As can be seen here.
Of course all these commands work flawlessly when run using command prompt and gradlew.
What I've tried so far:
Reinstalling Android Studio (including the removal of .AndroidStudioProject)
Upgrading Android Studio to the latest version
Removing any build files from projects
Creating completely new projects in Android Studio
Switching from 64-bit to 32-bit Android Studio
I'm running the latest version of Android Studio, using version 19.1.0 of the build tools, gradle v0.11+ and am on Windows 8.1.
Is there anything else I can try? This is starting to become seriously annoying. The last possible solution I can come up with is just doing a complete format and a fresh Windows installation.
I was experiencing the same problem, and the solution was very unexpected in my case: AVAST antivirus was somehow interfering with the Gradle:build process.
Deactivating this antivirus solved the problem!
Because there is no answer to this problem I will share, what I have done, to solve this issue. From what I have seen, the problem is that there is a dependancy(or many) from a maven repo that can not be loaded. So you have to take all dependacy one by one and check if exist on the maven repo.
For example I was having a dependancy for "org.jraf:android-switch-backport:1.3.1" from "http://JRAF.org/static/maven/2" that at that time could not be opened.
My build.gradle looked like this:
repositories {
mavenCentral()
maven {
url "http://JRAF.org/static/maven/2"
}
}
compile "org.jraf:android-switch-backport:1.3.1
For me, this problem occurred when I was USB tethering using an Android device. The first build took anywhere from 5-10 minutes, and every subsequent build took about 3-7 seconds. I found that by disabling USB tethering, the first build completed quickly (and so would all subsequent builds). After the first build completed, I could reenable USB tethering.
If you have a fresh Ubuntu 14.04 with Android Studio 1.5, you may be missing a library. Try this:
sudo apt-get install lib32z1
Another stack overflow answer
It happens 1 in 2 times for me. The hack that works for me is File->Exit and confirm exiting. Then a message shows up telling me that Gradle is running and then all of a sudden the screen to choose the device shows up. I Click NO and all goes well again.
Anyway, still a bummer, but I have not found an answer yet.
My problem was that the Android Sdk executables were missing the executable bit. You can check some of your binaries like /Sdk/build-tools//aapt to see if they have permission to execute. If not you can solve it by running this on the Sdk folder
chmod -R +x ./
If you are behind a proxy on ubunthu you might need to set your gradle system wide proxy:
sudo nano ~/.gradle/gradle.properties
And enter the following entries:
systemProp.http.proxyHost=<Your Host>
systemProp.http.proxyPort=<Your Host Port>

Categories

Resources