CommandInvokationFailure: : Unable to forward network traffic to device in Unity - android

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.

Related

The game crashes after the build for android

I have a problem with the game crashing after the build. If I run the game in Unity, then everything works. And when I build it on android, when I start the first training scenes work fine, but when I reach the main stage, the game crashes. There is a error in Unity:
Google.JarResolver.ResolutionException: Cannot find candidate artifact for com.google.android.gms:play-services-games:8.4+
Maybe that's the problem. If that's not the problem, how do you know what it is?
So this looks like plugin resolve problem. But more information wouldnt be bad and you should learn how to see your device logs on Android. Here is how:
You should check the logs of your mobile device in the moment of the crash. You can do it by using "adb logcat".
First you should download SDK Platform Tools.
Then, enable USB debugging on your phone.
Connect your phone to your PC and give the permission it needs. It will ask you when you first connect it.
Open command line on your computer, go to your SDK Platform Tools folder, copy the directory and paste it after writing "cd " to your command line
Now you can use adb to figure out your Android crashes. To filter the ADB you can use
adb logcat -s Unity ActivityManager PackageManager dalvikvm DEBUG
This way you will only see Unity related logs from your device.

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 Logcat is empty when debug with device in android studio

When I try to debug using android device in android studio Logcat shows nothing. But when I use emulator LogCat shows all the messages. How should view the Logcat messages when debugging on actual device?
Thank You !
In Android studio 0.8.0 you should enable ADB integration through Tools -> Android, before run your app. Then the log cat will work correctly. Notice that if you make ADB integration disabled while your app is running and again make it enable, then the log cat dosen't show anything unless you rebuild your project.
Restart the phone. And it solves magically
I was using Lenovo A7000plus powered by Android 6.0 M and found out that my Android Studio was unable to record the debug process, but somehow other's phone debug report could be recorded. Plus, I tried use Memu emulator and it recorded normally.
Strangely, that device was recognized by Android Studio and ready to be debugged, but no recorded debug report at all from all application that ran on the device. Of course, USB debug was tuned on.
What I did before, I turned off Developer option on that phone in order to play my favourite mobile game (F/GO) which forbids USB Debugging is turned on in the device.
A few hours later, after trying any method in Internet and not success, accidentally I found simple but strange solution that is Restart the phone. I restarted the phone while it was connecting to PC, and somehow the logcat showed all debug process in Logcat like normal.
It sounds like non-engineering solution at all, but that's really work for my case.
As of 0.4.0 I have noticed that the logcat tab does not work in the debugger window - only in the Android DDMS window (hit Alt+6 to bring up the working logcat while debugging). Awkward I know :)
In Android studio 1.0.2 or later: you should enable ADB integration through Tools -> Android, before run your app
In Android studio 1.* if logcat messages have disappeared for me helps the next trick:
Tools -> Android -> disable )) "enable ADB integration" (if it've been enabled)
Tools -> Android -> enable it again "enable ADB integration"
In 0.8.2 the DDMS window doesn't show up. However restarting the adb logcat windows by pressing Alt+6 (Twice, if it's already opened) fixes the issue. It worked for me.
I understand that this question is over 2 years old, but from my searches a few people are still having a persistent problem with this. One possible solution to this (which worked for me after two hours!) is that your phone settings may have its "Log Switch" set to off, hence it isn't sending your log data to the IDE.
Here is the solution - "Unable to open log device '/dev/log/main': No such file or directory"
Hope it helps!
If anyone's still having trouble with this despite trying all the answers here, just use System.out.println instead of log.* and your debug messages will output.
Updated: I finally got the cause of the problem in my case. If I switch of my device's wifi, the log shows. Otherwise, the log will not show. I tried several times and it the always show full logs when I turn off my wifi.
My device is: Gsmart Classic, OS: Android OS, v5.1 (Lollipop). I met the problem when I updated the gradle build tool from 'com.android.tools.build:gradle:2.0.0-alpha1' to 'com.android.tools.build:gradle:2.0.0-alpha3' in Android Studio 2.0-preview. After trying all the solutions with no luck, I tried un applied all the instant run choices and re-apply it again. Then the logs show up.
Note: if it still doesn't help. You can as well try to switch back-and-forth the back ground process limit. Unfortunately, I couldn't reproduce the error.
In Android Studio 2.x I used to have to restart to get it working but often switching back and forth between the applications works or running
adb kill-server;
adb start-server;
to restart adb fixes many things as well.
The problem seems to have different causes.
For me, the issue was that I had two emulators with the same name (I created it, deleted it, and then created it again with the same name). There were two emulator entries in the logcat dropdown and it was connected to the wrong one. All I had to do was switch to the other one. I prevented the problem permanently by renaming the emulator.
I believe that the problem has various causes for different users. I experienced the same issue with logcat not displaying any information when my application crashed, and we all know how frustrating this can be.
The following are the solutions that worked for me.
Invalidating caches and restarting android studio
In the developer option in your physical device make sure the logger Buffer size is set to 1MB per logger buffer.
Restart your physical device.
Hope this helps.

