How to use Android Studio with WSL (bash) as your shell Terminal? - android

Is it possible to use Android Studio and configure Windows Subsystem for Linux as a Terminal? I really don't like to work with Windows cmd.exe, but when I try to switch to bash.exe, which seems to work, it cannot build the project because there are missing e.g. Android/sdk/build-tools/27.0.3/aidl'.
This file is there, but it is with .exe suffix as it was downloaded for Windows. Any workaround to use *unix like bash for Terminal in Android Studio while being on Windows 10?

Yes, it is possible. I'm doing it right now. I have an Ubuntu app as WSL and figured out that it's accessible at C:\Windows\System32\bash.exe
So, open Android Studio and navigate to File -> Settings -> Tools -> Terminal. There fill Shell paht with C:\Windows\System32\bash.exe and voilĂ !
Now, when you open a new terminal it will use the WSL you have installed in your machine.
I'm using Android Studio 4.0.1.

I'm setting this up right now and hit your question from Google looking for advice. So with that caveat, let me explain what I did to get it running and if you have follow up questions we may need to experiment together to find the answers.
First, I installed VcXserv: https://sourceforge.net/projects/vcxsrv/. This X Server for windows allows you to run graphical linux applications in WSL. You'll just need to export the display variable in your ~/.bashrc since that isn't done normally in WSL:
$ echo "export DISPLAY=:0" >> ~/.bashrc
Then you have to run XLaunch from the start menu. It takes you through the config dialogs (just choose the defaults) and it puts an icon in the notification area you can check to make sure it's running.
Then, you want to download the Linux version of Android Studio 3.1. Extract it into the WSL filesystem somewhere (I used ~/apps). Then from your bash shell you can run android-studio/bin/studio.sh and the window will appear and begin the unboxing dialogs.
This is as far as I've gotten, right now it's downloading the SDK. I still am not sure how adb over usb is going to work or tested the emulator. I'll update this if I learn more.
Update unfortunately, VcXserv is crashing when the main Android Studio window launches. I'm going to file a bug report on it and try some other X servers if I have time later.

Related

Can't see Android Studio install wizard on Ubuntu 17.10

I just installed the new version of Ubuntu (17.10) but now if I try to install Android Studio by running "studio.sh" it doesn't show the install wizard. It's there but I can't see it. Does anyone know how to get it to display? This is a fresh install of both.
Update: I've found a workaround. If I alt + ~ then I can see the preview image and I can actually use this to navigate through the wizard and get it to work. But this isn't really ideal. The wizard is apparently on the screen and I can interact with it via the keyboard, I just can't see it.
You have to execute the studio.sh file using the command below.
(I assume you have extracted the archive in your home directory)
$cd android-studio/bin
~/android-studio/bin$./studio.sh
It will open a wizard for basic setup like downloading sdk etc.

'Visual Studio Emulator for Android' devices are not listed in the Android Device Monitor

