When i accessed my app on the browser i have no problem accessing data from API. But when i launch it on emulator on android studio, i can´t. It pops-up a card with a ERROR CODE :0, Message Ht failure with the referent link API.
I tried to add the allow-intent, change the "localhost" on API GET request to "127.0.0.1"... and more that i don't remember.
Even the DATA received by the server side is not accessible. Right now i'm inclined to think that is a proxy related issue or a CORS problem.
Problem Solved: Basically you need to change the url on your project where you do service. Change it from localhost:3000 to 10.0.2.2:3000. The 3000is the port's number, it doesn't need to be 3000. Then you open android studio, open emulator and run it. On the litle tab right next to the android device, theres 3 dots at the end. Press those, then go to settings, and change proxy to 10.0.2.2 and the port number to the one you are using, in this case is 3000. After that it will work. Sorry for late update on the problem!
For more info:
why do we use 10.0.2.2 to connect to local web server instead of using computer ip address in android client
This can sometimes be caused by the emulated device looking at itself, not at your machine. Are you looking at it from the emulated device browser, the Ionic Devapp on emulated device, or built to native on the emulated device? Set any urls on the device to point to your host machine external IP, and allow open networking on the emulated device.
I had this error and searched for days. I have sorted out using capacitor and not cordova.
Launch this command from the project folder:
ionic build
ionic capacitor add
npx cap open andoid
If last command gives error, open the android folder with Android Studios 4
I installed Unity and following tutorial from GoogleAR.
I faced some difficulties and managed till installation of app in mobile by lot of internet search.
Now, the app is installed in my Android mobile by unity, but not opening by itself due to the following error
CommandInvokationFailure: Unable to forward network traffic to device.
Please make sure the Android SDK is installed and is properly
configured in the Editor. See the Console for more details. /home/_____/Android/Sdk/platform-tools/adb -s "number" forward "tcp:34999" "localabstract:Unity-com.example.helloAR"
What causes this issue and how to overcome it?
Note that I did un-check Development Build, but still not working.
Looks like a bug in UnityEditor on Linux, where it opens port 34999, and adb fails to do the port forwarding because it's in use.
https://issuetracker.unity3d.com/issues/android-linux-unable-to-forward-network-traffic-to-device-when-trying-to-build-and-run-a-development-build
While it's being fixed, workarounds:
The app should be successfully installed to the device, so you can run it manually from the Apps menu.
Close Unity editor, run adb forward "tcp:34999" "localabstract:Unity-com.your.packagename" and open the editor again. This way you make the port used by adb so that later it works when building.
For Windows: just kill adb.exe and Build&Run again. Work for me every time :) You don't even need to restart the Editor.
Ctrl+Alt+Del -> Task Manager
kill this task
On Windows, I was able to fix the issue by simply restarting the Editor.
I'm using windows 10 and android studio 3.0.1.
In past, I was able to use internet at my Android emulators but now, I'm not !
I saw similar topic in stackoverflow but answers not working for me,
what should I do ?
try this command on windows cmd while replace the path with your own.
C:\Users\prashant\AppData\Local\Android\sdk\emulator\emulator.exe -avd Nexus_5X_API_25 -dns-server 8.8.8.8
If this doesn't work try genymotion, it's best. Here
Finally I found the answer!
I'm using proxy in my android studio and emulators by default using android studio proxy setting too!
I just disabled proxy in emulator and problem solved!
you need to enable your internet conection to share with another conected devices, once you do it restart the emulator and you got internet
this works for windows
go to your conection properties
go to sharing tab
click in "Allow other network users to connect through this compueters connection
I had this issue and finally I realized the problem is because of my firewall (Kaspersky).
Go to in firewall application settings and search 'Android studio'.
You may find several applications with the same name, allow all of them to access Internet.
For me, there were 2 apps including JetBrains extension, which i had blocked long time ago!
This problem appeared out of nowhere for me after updating Android Studio to Chipmunk. After a great deal of searching and trying different solutions, I found one on Medium.com that solved it! This is a very similar fix that Prashant posted (setting the DNS server to 8.8.8.8), but it gave a step-by-step solution without using terminal, and included adding 8.8.4.4 as well.
DNS fix for Windows or Mac
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
on android 6.0.1 I am getting this error when trying to use run-as.
⋊> ~ adb shell 14:29:01
shell#trlte:/ $ run-as org.ligi.passandroid
run-as: Could not set capabilities: Operation not permitted
I really like the run-as command - is there a way to get it to work on 6.0.1 ?
If you have a SAMSUNG device, don't bother - SAMSUNG broke run-as by dropping the setuid flag (so run-as has no chance of switching to a different identity).
Also don't bother trying the Smart Switch "reinitialize device" workaround, it won't work until SAMSUNG fixes it in the firmware (so it is worth updating to the latest version).
Use some other method to access your app's data, like adb backup:
adb backup -f data.ab <my.package>
dd if=data.ab bs=24 skip=1 | openssl zlib -d > data.tar
Instead of dd you can use the abe tool, which can also write .ab files.
For me, it went like this. I am using Samsung s6 API 24. The error list log's detail was the same as mentioned in the question. But when I checked the Build Logs I found the solution written there. To set the MSBuild. So I followed the following steps to resolve this and the app ran successfully.
To correct this problem I had to
Unload Android Project from solution explorer
Right-Click unloaded project and "Edit Project File"
Searched code for "EmbedAssembliesIntoApk"
Found the occurrence in the project file
<EmbedAssembliesIntoApk>false</EmbedAssembliesIntoApk>
Change it to true and reload the project.
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
Ran the app and the app starts running on Samsung s6
The solution for me was the parameter -autolaunch in the Debugger configuration of the project in the field Parameters.
I use Delphi 10.2 with S7 Edge Android 7
Unlike another answer here, I have also tried to use smart switch & hard device resetting, but unfortunately that approach did not work for me (Wasted extra one hour just to try out that approach). Besides not working, it might create additional problem "samsung account: session expired" - problem, which can be fixed only if you have root access to your device.
I by myself have used instructions from here:
https://www.youtube.com/watch?v=Sy4FWLHxGYs
and then from here:
https://www.tomsguide.com/us/samsung-galaxy-s6-guide,review-2856-3.html
for getting root access to your device, and after that run-as can be executed with additional command "su -c" as for get root user. So whole command will look like this:
su -c run-as org.ligi.passandroid
WARNING: Gaining root access to your device will most probably void your device warranty if you have any left.
Additionally to this, I wanted to be able to debug my application inside Samsung Galaxy S6, so I've altered Visual studio components, more instructions can be found here:
https://issuetracker.google.com/issues/37093233#comment53
If you happen to have Samsung based android device - I have already reported that bug to Samsung, but I've could not get any time schedule if when and if at all they are going to fix this issue. If you own some other Android device - makes sense to report this problem to manufacturer.
I was working from Delphi 10.1 berlin.
I was presented with the same problem and my solution was to configure the sdk to the previous version.
I was using Android SDK 25.2.5.32bit and downgraded to android SDK 24.3.3 32 bit. To configure:
Tools->Environment Options -> SDK Manager
Then, add the necessary sdk, in this case android SDK 24.3.3 32 bit.
#RustyX answer helped my partially. zlib didn't work in my Mac. So I had to use the Android Backup Extractor to convert .ab file to .tar file. You can download it here.
For the full step by step instruction, refer here.
In Visual Studio, App properties, Android Options, changing the debugger from C++ to .Net(Xamarin) seems to have fixed the problem for a mixed C++/C# app.
Also got this error today when I tried to deploy/debug my application on a Samsung Xcover 3 running Android 6.
I solved it by changing the project property "Android Options / Use Fast Deployment" to false.
Here is solution for MS Visual Studio 2022.
https://www.youtube.com/watch?v=_r9GLm0k55o
Just uncheck the "Use Fast Deployment".
I had previously posted an answer here which was deleted, maybe because it was a link to another stackoverflow question referring to the answer I gave there, instead of containing the full answer.
Reposting its contents here from https://stackoverflow.com/a/43242739/7823460:
I had a very similar issue on Samsung Galaxy S6 Edge, trying to start debugging on VS2015, I got a different error, much less verbose than in the attached screenshot:
run-as: Could not set capabilities: Operation not permitted
Based on the contents of the attached screenshot above, I tried 'initializing' / factory resetting the device using Samsung's Smart Switch and it actually fixed the 'run-as' issue I was having.
This is the only solution which worked and didn't involve rooting the device, so I believe it must be publicly available. Of course people attempting this should keep in mind that factory reset means that data will be lost, unless it's backed up. The same Samsung software helps with backing up your data.