LogCat & Console stopped working with Eclipse Android Emulator

The Console and LogCat printouts stopped working in Eclipse with the Android Emulator.
I'm getting the following Exception in the Console
[2011-11-10 11:04:58 - Unexpected error while launching logcat. Try reselecting the device.]device not found
com.android.ddmlib.AdbCommandRejectedException: device not found
at com.android.ddmlib.AdbHelper.setDevice(AdbHelper.java:736)
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:373)
at com.android.ddmlib.Device.executeShellCommand(Device.java:319)
at com.android.ddmuilib.logcat.LogCatReceiver$1.run(LogCatReceiver.java:100)
at java.lang.Thread.run(Unknown Source)
Usually when the emulator is loading or updating an apk there's a printout in the Console telling the status. Now the Console is just blank.
I made sure the emulator is selected in the DDMS Tab.
I tried deleting and recreating the emulator in the AVD Manager. I restarted eclipse and the computer. I also updated all of the android and eclipse software in hope that the problem may get fixed. But, to no avail.
It may be related to a problem I had in my code yesterday. There was an unending loop in my code, so I had to stop the emulator mid code running.
I was having a similar error and it was driving me crazy. I just got it to work by doing the following steps:
In a shell or command prompt run: adb kill-server
Unplug the USB cable from the device and plug it back in.
Open the devices view (Window -> Show View -> Other -> Android -> Devices)
Click on the device on the android devices view.
I tested this for the emulator and it works if you relaunch the emulator instead of step 2.
Another way I got it to work was to restart Eclipse. But that's not usually ideal.
Note: Logcat would stop working any time I disconnected the usb cable from my android device (similar to killing an emulator).
I recognize this might not fix your initial issue, but it might help others who stumble on this question.
I also had the same problem, install the SDK even three times as TT, but the solution is to go to the folder android-sdk-windows, then platform-tools, and double click adb and ready!
Clean project with Project/Clean...
deleting the emulator and creating a new one did the job for me.
Even in my case a faulty code or a secret infinite loop, i think is the problem. i tried out something and logcat failed to boot up since then.
Most likely you have 2 instances of Eclipse running (I did).
(On Windows) Exit eclipse then check with the Task Manager if there is another eclipse.
End it as well as any image name "adb".

How to resolve "Waiting for Debugger" message?