I can start the VS Emulator devices just fine, but they simply don't show up in ADB/Android studio.
I searched and found a similar SO question (same issue, only I installed the standalone emulator) but OP provided a workaround and I would like to know how to actually fix it so it shows up every time as intended instead of having to connect it manually (and as per SO etiquette didn't want to ask there in the comments).
I also found a "solution" in a Microsoft FAQ post which instructs you to edit a registry key under
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Android SDK Tools
but the 'Android SDK Tools' is nowhere to be found under 'Wow6432Node' in my registry, which could very well be the cause of the problem to begin with. I'm not sure if it's missing because of the Android Studio/SDK installation or something else, but for example Genymotion devices connect to ADB without any problems. (I always feel uneasy about adding anything to registry manually, but maybe I should add the 'PATH' myself?)
I installed everything just today on a fresh Windows 10 installation and didn't mess with anything in the registry myself.
Any help is appreciated. Thanks in advance!
I experienced this issue when i moved my android SDK (due to disc space reasons).
If you open regedit and go to the following registry entry:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Android SDK Tools
and edit the value Path to look at your new android sdk location it should work.
you may have to call:
adb kill-server
adb start-server
and relaunch your emulator again to get adb devices to see it but it should show up in the end
You may also need to restart your machine just to be safe
In my case I didn't have that entry in registry. But all you need to do is just create the key Android SDK Tools that entry under
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node
Then add the two keys as shown (right click -> New -> String Value). Add the correct path to your Android SDK. Here is what it should look like:
Once you add those entries
adb kill-server
adb start-server
Restart the Visual Studio Emulator for Android then run adb devices and hopefully it should just appear.
Copy Your ANDROID SDK PATH for me it look like this :
Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Android SDK Tools.
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.
You can read this answers :
Nativescript project running with Visual Studio Emulator

how to setup eclim with android developer tool (eclipse 4.2)

I have the Android Developer Tool which shows eclipse version 4.2 (juno).
According to Eclim site required version of Eclim is as
Eclipse 4.3.x (Kepler) (Eclim 2.2.x), Eclipse 3.7.x (Indigo) (Eclim 1.7.x), or Eclipse 3.8 (Eclim 1.7.13 or greater)
I thought eclim 1.7.18 will work with eclipse 4.2. I also tried 2.3 but none are compatible with eclipse 4.2 which comes bundled in ADT.
So which version of Eclim should I use?
I got ADT bundle with eclipse 4.2 and installed eclim 2.2.6 which doesn't complain about eclipse's version.
I hope it works for you too.
For other readers not satisfied I'll tell my story, before you read you must know I'm that type of developers who love using the CLI and thinks that keyboard shurtcuts are faster than using a mouse, if you don't agree may be this setup is not for you:
Install main tools
I've downloaded Eclipse Luna (4.4.0) from the eclipse project website.
Download the Android SDK.
Later install the ADT Plugin (through Help > Install New Software).
After installing the ADT Plugin will ask for the path to the Android SDK.
Later on installed Eclim (2.4.0), it will ask for the eclipse installation folder as well for the .vim folder.
Start the Eclim daemon service. (In debian you can use update-rc.d to make it always run, or search a solution for your system, you can setup to start at system start, let the ideas come out!)
Setting up the Android Development Vim Studio
Check Eclim is up by typing in vim :PingEclim you should see the version of Eclim as well of Eclipse.
I suggest installing the NeoComplCache Vim plugin it integrates nicely with Eclim autocomplete, in the Eclim doc web site it says what you need to add to integrate it.
Eclim will detect the android-sdk path based on the setup you made on eclipse but if not you can define the android-sdk path (see Eclim docs).
How to create projects and install on device
With my NERDTreee I automagically CD in the selected root dir and use :ProjectCreate %/MyProjectFolder -n android, it will ask for some configs.
Later in order to you can build and install the app to your phone you need first to generate the build files (eclipse doesn't share these build files), use :!android project update --path %/MyProjectFolder (note you can omit '/MyProjectFolder' if you're already inside that folder). You can add --target and --name flags if you want to update these values.
At this point you can work in your project without any issues, code completion works excellent, if you need import something use :JavaImport but you know you can map it.
Wenever you want to test the app in your device (I use a physical device) use :Ant debug install and if build succeeds use :!adb shell am start -n your.package.name/.YourMainActivity this will fire the app in your device just like eclipse does.
You can combine the build and install command with :!ant debug install && adb shell am start -n your.package.name/.YourMainActivity. Also remember to keep a terminal open for your logcat adb logcat or if you declare a tag (I suggest doing it) adb logcat -s "MyTag"
Why to use eclim?
I was in a pain after updating my eclipse juno only errors was shown, I was tired of downloading, installing, updating eclipse, even the bundled ADT was bugy, Android Studio looks very ugly on linux by the swing font rendering, many hours were wasted at the end I just search for integrate my vim (I use it for web dev) and never looked back, used Eclim because I had the buggied eclipse on my system (is still here can't use that slow bugy crap, I HATE ECLIPSE).
Does it worth it?
If you don't have eclipse I suggest you try another Android Development Vim Studio without eclim, but if you already have Eclipse, go for eclim. And yes I'm happier to code this way in Vim rather than in eclipse, the only miss is the GUI Layout Designer. As some people say If you want something done well, better do it your self
Looks like a lot of work
Yes, for sure I'll start building a vimscript for this.

'Titanium.API.INFO' is not displaying in console

I am using Windows 7.
but Ti.API.INFO not displaying in console. I changed log level also but still its not display in console can some one help how to show info..
Android device is working fine but not displaying INFO in it also.
and emulator is not launching also.
Ti.API.info('splash function run');
Maybe you can find your answer in this post
Now, my 2 cents, sometimes there is a problem running the emulator when you have your phone plugged at the same time. You could try unplugging your device first.
But perhaps, debugging with the emulator isn't what you want. I recommend to start the ddms tool. And use a query to search what you need, like one of these: tag:ti, tag:tia, tag:tiapi
In order to do that, open a terminal and go to your android sdk folder, cd tools, and run ddms command. You can find where is your android sdk folder looking into Titanium Studio -> Preferences -> Studio -> Platforms -> Android.
Edit
Another option is to run titanium commands from a terminal pointing to your project folder:
cd "path/to/your/project/folder"
# in case of using the emulator
ti build -p android
# in case of using your device
ti build -p android -T device
Android device does not show console on titanium for seeing the result on android one possible solution could be alert that results
alert('I am alert');
Thanks

How to install an apk on the emulator in Android Studio?

How do you install an apk on the emulator in Android Studio from the terminal?
In Eclipse we did
/home/pcname/android-sdks/platform-tools/adb -s emulator-5554 install /home/pcname/Downloads/apkname.apk
Now how about in Android Studio?
Run simulator -> drag and drop yourApp.apk into simulator screen.
Thats all.
No commands.
EDIT: Even though this answer is marked as the correct answer (in 2013), currently, as answered by #user2511630 below, you can drag-n-drop apk files directly into the emulator to install them.
Original Answer:
You can install .apk files to emulator regardless of what you are using (Eclipse or Android Studio)
here's what I always do: (For full beginners)
1- Run the emulator, and wait until it's completely started.
2- Go to your sdk installation folder then go to platform-tools (you should see an executable called adb.exe)
3- create a new file and call it run.bat, edit the file with notepad and write CMD in it and save it.
4- copy your desired apk to the same folder
5- now open run.bat and write adb install "your_apk_file.apk"
6- wait until the installation is complete
7- voila your apk is installed to your emulator.
Note: to re-install the application if it already existe use adb install -r "your_apk_file.apk"
sorry for the detailed instruction as I said for full beginners
Hope this help.
Regards,
Tarek
For those using Mac and you get a command not found error, what you need to do is
type
./adb install "yourapk.apk"
Start your Emulator from Android Studio Tools->Android-> AVD Manager then select an emulator image and start it.
After emulator is started just drag and drop the APK Very simple.
Just drag APK file to android emulator it will install automatically.
In android studio emulator to run an apk file just drag the apk into the emulator.The emulator will install the apk
Much easier is just to start your emulator, then go to sdk/platform-tools and use adb from there to install apk. Like:
adb install xxx.apk
It will install it on running emulator.
Drag and drop apk if the emulator is launched from Android Studio. If the emulator is started from command line, drag and drop doesn't work, but #Tarek K. Ajaj instructions (above) work.
Note: Installed app won't automatically appear on the home screen, it is in the apps container - the dotted grid icon. It can be dragged from there to the home screen.
For Linux: once emulator is running, the following worked for me.
Because I installed the Android SDK on my home directory, I have the following file structure:
home/Android/Sdk/platform-tools/adb
home/AndroidStudioProjects/Metronome.adk
AndroidStudioProjects is a file folder I made for my Android projects. "Metronome.adk" is the file I want to run.
So, using Terminal from the home directory...
./Android/Sdk/platform-tools/adb install ./AndroidStudioProjects/Metronome.adk
Being a Linux novice, I often forget the need to put the "./" in when trying to locate a file or run a command.
After the command achieves "Success", the app is in the Apps area of the emulator and can be run.
When you start Android studio Look for Profile or Debug apk.
After clicking you get the option to browse for the saved apk and you will be able to later run it using emulator
If Android Studio is already open:
Click on File you can find Profile or Debug apk in this menu too
Just download the apk from talkback website
Drag the downloaded apk to the started emulator, Go to settings on emulator > Search for talkback, you will now find it there
1.Install Android studio.
2.Launch AVD Manager
3.Verify environment variable in set properly based on OS(.bash_profile in mac and environment Variable in windows)
4. launch emulator
5. verify via adb devices command.
6.use adb install apkFileName.apk
Upload your apk file on the cloud , then make a direct download link for downloading and then copy that link and paste it on the emulator browser for download it :) ;
In Android Studio: View - Tool Windows - Gradle
In the Gradle tool window navigate to your :app - Tasks - install
and then execute (by double-clicking): any of your install*tasks: e.g. installDebug, installRelease
Note: the apk will also automatically installed when you Run your application

Categories

Resources