Titanium Developer, Android Emulator - Passing Custom Arguments - android-emulator

I seem to be plagued by an issue that a lot of people run into, when I run my Android Emulator it fails to have any usable internet connection. If I run the emulator manually and pass "-dns-server 8.8.8.8" it works just fine.
emulator.exe -dns-server 8.8.8.8 -avd {NAME}
What I'd like to do is add this "-dns-server 8.8.8.8" as a custom argument when launching the emulator through Titanium Studio. I've figured out how to do this in Eclipse for the Android SDK, but not through Titanium Studio as the same options are not available.
Titanium appears to launch the emulator with the following arguments:
\tools\emulator.exe -avd titanium_15_HVGA -port 5560 -sdcard C:\Users\dhiggins\.titanium\titanium_15_HVGA.sdcard -logcat *:d,* -no-boot-anim -partition-size 128
On a side note, it appears that if I setup my NIC to "Obtain Automatically" rather than use a static address, the Android Emulator works just fine with the internet. I, however, require a static address on my development machine.

I would first start with diagnosing the source of the problem on the static allocation. Does your static IP have the appropriate DNS server listed? When obtain automatically, there are several parameters DHCP provides, including the DNS server list.
In any case, it is fairly simple to update the commands to start the android emulator, at least for the Windows platform. I have to think that there is something similar in the mobile SDK for Apple.
Locate the mobile SDK folder. Under Win 7 it is C:\ProgramData\Titanium\mobilesdk. Under the mobile SDK folder open \android\builder.py and locate the following (search for -avd gets you right to it):
# start the emulator
emulator_cmd = [
self.sdk.get_emulator(),
'-avd',
avd_name,
'-port',
'5560',
'-sdcard',
self.sdcard,
'-logcat',
'*:d,*',
'-no-boot-anim',
'-partition-size',
'128' # in between nexusone and droid
]
debug(' '.join(emulator_cmd))
p = subprocess.Popen(emulator_cmd)
Edit this section and add one or more lines for your custom parameter(s).
Good luck!

Related

Nativescript project running with Visual Studio Emulator

I have a Nativescript application that I'm developing using VS Code and have no issues when I try to run it using the Nativescript launch configurations from the Nativescript extension, when I'm using a real device connected with USB or when I use one of the android-sdk emulators.
Now I need to run Hyper-V on the machine too and those emulators cannot run when hypervisor is on. So I downloaded and installed Visual Studio Android Emulator which runs fine when I launch it manually.
Problem is that the nativescript project doesn't recognize this device either with tns device or adb devices commands and if I try to launch the application from VS Code it tries to launch one of the other emulators, which obviously fails due to the hypervisor/Intel Haax incompatibility.
Did any of you had this problem before and have any solutions you can share?
Thanks.
Microsoft MSDN say :
If the emulator is running, but it does not appear to be connected to ADB or it does not appear in Android tools that make use of ADB (for example, Android Studio or Eclipse), you may need to adjust where the emulator looks for ADB.
The emulator uses a registry key to identify the base location of your Android SDK, and looks for the \platform-tools\adb.exe file under that directory.
Here We Go!! Step By Step ;)
Copy Your ANDROID SDK PATH for me it look like this :
To modify the Android SDK path used by the emulator:
Open Registry Editor by selecting Run from the Start buttons context menu, typing regedit in the dialog box, and choosing OK.
Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Android SDK Tools in the folder tree on the left.
Note : if Android SDK Tools folder doesn't exist, Create it under WOW6432Node, And open it, And Create a String Value name it Path:)
Modify the Path registry variable to match the path to your Android SDK.
Restart the emulator and you should now be able to see the emulator connected to ADB and associated Android tools.
Now! Open Your Terminal (CMD), and Run ADB command
adb devices -l
YES YES !! The Visual Studio Emulator is running, and connected to ADB!
HERE WE GOO !!
Now We Want To Create A Demo App (for example FIRSTZAKI) ZAKI is my nickname :p
On Terminal (CMD) :
tns create FIRSTZAKI
Choose Android Platform
cd FIRSTZAKI\
tns platform add android
Check if VS EMULATOR is ready!
tns devices
YES YES ^^
Finally Step (RUN/BUILD) :
tns run android
WOW ... Great :)
AND .. Good Luck ♥ — ZAKI

