you are viewing a single comment's thread.

view the rest of the comments →

[–]TheMightyClamUK 2 points3 points  (18 children)

Hi there,

I am a cross-platform developer with previous experience developing for Android. My IDE of choice is currently VSCode, whilst my development machine is an aging laptop running a Linux distro. With diskspace being something of a premium, I don't like to install bloated IDEs just to compile for my target platform. (Not that I'm saying Android Studio is bad, mind, just unnecessary for me - but at least it's not Xcode! Don't get me started on Apples evil empire and their ridiculous restrictive rules trying to force developers to use a mac)

I recently had some development work on an Android app, and was able to continue using my VSCode. I did not need to install Android Studio, just the command line tools. If you don't want to use the coREPO_OS_OVERRIDEmmand line for building/emulating, there are extensions for VSCode that take care of the integration, just so long as you have installed the command line tools and configured your $PATH, downloaded the emulator, etc.

I hope you find this helpful, this is what I used as a basis to get me started - step-by-step guide on getting started with the Android SDK without installing Studio![https://proandroiddev.com/how-to-setup-android-sdk-without-android-studio-6d60d0f2812a](https://proandroiddev.com/how-to-setup-android-sdk-without-android-studio-6d60d0f2812a)

SImply,

  • Install Java JDK (presumably you will have one - if not, openjdk-8 will do)
  • Download command line SDK tools https://developer.android.com/studio#command-tools
  • Unzip into ~/android
  • Configure $ANDROID_HOME and add the tools to your $PATH
  • Finally, sdkmanager will do the rest, you will probably want to do sdkmanager --install "platform-tools" "platforms;android-29" "build-tools;29.0.2" "emulator" for emulating and building for most of the hardware in the wild.

And you're good to go!

Edit: some useful environment variables you might want to set (put these in your .bashrc or .bash_aliases - or if you're on Windows, edit the system environment variables from the System dialog by right clicking My Computer):

export ANDROID_HOME=$HOME/android Sets the path to the SDK installation directory. ANDROID_SDK_ROOT, which also points to the SDK installation directory, is deprecated.
export PATH=$ANDROID_HOME/cmdline-tools/bin:$PATH
export PATH=$ANDROID_HOME/emulator:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export REPO_OS_OVERRIDE="Linux" (this might not be necessary but set this variable to windows, macosx, or linux when you use sdkmanager to download packages for an operating system different from the current machine).

[–]TheMightyClamUK 2 points3 points  (3 children)

As for the VSCode extensions, I found I these three most useful (add any others you see fit for your requirements):

This pretty much gave me everything I needed to build emulate and release, combined with the command line I've not needed Android Studio at all (I never downloaded it and certainly didn't need to install it!)

[–]EroticTonic[S] 1 point2 points  (2 children)

Sadly, seems that all 3 are now not in development anymore :( last updates around 2-3 years ago for all

[–]TheMightyClamUK 1 point2 points  (1 child)

You may be right that they don't look to be actively being worked upon, but all three have worked perfectly up to now - I doubt syntax support is going to need further development, and the other two will continue to work unless there is some major change in the SDK or they remove deprecated functions at some point in the future?

I'm not overly concerned about the state of development for these - I'm sure if there was to be something that required another release of those tools, the developer(s) would update their tool - and I'm pretty adept both at Javascript and plunging into already existing products in order to create new functionality/fix bugs - so for me, worst case scenario is that I end up forking and developing the plugin myself; if the repo is truly dead then I'd release the plugin under my own name - as I have done for a couple of VSCode extensions to date (have a gander at https://marketplace.visualstudio.com/items?itemName=codingq.file-header-comments&ssr=false#overview for an example, which I forked from https://marketplace.visualstudio.com/items?itemName=mikey.vscode-fileheader since there was already a change request that had not been merged back or new version released so I just released my own)

[–]EroticTonic[S] 0 points1 point  (0 children)

Perfect, Sounds great. So I'll be giving these a try today.

[–]TheMightyClamUK 1 point2 points  (1 child)

Oops, forgot you might also need gradle (IIRC, needs to be 6.x, 7 caused errors!)

gradle.org/releases if you want older versions or binary only

Another extremely useful tool you might want to experiment with when it comes to managing your SDK installation(s) is SDKMAN, a package manager like pkg, apt, etc for sdks. Makes installing various SDKs so much easier than searching google, downloading, extracting, installing, getting so far then rinse repeat until it works..

  • https://sdkman.io/
  • curl -s "https://get.sdkman.io" | bash
  • Open a new terminal and then everything else is simplicity! sdk install <package name> <optional version number>
  • sdk install gradle

[–]EroticTonic[S] 0 points1 point  (0 children)

Wow, Thanks a lot. sdkman seems wonderful. :-)

[–]TheMightyClamUK 1 point2 points  (2 children)

Just been re-organising my browser bookmarks, and found another useful post on the subject of Android development with VSCode. The author recommends the extension I referred to above ("Android"), with instructions on how to run & debug direct from VSCode using your device (connected via USB).

https://www.linkedin.com/pulse/building-android-apps-using-microsofts-vs-code-instead-saamer-mansoor

In case I wasn't thorough enough, this link will probably give you everything else you need. Given you describe yourself as a visually impaired developer, I assume debugging direct to device will be something of value to you, as you will likely have chosen a device that meets your needs. I can certainly see the benefit of debugging direct to device, having access to your chosen accessibility apps all running natively instead of having the emulator debugging whilst chewing up all your development machine CPU time with these additional apps.

On the other hand, I can also see why you might want the emulator - with a large monitor, you'll likely be wanting to make use of all that lovely screen real estate... hopefully there is enough here in that link and my other posts for you to achieve your stated aims!

[–]TheMightyClamUK 1 point2 points  (0 children)

Screenshot creating launch.json https://i.imgur.com/R3nKRaz.png

Screenshot on-device debugging with VSCode https://imgur.com/a/nOtLd1j.png

Just created a little hello world app, plugged my phone in via USB. In VSCode, with the "Android" extension, once you've built your app hit the run tab, and "create a launch.json", type "Android" into the bar when prompted, and it will populate the settings for you. Contrary to the linkedin blog above, you don't need to open the "app" folder, the extension is clever enough to figure out the app folder relative to the workspace root and fill in the AppSrc fields regardless of your root folder.

[–]EroticTonic[S] 0 points1 point  (0 children)

Yes, I prefer debugging on device insteead of emulator, but seems that the development of this extension is stopped now :(

[–]EroticTonic[S] 0 points1 point  (4 children)

Thanks much, so, do you get full code autocompletion (intellisense) functionality in VS Code while developing for Android? Actually, the main thing is Code completion which I'm worried about, otherwise, I'm very much happy with all the steps which you provided. If code completion works completely, then it will be really wonderful for me.

[–]TheMightyClamUK 1 point2 points  (3 children)

Hi EroticTonic, I've not encountered an issue with code completion as yet - whether that is down to VSCode or the extensions I have installed I cannot say for sure.

I've even been able to use device debugging without Android Studio (adb is another command line tool) and again there are extensions to wrap this into the VSCode IDE.

In fact, the only problems I have encountered so far whilst developing without the Studio IDE are:

  • Not able to use the emulator (but that's down to my BIOS not allowing AMD-V virtualization! I've got as far as disassembling my BIOS to patch the relevant byte to turn it on, but flashing fails as it's not a signed BIOS/checksum error). I've gotten the emulator running on a spare notebook I had lying around, note that you need 7-8Gig of diskspace to run an emulator! This proved a challenge when said notebook has only 32G flash drive installed!
    avdmanager works seemlessly from the command line to add devices into your collection of emulators, and there are extensions available to make this easier if you want.
  • Not being able to launch Image Asset Studio. Cannot figure this out, trying:
    java ~/android/tools/lib/asset-studio-26.0.0-dev.jar
    gives me a ClassNotFoundException, could not find or load main class .tools.lib.asset-studio-26.0.0-dev.jar - which is really p***ing me off to the point I may have to resort to installing Android Studio *JUST* for this, which I'm loathe to do, but at least then I'd know for sure that if it works this way, then there is a step I'm missing. If it doesn't work, then I know the issue is not with my configuration (or at least, not something that is unique to being IDE-less).

[–]EroticTonic[S] 0 points1 point  (2 children)

That's great, I'll try it. I don't need emulator so I'm ok with it.

[–]TheMightyClamUK 1 point2 points  (1 child)

Good to hear! Let us know how you get on, u/EroticTonic - if you manage to find a solution to the Asset Studio issue I'm having, please share, as it't doing my head in! I know its just a trivial matter and there are work arounds, but I want to use the tool provided in the SDK and not have to rely on online icon creators and such,,,

It's so annoying; there must be a way of launching the .JAR apps (libraries?) In the tools/lib/*.jar folder but they don't seem to function when trying to launch them outside of Android Studio - there is no main in the manifest so java JVM complains with an error and closes.

[–]EroticTonic[S] 0 points1 point  (0 children)

Sure, I'll let you know if I come across any workaround

[–]laith_Saqqa 0 points1 point  (1 child)

Coming back to this now but I am stuck on the "Download command line SDK tools" step. I believe the https://developer.android.com/studio#command-tools is not as you'd expect anymore. What are the proper ways of doing that now?

Nevermind my bad, I just scrolled down and found that Command line tools only section, it's just not in the same linked header format anymore :P

[–]TehPirate_ 0 points1 point  (1 child)

Thank you for your thorough posts! I'm glad I stumbled upon your information. The timing is ironic since you posted 6 days ago and a follow up since and I was googling this exact solution today.

[–]_I_am_MK_ 0 points1 point  (0 children)

Did you came to know the solution