I have HTC Comet connected to Eclipse with SDK 2.2. I do a debug build - the application does not run; though it does get installed on the device. On the device I get this message box on the Comet screen
Waiting for Debugger
Application HunyDew (process com.airvine.hunydew) is waiting for the debugger to attach.
[Force Close]
Whereas in the Eclipse console I get these set of messages
[2010-12-07 01:42:29 - hunydewprj] Android Launch!
[2010-12-07 01:42:29 - hunydewprj] adb is running normally.
[2010-12-07 01:42:29 - hunydewprj] Performing com.airvine.hunydew.HunyDewAAStartsHere activity launch
[2010-12-07 01:42:47 - hunydewprj] Application already deployed. No need to reinstall.
[2010-12-07 01:42:47 - hunydewprj] Starting activity com.airvine.hunydew.HunyDewAAStartsHere on device 308730C861BC
[2010-12-07 01:42:49 - hunydewprj] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.airvine.hunydew/.HunyDewAAStartsHere }
[2010-12-07 01:42:49 - hunydewprj] Attempting to connect debugger to 'com.airvine.hunydew' on port 8601
[2010-12-07 01:43:09 - hunydewprj] Launch error: Failed to connect to remote VM. Connection timed out.
The application runs fine in the Emulator - please help - what is it that I am missing here? Any hints/suggestions? Thanks
Some devices will only let the debugger attach if the application has the android.permission.SET_DEBUG_APP permission set in its manifest file:
<manifest>
<uses-permission android:name="android.permission.SET_DEBUG_APP"></uses-permission>
</manifest>
The Dialog Waiting for Debugger is shown if you are building a debug application or somewhere in your source code, you called Debug.waitingForDebugger();
Inside Android Studio 2.0 and above, there is an option of Attach Debugger to Android Process. It is the last menu item in the Run menu.
Not sure if this is what you are looking for, but try putting:
android:debuggable="true"
in the application tag in the AndroidManifest.xml
I've got this problem for long that I cant get my android emulator or device connect to the debugger while both the console and the emulator were displaying waiting for connecting to the debugger.
And configuration for debug inside eclipse also confused me so much before, but today, i got this problem solved, by the following steps:
When you want to debug a android project, for instance, mypro. you would right click on it in the "Package Explorer". Then choose "Debug as"-->"Android Application".
Then the emulator might stop at the "Waiting for connecting to debugger"(or something else similar to this).
Then you need to connect to the debugger yourself by click "DDMS" to open the DDMS perspective, and click "Devices" tab.
Then you can see a list of processes that are running on your emulator or device.
Double click on the one which you are debugging, then change to the Debug perspective, you can see the debugger is connected and you could debug your program. That's how I solved this problem.
By the way, my OS is Win7 32-bit. Eclipse's version is Helios Service Release 2. Android SDK is rev. 16 and platform-tools' 10.
Update.
I found that it is the problem of my TCP/IP configuration. The debugger can't be connected when i assign a static IP address(for access to internet).
So every time when the debugger is unable to connect, I always do the following steps:
1.close current eclipse window.
2.change the config of IP address to dynamic, it means getting a IP address by DHCP.
3.open up the eclipse again.
then the debugger is able to be connected. I thought it might be a issue of the internal mechanism of java debugger which is using socket connection.
I get this if I switch the usb cable to a difference port on my PC, odd but it works when I switch it back again. Also I think I've got this when there's been another device or emulator running at the same time, or two instances of Eclipse open.
For those getting this annoying behavior in 4.2.2 you have to un-check the setting for "wait for debugger" in the developer options. Of course, those options were hidden by Google, and you have to do a sneaky trick to get them to show back up. I had set them before they disappeared, and couldn't for the life of me find them again.
This page explains the procedure
Running Android Studio, I ran into this problem and after trying various remedies restarting Android Studio is what appeared to fix the problem.
My solution is to use the Dalvik Debug Monitor. Sometimes there is a red or green bug beside a process. Click on the device you're trying to load to. Select the Actions tab and reset adb. This usually attaches the debugger for me. I find that doing debugging through this Monitor works better for me than using the Android Eclipse plugin Logcat.
Closing the emulator and closing eclipse. Reopening Eclipse and starting the simulator worked for me.
The key thing to look for is in the Devices pane of Eclipse. If you start the emulator or device and it shows up in the device name list but says [null] and no running processes show beneath it, then it won't work correctly with loading your app into it.
If the name of the device comes up and is Online then things seem to work smoothly.
Don't know why it doesn't work out all the time though.
In my case, the problem is caused by adb connected with another device.
If several devices are connected in PC, remove other devices except required one.
I end up going into "Debug" perspective.
Then in the "Debug" frame, there are debug list or running list.
You have to decide which one is your current one that has this problem (Waiting
for debug...)
Then do right-click and choose "Terminate and Remove".
Then you try to run again. And that warning box will be gone.
I solved this issue this way:
Go to Run menu ====> click on Edit Configurations ====> Micellaneous and finaly uncheck the option Skip installation if APK has not changed
Rebooting the phone was the solution for me.
If your development environment is Windows make sure the USB drivers are correctly installed.
One way to ensure that the USB drivers are installed correctly is to get the PDANet Windows installer and let it install the USB drivers.
You can find the PDANet page here.
I would try to connect to the phone with ddms on its own without Eclipse. You might be running an emulator inside eclipse that you dont see or have some other problems with Eclipse.
Just run ddms from a command prompt and see if the device appears and you can connect to it.
You can also see if appears when you run adb devices and see that your phone is listed (and maybve something else..)
I got the same problem, I know I wasn't running any other instances, and I could see it with adb devices. I just did a restart of eclipse and it worked.
Rebooting the PC was the only thing that worked for me. It worked when I had this problem with an Android 2.2 phone, and also an Android 3.1 tablet.
I ran into this problem today. After spending most of the day trying to fix it, the only thing that ended up working was to create a new workspace and import my project into it. I hope this helps someone avoid all the trouble that I went through.
I also enounter this problem. In my environment, I use a tomcat as server and android as client. I found,
If tomcat is started, this error " Launch error: Failed to connect to remote VM. Connection timed out." will occur.
If tomcat is not run, adb works well.
I tried all the solutions above, it fixes the issue sometimes, but still from time to time I happened to get stuck with the "Waiting for the debugger to attach" message box.
The final solution in my case was to unplug all the Android devices but the one I want to debug on. I don't know which one is the culprit: the Nexus 7 running JB 4.2, the HTC One X running ICS, the HTC Desire S running Gingerbread, or the combintation of the 3, but as soon as I only have one device plugged in, it runs smooth as silk.
I used Task Manager to kill adb.exe to solve this problem. Adb.exe will automatically start after being killed.
Killing adb.exe has solved a lot of problems related to debug and emulators for me so far.
For Android Studio users I encountered this problem first time while trying to run a bare
bone project just after updating my jdk location. So I stumbled across this post. In my case simple Build->Clean Project did the job.
I was also having the same problem when using Android Studio and GenyMotion.
I am able to solve this problem by pausing the program and resuming it again after "Waiting for debugger" message is shown. It may work while using other IDEs and emulators as well.
Android Studio 1.2.2 on Mac OS 10.10
Same problem as others have reported.
I closed Android Studio, then checked from command line in terminal:
ps -efw|grep -i android
This reported a java process (.gradle/daemon) associated with Android Studio. I killed this process, restarted Android Studio, and the problem went away.
disable you developer option in your phone.
Settings > Developer option > Disable
This worked for me, when i tried to use my application without debugging it.
What solved the problem for me was going to:
"Run"->"Attach Debugger to Android process" and then select your process.
You do this in Android Studio.
I had the same issue, fixed it by explicitly selecting desired device in debug configuration. Unfortunately, even after that log sometimes stops when debugger tries to connect. In this case in DDMS perspective find the desired process. It will be highlighted with green bug. Click stop and then debug it again.
This may be old, but for Genymotion's latest update 2.7.1, go to Developer options, if in case you dont know how to open that option, go to About phone and click Build number few times and Developer options will be enabled. Turn ON Developer option, check USB debugging.
Tested on Genymotion 4.4 and up.
Weird solution eh ? But definitely works. Hope it helps.
Happy codings.
In Debug mode Android Studio connects to your Device via socket(:8600). Somehow your socket connection is choked and thus not responding to incoming connections.
Restart Android Studio and your problem will be resolved
"Wait for debugger"in Developer options may have been set to wait your application.Please clear that option and application should run normally.

Categories

Resources