Android studio launches emulator with such command line:
/Users/sergey/Library/Android/sdk/tools/emulator -avd Nexus_5_API_22_x86 -netspeed full -netdelay none
How do I add additional options? I need to specify -http-proxy command line parameter
First, run the emulator from the terminal:
/Users/sergey/Library/Android/sdk/tools/emulator -avd Nexus_5_API_22_x86 -"all parameters you need"
Then, clic on the run button in Android Studio. Select your device, that is already running. Your app will deploy there.
The command to run start Nexus_5X_Edited_API_23 emulator with proxy setting (get more params here)
~/Library/Android/sdk/tools/emulator -netdelay none -netspeed full -avd Nexus_5X_Edited_API_23 -http-proxy http://username:password#local_server:8080
also You can list all emulators name from command
emulator -list-avds
From Emulator help section make all TCP connections through a specified HTTP/HTTPS proxy
The value of can be one of the following:
http://<server>:<port>
http://<username>:
<password>#<server>:<port>
The http:// prefix can be omitted. If the -http-proxy <proxy> command is not supplied, the emulator looks up the http_proxy environment variable and automatically uses any value matching the <proxy> format described above.
Related
I am setting local host port in local.setting.json. Referring Microsoft doc https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local
The file looks like below
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"AzureWebJobsDashboard": ""
},
"Host": {
"LocalHttpPort": 7073
}
}
When I run/debug the solution , VS still host the app on default port (7071)
I have checked the bin directory, the local.setting.json file is geting there with above settings.
Running Azure Fucntion CLI (func host start) from bin directory correctly read the port number.
Looks like VS is not using the "LocalHttpPort" port. Is there any other changes required in the settings. I have Visual Studio 2017 Preview (2)
I am using the CLI version 1.2.1, and the following Application arguments setting in Project Properties -> Debug worked for me.
host start --port 7074 --nodeDebugPort 5860
Update: If you're just looking to change the port, you don't have to set it through the file specified in the question. Check Thuc Nguyen answer
Original answer:
the command line takes precedence over the settings file, the problem is that VS passes an explicit port on the command line.
work around is to go through project -> properties -> Debug, then under Application arguments take control of the args. you can type host start --pause-on-error
Edit from ravinsp:
Update for .Net Core 2.0 function project:
The command line arguments you have to pass are different. You have to pass in the path to a dll in front. Like this:
%AppData%\..\Local\Azure.Functions.V2.Cli\2.0.1-beta.22\Azure.Functions.Cli.dll host start --pause-on-error You can see for yourself by running the function in Visual Studio and using the process explorer to see command line args to dotnet.exe process.
edit: a word
Update Project Properties -> Debug to following
host start --port 7073 --pause-on-error
As of this version:
Azure Functions Core Tools (3.0.2912 Commit hash: bfcbbe48ed6fdacdf9b309261ecc8093df3b83f2)
Function Runtime Version: 3.0.14287.0
you only have to type start --port 7074 in the Application Arguments box
Correct answer for .NET Core 2.0 / .NET Standard 2.0 Azure Functions project in Visual Studio 2017 when you have installed Azure Functions Core Tools 2.x Runtime via NPM
I followed #ahmelsayed's answer and in particular, #ravinsp's comments for .net core 2.0 comments. While very helpful and putting me on the right track, they did not work for me without a crucial and non-intuitive modification so I'm adding a fresh answer.
TL;DR;
If you've used NPM to install Azure Functions Core Tools 2.x Runtime then you may need to set Project/Properties/Debug/Application Arguments to:
C:\Users\<myuserid>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\func.dll host start --port 8888 --pause-on-error
Long answer follows ...
My Setup
During this exercise, my setup is fully up to date (at time of writing) and as follows:
Visual Studio 2017 Professional: 15.6.2
Azure Functions and Web Job Tools: 15.0.40215.0
Windows 10 10.0.16299 Build 16299
Azure Functions Core Tools (installed as per the Develop and run Azure functions locally document from Microsoft) reports (in Git Bash):
me#MYDESKTOP ~
$ func
<snip/>
Azure Functions Core Tools (2.0.1-beta.24)
Function Runtime Version: 2.0.11587.0
fwiw, the Functions App settings tab for this Functions App on Azure reads:
Runtime version: 2.0.11587.0 (beta)
My Issue
When I run my functions project (with no application arguments) I get this in the console output:
[17/03/2018 21:06:38] Starting Host (HostId=MYMACHINE, Version=2.0.11353.0, ProcessId=<snip/>
Listening on http://localhost:7071/
This in and of itself might not be a problem, but I'm getting annoying "works on my machine, fails when publishing to azure" type issues, so I want to make sure that local execution is using same functions runtime as azure (i.e. 2.0.11587.0 which, as per the setup notes above, it is/should be, right?)
So, based on #ravinsp's instructions, I run a find on my C drive to locate Azure.Functions.Cli.dll - there's only one, and it's located at C:\Users\<myuserid>\AppData\Local\Azure.Functions.V2.Cli\2.0.1-beta\Azure.Functions.Cli.dll which seems very consistent with #ravinsp's answer.
So, I add the following Project/Properties/Debug/Application Arguments:
C:\Users\<myuserid>\AppData\Local\Azure.Functions.V2.Cli\2.0.1-beta\Azure.Functions.Cli.dll host start --port 8888 --pause-on-error
then I DO get port 8888, but runtime weirdly is still being reported as 2.0.11353.
[17/03/2018 21:13:02] Starting Host (HostId=MYMACHINE, Version=2.0.11353.0, ProcessId=<snip/>
Listening on http://localhost:8888/
Solution
Given that running func from Git Bash as per the above showed runtime of 2.0.11587.0, I tried which func which returned /c/Users/<myuserid>/AppData/Roaming/npm/func
. I did a cat on it and long story short I could see that ultimately it was running C:\Users\<myuserid>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\func.exe, and that in that same directory there was a func.dll.
So, I tried the following Project/Properties/Debug/Application Arguments:
C:\Users\<myuserid>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\func.dll host start --port 8888 --pause-on-error
then finally I do get ...
[17/03/2018 21:16:29] Starting Host (HostId=MYMACHINE, Version=2.0.11587.0, ProcessId=<snip/>
Listening on http://localhost:8888/
and, crucially, the error I was getting when publishing to Azure starts manifesting itself locally too.
Ok, now the runtimes all in sync, time to get down to fixing my actual bug :)
To do this
Select the Function App Project in Visual Studio -> Hit Alt+Enter and navigate to Debug settings and set
host start --port 8085 --nodeDebugPort 6890
I used the accepted answer but I still got an error when the debugger port was trying to bind because both function apps were trying to bind to 5858.
To get around that I added one more attribute to the application arguments in the project settings and my arguments look like this:
host start --pause-on-error --nodeDebugPort 5860
If you're using Visual Studio for MacOS right click on your project, click Options, click on Run -> Configurations -> Default and enter host start --port 7073 --pause-on-error in the Arguments field.
Using Visual Studio 2022 and Function v4, you could set the port in the launchSettings.json file:
{
"profiles": {
"<functionapp project name>": {
"commandName": "Project",
"commandLineArgs": "--port 7137",
"launchBrowser": false
}
}
}
This setting can also be updated through UI:
Properties > Debug > General > Open debug launch profiles UI:
This is the way I use a different port in local.settings.json file, while running this in Intellij. You can use any other IDE as well, local.settings.json works everywhere.
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "java"
},
"Host": {
"LocalHttpPort": 7072
},
"ConnectionStrings": {}
}
Using the following in the "Command line arguments" in VS 2022 and .Net 6 works:
start --port 7074
Using Android Studio 1.5.1 in a win7 ultimate sp1 and in a Mac mini 10.11.3 fully updated.
I have a number of Samsung units for testing my app development incl JNI and this week my private Samsung Galaxy S4mini (Kitkat) died physically so I got a new Samsung Galaxy J5.
However the J5 (lollipop) refuses to be debugged in native mode. Does not matter the app, fails also with Hello-JNI.
The J5 also have some odd java bugs like in a AlertDialog (with stacked linear layouts) linearLayout.addView(anotherLinearLayout); just crashes?? Also I have an odd JNI-bug, I like to debug. And both "bugs" works without crashing in my other devices my old S4mini and a TAB4 Kitkat and a TAB3 and S3mini.
However I found the TAB4 also refuses native debugging. Both the TAB4 and the J5 works fine in (non-native) app-debugging. All other units debugs native no problem, just switching unit on the cable and run, works fine?
Is there something missing in the J5 and TAB4 for making native debugging available?
The debug error message is (I tried everything I could find):
Target device: samsung-sm_j500fn-0af60463
Installing APK: C:\Users\JB\AndroidStudioProjects\HelloJNI\app\build\outputs\apk\app-all-debug.apk
Uploading file to: /data/local/tmp/com.example.hellojni
Installing com.example.hellojni
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.example.hellojni"
pkg: /data/local/tmp/com.example.hellojni
Success
Launching application: com.example.hellojni/com.example.hellojni.HelloJni.
DEVICE SHELL COMMAND: am start -D -n "com.example.hellojni/com.example.hellojni.HelloJni" -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.hellojni/.HelloJni }
Warning: debug info can be unavailable. Please close other application using ADB: Monitor, DDMS, Eclipse
Restart ADB integration and try again
Waiting for process: com.example.hellojni
DEVICE SHELL COMMAND: run-as com.example.hellojni mkdir /data/data/com.example.hellojni/lldb
Error while launching debug server on device: com.android.tools.ndk.run.DebuggerContext$StartServerException: java.lang.IllegalStateException: run-as is broken (please see http://b.android.com/187955 for details)
I was learning how to use the Microsoft Azure Tools for Visual Studio to develop an Azure cloud service at :"Getting Started with the Azure Tools for Visual Studio".
I successfully completed the following steps:
1. Install the Azure tools.
2. Create an Azure cloud service.
3rd step was build and debug the cloud service, where i was stuck.
While debugging i got an error "Failed to initialize Microsoft Azure Storage Emulator".
I did try various methods given on various websites to initialize the Storage Emulator, but none of them worked for me.
When I was trying the command WAStorageEmulator.exe init , i got an error "cannot create database".
Any help would be greatly appreciated.
Step 1 : Start your system in safe mode (Immediately after the computer is powered on or restarted tap the F8 key to enter safe mode).
Step 2 : In safe mode go the path C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator.
Step 3 : Search for WAStorageEmulator.exe - config file.
Step 4 : Edit WAStorageEmulator.exe with Notepad++ (any editor).
Step 5 : Change the port numbers as shown in the above snapshot.
(By default the port numbers will be 10000, 10001, 10002).
<services>
<service name="Blob" url="http://127.0.0.1:30000/"/>
<service name="Queue" url="http://127.0.0.1:30001/"/>
<service name="Table" url="http://127.0.0.1:30002/"/>
</services>
Step 6 : Save the file and restart your system in normal mode and run the program.
I hope this helps.
I had a similar problem and it sounds like one of the answers posted here:
This post talks about removing old mdf files so you can install again
This seems to be closer to what you are experiencing.
I hope this helps
Open MS Azure Command Prompt. Type (depending on your local db name):
SqlLocalDb stop projectv12
SqlLocalDb delete projectv12
Then go to
C:\Users(admin)\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances
and I deleted all instance in there. Then try re-install the Azure storage emulator. This worked for me.
A re-boot is not neccesary as per the accepted answer.
Open a Powershell window in admin mode.
Enter the following command: netstat -p tcp -ano | findstr :10000
That will tell you what process id is using the emulator designated port.
Use the Detail Tab in Task Manager detail to find the associated application for the process id. Often times this is something like bittorrent/utorrent.
Kill that process and you're done.
..
But if you absolutely must run the conflicting application while you develop then you can change the ports used by the emulator.
To change the ports used by the emulator, then in powershell:
chdir "C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator"
.\WAStorageEmulator stop
Then edit the config file as per the accepted answer and just save it.
C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator\WAStorageEmulator.exe.config
You don't need to copy it anywhere. Then back into Powershell and :
.\WAStorageEmulator status
.\WAStorageEmulator start
Make sure you have SQL Server Express or SQL LocalDb installed. You should then be able to type
.\AzureStorageEmulator.exe init
Or, in this older case:
.\WAStorageEmulator.exe init
...and it should install the default database. Note I'm using the PowerShell syntax. If using the command prompt, it's minus the .\ portion.
It's not always a port conflict, contrary to what other posts may suggest.
You can download SQL Server Express editions here:
https://www.microsoft.com/en-us/sql-server/sql-server-editions-express
You should see something like this when you run the command:
PS C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator> .\AzureStorageEmulator.exe init
Windows Azure Storage Emulator 5.10.0.0 command line tool
Empty SQL Instance. Autodetecting SQL Instance to use.
Looking for a LocalDB Installation.
Probing SQL Instance: '(localdb)\MSSQLLocalDB'.
Caught exception while probing for SQL endpoint. Login failed for user 'somedomain\someguy'.
Number of SqlErrors Reported: 1
SqlError: System.Data.SqlClient.SqlError: Login failed for user 'somedomain\someguy'.
Could not find a LocalDB Installation.
Probing SQL Instance: 'localhost\SQLExpress'.
Found SQL Instance localhost\SQLExpress.
Creating database AzureStorageEmulatorDb510 on SQL instance 'localhost\SQLExpress'.
Granting database access to user somedomain\someguy.
Database access for user somedomain\someguy was granted.
Initialization successful. The storage emulator is now ready for use.
The storage emulator was successfully initialized and is ready to use.
PS C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator>
The problem is with the “(localdb)\MSSQLLocalDB” SQL Service with Permissions.
The best option is using below commands,
Step 1: Go the path “C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator”
Step 2: Open PowerShell as Administrator,
Step 3: Run the below command in PowerShell,
“AzureStorageEmulator.exe init -server . -sqlinstance SQLEXPRESS -forcecreate”
Below is the output,
Step 4: Run the below command in PowerShell to Start Emulator,
“AzureStorageEmulator.exe start”
Below is the output,
Step 5: After that check the “SQLEXPRESS” Databases,
New Database is created.
Now you can use the Storage Emulator.
I have a web role that I'm trying to run locally using the emulator. I have it working on another computer, but I cannot get it working on a different one, and have gone as far as to reformat it and start from scratch.
When I launch the site from Visual Studio, Chrome shows the following message:
This webpage is not available
The connection to 127.0.0.1 was interrupted.
There is also an error code listed at the bottom:
Error 101 (net::ERR_CONNECTION_RESET): The connection was reset.
One interesting thing from the build output are these lines:
Starting process 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Windows Azure Tools\v1.8\Debugger\WindowsAzureDebugger.exe' with arguments '"C:\Program Files\IIS Express\iisexpress.exe" /trace:error /config:"C:\Users\brian\AppData\Local\dftmp\Resources\159c7254-b7d0-4076-a4fd-820b00feca5f\temp\temp\RoleTemp\applicationHost.config" /site:"deployment18(27).AzureApp.MyApp.Web_IN_0_Web"'...
Process 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Windows Azure Tools\v1.8\Debugger\WindowsAzureDebugger.exe' exited with exit code 0.
If I run C:\Program Files\IIS Express\iisexpress.exe" /trace:error /config:"C:\Users\brian\AppData\Local\dftmp\Resources\159c7254-b7d0-4076-a4fd-820b00feca5f\temp\temp\RoleTemp\applicationHost.config" /site:"deployment18(27).AzureApp.MyApp.Web_IN_0_Web" from the command line, I get the following message:
The system cannot find the file specified.
Unable to start IIS Express in background.
I have no idea what file it cannot find, but I've verified that the config file I'm passing does in fact exist. Anyone have a clue what's going on here??
While I can not tell you what could be the actual root cause of your problem I can suggest a few ways to troubleshoot it:
Try changing IIS Express to Full IIS and see if it changes the behavior. You can do it by going to your Windows Azure Application project properties and look at "Web" option.
Try running application without debugging it
Launch CSrun at command prompt with /launchDebugger parameter of the /run option to verify that debugger does run without any issue
Try using IE as default browser
Clean your dftemp folder completely for any residual configuration and then launch Azure Emulator separately to verify there are no issues
Procmon "http://technet.microsoft.com/en-us/sysinternals/bb896645" may help you find the file that is missing...
Hopefully someone stumbles upon this answer with similar symptoms. When removing in role caching the <dataCacheClients> section was removed from . Somehow there was a left over <dataCacheClients> section left in the web.config. Everything and compiled and deployed to the emulator successfully. However, the role would fail to start since applicationHost.config was missing.
The fix was simply remove the unnecessary <dataCacheClients> section from the web.config file.
Following this question, how do I launch instruments with iPhone simulator as a device.
I tried this:
$ instruments -t /Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate -w iphonesimulator5.0 MyApp.app
But I get this error:
Instruments Usage Error : Device failed to become ready for use.
-w <deviceID> is used only when you wish to specify a hardware device as the destination (the 'deviceID' here is the Identifier of the device, found in the Organizer of Xcode).
Instead of using -w, you can specify a flag during the build to force instruments to use iPhone. Details can be found here.
I was doing it as follows:
1.I created a template in which I was calling my UI Automation Main file that Triggers running all the scripts.
EX:
//Main.js file will run auto.js scripts
//auto.js is my main file in which I am running all the scripts
//Main.js file
#import "auto.js"
auto.run();
//Now open terminal and run the following command.
1. Go to the directory where you saved your template
2.Copy the location where you simulator (full path) is
Than run the command below:
instruments -t ./NameOfYourTemplate.tracetemplate /Users/swathyvalluri/Debug-iphonesimulator/MyApp.app
Note : Create a new file in the template and copy the contents into it what ever you want to put, otherwise it will look for Main.js file in your locally and will fail when running it on another server.
Please let me know if you need more help :)
Device id means here UDID of the device.
Also see the link below, it is very useful :
http://lemonjar.com/blog/?p=69