How to prevent launch Ionic app on emulator

I'm working on ionic App and I'm trying to run App on real Android device, But when I run ionic run android in terminal, I get the following error:
Running command: "C:\Program Files (x86)\nodejs\node.exe"
D:\wamp\www\pars-app\pars-app\hooks\after_prepare\010_add_platform_class.js
D:\wamp\www\pars-app\pars-app
add to body class: platform-android
ANDROID_HOME=D:\Sdk\android-sdk
JAVA_HOME=C:\Program Files\java\jdk1.8.0_45
No target specified, deploying to emulator
ERROR running one or more of the platforms: No emulator images (avds)
found.
1. Download desired System Image by running: "D:\Sdk\android-sdk\tools\android.bat" sdk
2. Create an AVD by running: "D:\Sdk\android-sdk\tools\android.bat" avd HINT: For a faster emulator, use an Intel System Image and install
the HAXM device driver
You may not have the required environment or OS to run this project
How to prevent run app on windows emulator? I want to run app on real device that conected to my computer.
I am using windows 8 and Huawei with Android 4.2.2
::note
I have read these questions, But I didn't got the answer!
Why not work Ionic app testing on android real device?
Ionic run android does not run app on device
ionic run android - configurations not running app on device
As a complement to #OClyde answer, you could try :
adb kill-server
adb start-server
To have infos about these commands :
adb --help
Nb : Sometimes, for a reason i do not know, the connection between my phone and the computer break. Running this fixes it.
To make sure that your app is not installed to an emulator but to your device, take the following steps:
Open up your console and run adb devices. This should give you a list of all devices available (real devices as well as running emulators) to the Android Debug Bridge. If the adb command is not recognized check that you have installed the Android SDK correctly and that you've set all the necessary environment variables accordingly.
The adb devices command might give you output similar to this:
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
This indicates that the ADB wasn't ready before, so in this case just try to un- and replug your device and run adb devices again to see if the device is listed afterwards.
If your device is still not showing, check that USB Debugging is enabled on your device. Therefore you first have to enable developer settings, which you can do by tapping the build number (Settings => About Phone) 7 times (no, that's not a joke ;) ). After that, you'll have the developer options in your settings menu. Open these and check "USB Debugging"
If still your device isn't recognized by the ADB, change the USB connection mode. You can either do this in the developer options as well or tap the notification shown when the phone is connected to your PC. Try MTP as well as PTP, on of those should do the job.
After these steps, it should be nearly impossible that the device is still not recognized by your PC. As soon as there is a phone available, Ionic will install the app on the phone automatically instead of launching an emulator.

Running Instagram on AVD

I wanted to use Instagram on my computer, so I decided to use an Android Virtual Device for that task.
I downloaded the Android SDK and the newest apk for instagram for my computer.
Then I created a new AVD and ran it. After it was booted, I installed the instagram apk using adb install instagram.apk.
It installed smoothly and after clicking the app, it started.
Now here's my problem: From there on nothing works.
When I try to login and I press the login button, nothing happens like there would be no internet connection.
Browsers and other apps using an internet connection work just fine, just instagram doesn't work.
How can I fix this?
I think it has something to do that the android Emulator can't really handle a global proxy.
Therefore hostnames get resolved directly to their IP which violates HTTP 1.1 standarts and the request doesn't get send properly.
To fix this, it is needed to change it so the hostname gets send instead of the IP.
You should try creating an AVD with different settings. More RAM and allowing GPU emulation is a good idea. If you insist on using an AVD and you have an appropriate intel CPU then you can make the emulator run much faster by following these steps. They are a bit complicated, but worth it if you want the emulator to run quicker.
I typically try to avoid using the Android emulator while I am developing apps. It has its uses, but it tends to be slow and doesn't have all of the capabilities of actual devices.
As an alternative to using an AVD, I would recommend downloading and installing BlueStacks. BluesStacks was written from the ground up to allow running Android apps on your Windows PC or Mac. I have used it before and it does a great job. Much better than an AVD.
Try visual studio emulator for android. Instagram works on it with enabled and connected wifi. This emulator works better than BlueStacks.

Android Emulator 'No Service'

I am new to both the android and android development so I'm not on familiar ground here.
When I start the emulator I have no service. Therefore I have no internet connection on the emulator.
I am running Windows 7 and I generally run the emulator via eclipse.
My host machine is connected to the internet via the Local Area Network. There is no proxy.
I have tried:
Disabling all network adapters except for the Local Area Network [link]
Running the emulator from cmd line with: emulator -avd -dns-server 8.8.8.8
Reinstalling the SDK Tools 9 and Platform Tools (rev 2).
Restarting the machine! :P
Is there a setup needed to specify to simulate a 3G connection? Or could this be a Windows 7 permissions issue? Or am I doomed like these folks: link link
Ah! found the solution.. I uninstalled the entire SDK and reinstalled it to C:/Android. I deleted the C:/Users/[your-name]/.android folder and recreated an avd. Voila.. Something in there worked!
[edit]
Actually it looks like you have to keep restarting the emulator until it connects. I will often get no service so I restart a bunch of times till it works.
I found that 'Airplane Mode' was enabled by default in the standalone android emulator - this may also be the cause in the sdk version. Turning this off (by holding down the red power button until the menu came up, and then toggling the airplane mode button/section) allowed the emulator to 'find service' and connect properly through the LAN.

How to connect android emulator to the internet

How can I connect my Android emulator to the internet, e.g. to use the browser? I've found lots of advice on what do to when your connected through a proxy, but that's not the case here, my machine (Windows 7) is directly connected to the router.
I think some of the answers may have addressed this, however obliquely, but here's what worked for me.
Assuming your problem is occurring when you're on a wireless network and you have a LAN card installed, the issue is that the emulator tries to obtain its DNS settings from that LAN card. Not a problem when you're connected via that LAN, but utterly useless if you're on a wireless connection. I noticed this when I was on my laptop.
So, how to fix? Simple: Disable your LAN card. Really. Just go to your Network connections, find your LAN card, right click it and choose disable. Now try your emulator. If you're like me, it suddenly ... works!
If you are on Mac - try this -
GoTo Apple Icon -> System Preferences -> Network
Click on the gear icon on the and select 'Set Service Order'
Bring the active interface before other interface.
Restart the Android Emulator.
[EDIT]
For more recent version of Android Studio, the emulator you need to use is no longer in the ~/Library/Android/sdk/tools folder but in ~/LibraryAndroid/sdk/emulator.
If while trying the below solution you get the following message "PANIC: Missing emulator engine program for 'x86' CPU.”, then please refer to https://stackoverflow.com/a/49511666 to update your bash environment.
Operating System : Mac OS X El Capitan
IDE : Android Studio 2.2
For some reasons, I wasn't able to access internet through my AVD at work (probably proxy or network configuration issues).
What did the trick for me was to launch in command line my AVD and giving manually the Google public DNS 8.8.8.8.
In your Terminal go to the folder tools of your Android sdk to find the 'emulator' program:
cd ~/Library/Android/sdk/tools
Then retrieve the name of your AVDs :
emulator -list-avds
It will return you something like this:
Android_Wear_Round_API_23
Nexus_10_API_22
Nexus_5X_API_22
Nexus_5X_API_24
Nexus_9_API_24
Then launch the AVD you would like with the following instructions:
emulator -avd NameOfYourDevice -dns-server 8.8.8.8
Your AVD is launched and you should be able to use internet.
My platform: Mac OS 10.6.4
Eclipse: 3.6
I had a similar problem where my map app background was grey (no tiles) and the browser was unable to connect to the internet.
Within Eclipse I went to Run Configurations -> Target and added "-dns-server X.X.X.X" and everything worked fine afterwards. (obviously X.X.X.X was the IP address for my DNS server).
In order to use internet via proxy on emulator try these steps it Worked for me:
Go to settings->Wireless & networks->mobile networks->Access Point Names.
Press menu button. an option menu will appear.
from the option menu select New APN.
Click on Name. provide name to apn say My APN.
Click on APN. Enter www.
Click on Proxy. enter your proxy server IP. you can get it from internet explorers internet options menu.
click on Port. enter port number in my case it was 8080. you can get it from internet explorers internet options menu.
Click on User-name. provide user-name in format domain\user-name. generally it is your systems login.
Click on password. provide your systems password.
press menu button again. an option menu will appear.
press save this and try to open your browser. I think it has helped u?
righ click on the Project in Eclipse
select Run As -> Run Configurations ...
select Android Application and then select "target" tab
Looking for "Additional Emulator Command Line Options" and put this command line to text box
-http-proxy http://< username >:< password >#< hostname >:< port >
There are different solutions to this problem . One of these , i will show you on my experiment and outcomes seen on results using a recent android studio and AVD images downloaded 2017.
First thing you have to do is launch your AVD from android studio.(in my case i choose NEXUSAPI25 android 7.1 image)
Goto Settings->Wirless and Networking - > Cellular Network - > Access Points -> (+) press add - > enter the following if you dont have NTLM proxy or proxy at all (that means you are directly connected)
a. add apn name as myAPN
b. add apn server => www
c. save and try browsing the internet.
if this doesn work add 'ANDROID_SDK_ROOT' in you environment variable
Then , launch AVD using emulator command as follow
emulator -avd Nexus25 -dns-server 8.8.8.8
For those who use NTLM proxies , i will show you how it work for me next.
add your Android_sdk_root path into your environment variable. THis make command line code read succesfully like using AVD names and so on.
Launch your emaulator using the following command
>emulator -avd Nexus_5X_API_25 -http-proxy http://username:password#ipaddress:port
ENTER
Have you tried starting the emulator with administrative privileges? It worked for me, I'm running Windows 7 64bit)
In my case I just had to launch the Android virtual device (AVD) from the "Android SDK and AVD Manager", and it was working
If you are behind a proxy in the SDK Manager, under Tools -> Options, do NOT configure the proxy settings.
When you run from the command line add -http-proxy:
emulator.exe -avd YOUR_AVD_NAME_HERE -http-proxy PROXY:PORT
Worked for me.
I also experienced the same problem.
The simplest solution I found out is:
Go to your Android\Sdk\emulator folder and open command prompt.
Type emulator -list-avds to see available emulator names.
Type emulator -avd name-of-your-device -netdelay none -netspeed full
-dns-server 8.8.8.8 command and press enter.
I encounter this issue when I first run the simulator, I solved it by setting the dns server with
Library/Android/sdk/platform-tools/adb shell getprop net.dns1
get the current dns server of simulator 10.0.2.3
Then set it to my lan dns server
Library/Android/sdk/platform-tools/adb shell setprop net.dns1 192.168.1.1
I had similar problem. I have installed an application that required INTERNET permission (and used it), and all of sudden, worked.
Guys, check also whether if you are not connected through a VPN somewhere, because it also can disturb the Internet connection.
blacharnia
In eclipse go to DDMS
under DDMS select Emulator Control ,which contains Telephony Status
in telephony status contain data -->select Home , this will enable your internet connection ,if you want disable internet connection for Emulator then --->select None
(Note: This will enable internet connections only if you PC/laptop on which you are running your eclipse have active internet connections.)
After reading this I decided to look at my "NICs". I put this in quotes because like many I am running virtual nics for devices like Hamachi and Virtual Box. After I disabled Hamachi I am able to use the internet. My guess is that the emulator picks the first available nic regardless of whether it is virtual. Now to find out if I can rearrange my nic order without tearing my box down.
Windows 7 32bit
My Service Order preferences were correct (Wi-Fi was first) but still could not connect.
Answer was to turn off the Thunderbolt Bridge:
System Preferences > Network > Thunderbolt Bridge
Then set Configure IPv4 to off and Apply your changes.
No need to screw around with Access Points in the emulator.
I solved it my disabling all network connections except the wifi connection I was using, then setting the properties on that one remaining enabled connection to have statically assigned DNS addresses. (no DHCP) This was on Win7 64bit
Thanks for the pointers. They really helped. The "Firewall" word clicked an idea in my mind.
I have a Windows XP machine with WIFI connection and no proxy. I have Norton Internet Security running on my machine which has a Smart Firewall. This Smart Firewall manages programs' access to network, including emulator.exe. I went into Settings -> Program Control and then granted full access to emulator.exe. After this I started Android Emulator and bang... I could connect to internet.
Hope this helps new folks.
~Saggy
Within the Android emulator, turning Airplane Mode on, then off again worked for me.
If you're on MacOS with 2.2 and you keep seeing an error about data connectivity, try the above, it works.
I removed all the network interfaces via Sys Prefs except LAN
Even thought my DNS is provided by DHCP, I retyped DNS with just one server
I used -http-proxy on the command line to specify one
It starts working at the office. Phew.
I think sometimes it's just enogh to simply restart the virtual device. :-)
I had the same problem on my virtual windows 7.
Go to Network Connections
Alt > Advanced > Advanced Settings...
In the second tab bring the internet networks interface on the top
hope it's helpful
thanks to
I had this issue due to a network change after I opened the emulator. If you change your WiFi after you start the emulator, you only need to restart the emulator to get internet access
yes--in win 7 start the emulator with administrator privs and all will be well--or at least you'll get the wireless going in android.
I had a similar problem on Win7 64 bit. Tried disabling my hamachi and virtualbox adapters and didn't work. Tried starting avd as admin and didn't work. In the end I disabled the teredo tunneling adapter using the info on this site and it worked:
http://www.mydigitallife.info/2007/09/09/how-to-disable-tcpipv6-teredo-tunneling-in-vista/
I found that starting the emulator with 'wipe user data' checked cleared this problem up for me after I rebuilt my dev machine from Vista x64 to Win7 x64.
it appears there might be a few reasons why there might be no internet connection for an emulator, in my case i was working from home where i have a wireless connection then came into the office and plugged in direct, however although my wireless connection was disconnected it was not disabled resulting in no emulator connection. my understanding is that when it starts up it looks for a network adapter and if there is any conflict here it might result in no internet connection. to resolve go to Start > Settings > Network Connections right click on Wireless Network Connection (if you are not using wireless) and select disable
I am not using a proxy...however I am using a script...Is there anyway around this. I am behind a company firewall
I'm not sure if this is your issue, but here's how I fixed mine.
I always had this "No DNS servers found" error when starting the emulator and did a lot of research on google to no avail. Anyway, I found a post somewhere (can't find it anymore) that was saying that the number of NICs, number of DNS entries could affect the emulator. Also, knowing that the emulator uses a Windows API function (GetNetworkParams()) to resolve DNS entries, I couldn't rely on the %WINDOWS%\System32\Hosts file.
However, I did went in the NICs properties (on Windows 7) to find that I was specifying a static IP, but no DNS entries. So, I got the DNS entries from my router and plugged them in the NICs property. I restarted the emulator and it is now using the correct DNS entries!
I can use my internet connection with the emulator now, and it works wonders!
Hope it helps!
I thought I experienced issues with connecting my emulator to the internet but it turned out to be problems with the code I was using. I know its obvious but in the first instance try the browser on the emulator to confirm you have no internet access. I would have saved an hour if I had done that first.