How to print debug info from the Emulator? - emulation

I'm trying to connect to a server on my machine with an android app hosted on an emulator on my machine. I know I'm supposed to connect to the IP "10.0.2.2" and I've set the INTERNET permission in the manifest file, but it isn't working. That said, if I could print debug statements I can probably figure this out myself.
I'm using Log.d(...), how can I get to the text it outputs? Or should I use something else?

Go to the command line and type ddms
If you don't have the Android SDK in your path, go to where you installed the SDK and look for ddms in the tools directory. Once you start ddms you can select the device and view logging in the bottom window.

Related

How to debug apps with #if ENABLE_WINMD_SUPPORT statements on HoloLens

I was recently tinkering with HoloLens2 and read the code on Github about getting the RGB camera data stream from HoloLens2.I want to use debugging method to see how the program is running, but there is #if ENABLE_WINMD_SUPPORT statement in the code, according to the general Hololens application debugging method, I can't see the change of some parameters in the code, so please tell me how to debug the code running on HoloLens in this case. Thanks in advance for your help!
You can follow this documentation to learn how to attach a managed debugger to your Unity IL2CPP UWP build on your HoloLens 2 to enable you setting breakpoints and debug C# code as usual: Managed debugging with Unity
In short:
Check InternetClientServer and PrivateNetworkClientServer in the UWP Publishing Settings Capabilities
Check Development Build, Script Debugging, Wait for Managed Debugger (optional) in the Unity UWP build settings
Build in Unity.
Build and deploy from the Visual Studio solution to your device with the Debug or Release configurations.
Make sure your device is connected to the same network as your PC and start the app on your device and your device is not connected to your PC via USB.
Open any script in Unity and go to the Visual Studio solution that opens to view and edit.
Go to Debug -> Attach Unity Debugger.
Select your device from the list and click "OK" to attach.

How to run VUZIX Blade Template application?

Trying to create the first template application with the sample code provided by VUZIX Blade glasses. But, unfortunately do not know how to use the template application using Android Studio.
The Blade_Template_AppV2 has been imported and I am wondering on Android Studio to see the results.
Anyone tried to run the template application and got success?
You just need to enable debugging on your Vuzix Blade as described on https://www.vuzix.com/Developer/KnowledgeBase/Detail/1077 and you can run the template app directly from Android Studio on the glasses.
In order to run the sample Vuzix Code, you'll need to activate developer mode and adb bugging.
Because https://www.vuzix.com/Developer/KnowledgeBase/Detail/1077 is down and many other vuzix manual links are down, below I have detailed the steps to activate Developer Mode and ADB bugging on the Vuzix Blade.
Navigate to your settings, then click system,
system
followed by the info tab,
info
and once you're in the info tab,
swipe left until you activate Developer mode.
swipes will display like this
To enable adb bugging,
look for adb debugging in Dev Options and enable it on.
Before we move to the next step, make sure your device is manually plugged into your system.
In order to verify that the adb debugging worked, load your app from Android Studio, open up the terminal and type ./adb devices. Your device should be displayed now.
When you run your first app, you may notice gradle builds and other things differ and pop-ups will display asking to possibly downgrade certain options so that the hardware api on the glasses matches the app. Follow these instructions accordingly.
Afterwards, you should have a fully functioning app ready to use on your glasses' home screen.
This answer was supplemented by a response at https://blog.csdn.net/sinat_28962939/article/details/103065417

Android studio's emulator has an error "can't connect to camera"

I'm connecting a webcam to my emulator by setting the front camera to "webcam0" in the AVD Manager.
When I launch the webcam from Android studio's AVD manager or using emulator -camera-front webcam0 , I get the following window:
and when the emulator has showed that is an error
Please help me how to fix that.
Go to Android Virtual device manager>>select the emulator>>click edit>>select Advanced Setting>>camera select as Emulated rather than Webcam0 .
I got this error on new android emulator and was able to fix it by selecting emulated options for both Front and Back camera and clearing Camera App's Cache & data.
The solution for me was : " start Android Studio via command line vs starting it the usual way " Doing so makes Webcam0 work inside the emulator.
On my Mac I simply typed
/Applications/Android\ Studio.app/Contents/MacOS/studio
into terminal. I also used Automator later to create a workflow which runs the script (command above), and saved the workflow as an app.
Using such Android Studio launcher.app launches Android Studio.app for me via command line.
Android Studio:
Tools > AVD Manager
select the Device & click edit
click Show Advanced Setting
Camera select as Webcam0
Click >> Finish
Download the free personal use version of genymotion and use that emulator instead of the one that come with Android Studio.
Like you, I've been trying all morning to make my webcam work with the emulator that comes with android studio without success. 0 problems with genymotion so far.
In my case, just change configuration -> saved -> turn on device (cold boot notification will appear) -> then turn off device -> revert change -> turn on again.
I don't know but it works for me. Maybe it just cache problem. CMIIW.
but if you are using bluestack emulator or any other emulator.
then in emulator first open emulator camera then click photo of that
then again your own application in emulator and click button of camera ..i must be work ..

Android Studio won't run application from studio ide?

I've got an application I've been working on and am having an issue with android studio. When I click "build->run" and then select my device, the application never runs on my phone (and the log in android-studio that automatically comes up does not have anything, whereas in the past when I have used this feature it usually says something like, "waiting for phone..." and then the application pops up and automatically opens on the phone and you get some other pertinent information). I have the phone already in developer mode with the install from unknown sources set to on. When I manually move the application from its gradle build location to the phone and then install it manually in file explorer, all is well and the application performs as expected. As I need to debug, however, this is not a very viable solution. Anybody have any advice as to how to get it to run from the IDE? I have tried rebuilding and invalidating the cache/restarting android studio, to no avail.
When I click the run tab at the bottom I have an empty window. When I click the debug tab, I see:
Waiting for device.
Target device: samsung-samsung_sm_g920a-randomIntegerId
Uploading file
local path: /home/eric/Documents/class/OOSE/final_project/2015-group-17/project_code/android/Place2B/app/build/outputs/apk/app-debug.apk
remote path: /data/local/tmp/oose2017.myApp
Note: I am building the application on a LUbuntu 15.04 VM on a windows 8 host, and am using the latest version of android studio.
EDIT: gradle console indicates a successful build as well (obviously since moving the .apk manually to the device works properly).
Open 'Run->Edit Configurations...', and look for your app module in the column on the left-hand side.
Select it, then go to the 'General' tab.
Under the 'Activity' section, there are a couple of radio buttons. Make sure that 'Launch default activity' is selected.

How to get to Hierarchy View while running the app on my device connected to android studio

Okay, so I am trying to get to know the android studio and been playing with few projects. My question is how can I run or debug an app and then open the hierarchy view on it. If I try to open the Android Device Monitor, while the app is running, I get the message: "Following debug sessions will be closed:xx". I see a small Android DDMS window, which opens while debugging or running, where I see the options for Method tracing and allocation tracking, but what about Hierarchy view?
I'm not sure about the gui, but there are instructions for launching it from the cli, here.
From a terminal, launch hierarchyviewer from the <sdk>/tools/
directory.
You can determine your <sdk> directory in Android Studio via:
File -> Project Structure -> SDK Location
execute the following:
./Users/<YourUser>/Library/Android/sdk/tools/bin/uiautomatorviewer
I've made an alias for it:
alias viewer='./Users/<YourUser>/Library/Android/sdk/tools/bin/uiautomatorviewer'
path might be different so locate it:
locate uiautomatorviewer

Resources