Android Studio Ubuntu Tutorial

28/12/2020
Chưa phân loại

What is Android Studio?

It is the officially recognized Integrated Development environment (IDE) used to make Android apps. It was created by Google and was first declared in 2013 at a Google I/O conference before its release in 2014. Before this IDE was released, Android application development was generally taken care of through Eclipse, a non-exclusive IDE that supports a few other programming languages.

Being an IDE, Android Studio’s primary purpose is to give the environment for creating Android applications. The core programming language for Android is Java, which is installed independently through a Java Development Kit (JDK). Android Studio is fundamentally where projects are composed, edited and managed. Android studio gives you access to the Android Software Development Kit (SDK), an augmentation of Java code that enables java to run smoothly on Android gadgets and utilize the local hardware.

Android Studio is entrusted with the job of explicitly putting together Java that is required in writing the projects and the Android SDK that is expected to make the projects run on Android. With Android Studio, tasks can be compiled and run on an emulator or a connected physical gadget, e.g., an Android phone or tablet. It allows debugging of the projects as they run and gives a log enumerating crashes in addition to other useful info.

How to install Android Studio on Ubuntu

It’s currently evident that Android is the most dominant mobile operating system (OS). Android, a Java-based innovation, has started a new gold-rush, with software engineers contending to profit from the mobile applications they create. To succeed, Android application developers need to comprehend the Java language, Android Application Programming interfaces (APIs) and the Android application architecture. What’s more, it’s essential that a proper development environment is utilized. Previously Eclipse IDE was the favored one, but we have Android Studio now.

Android Studio is a free open source IDE distributed under the Apache License. Here we will explain how to install this IDE on Ubuntu. Setting up Android Studio is fairly direct and simple given that about everything is packaged into one installer

Regardless of the technique used to install Android Studio, Java must be present. It’s recommended to use Oracle Java since it has a performance edge over OpenJDK. Run the following commands in a terminal to install it from PPA (Personal Package Archives).

sudo add-apt-repository ppa:webupd8team/java    sudo apt-get update    sudo apt-get install java-common oracle-java8-installer  

Amid the installation procedure, you should acknowledge the Oracle License agreement. Once installed you have to set Java environment variables, for example, JAVA_HOME on Ubuntu 16.04/17.04.

sudo apt-get install oracle-java8-set-default    source /etc/profile  

The above commands will set the correct java environment variables. At the time of this writing, the most recent stable version is Android Studio 2.3.3, released on June 8, 2017. Run the accompanying commands to include Android Studio PPA and install it.

sudo add-apt-repository ppa:maarten-fonville/android-studio    sudo apt update    sudo apt install android-studio

During the installation, the most recent Android Studio zip file will be downloaded from the Google servers. Once the installation completes, you can open Android Studio from Unity Dash or your favorite application launcher. If the icon is not loaded, run the following command on the terminal to start the IDE.

/opt/android-studio/bin/studio.sh

How to build your first Android application.

  1. Open Android Studio.
  2. Select “Start a new Android Studio project.”
  3. On the “Configure New Project” window that opens, name your project “MyApplication.”
  4. If you wish to; set the company name as desired. Take note of the project file location from the text field and change if desired.
  5. Click “Next.”
  6. Make sure to tick the “Phone and Tablet” checkbox. If you are planning to test the app on your phone, make sure the minimum SDK is below your phone’s operating system level.
  7. Click “Next.”
  8. Select “Empty Activity.”
  9. Click “Next.”
  10. You can leave the “Activity” name fields as they are.
  11. Click “Finish.”
  12. This is what you should see:
  13. Navigate to the activity_main.xml tab or open it from the project tree on the left if it is not already open.
  14. Click on the Text tab at the bottom to open the source code of the activity_main layout file.
  15. Find and change android:text=”Hello World!” to android:text=”Hello there ladies and gentlemen.”
  16. While on the same screen, on your keyboard, press shift+f10 to run the application.
  17. Connect an Android device to your computer using a USB cable if you have one; otherwise, the IDE will request you to create an Emulator which it will use to test the app.
  18. Ensure USB debugging is enabled on the Android device you choose to test the app with.
  19. Click ok to run the android app on your device.
  20. Congrats! You’ve now compiled your first Android application with some basic functionality

Key features of Android Studio

Android Studio is based on IntelliJ IDEA. It has a lot of features for Android development making the whole process smooth and productive. Android Studio offers tools custom-tailored for Android developers, including debugging, testing, rich code editing, and profiling tools.

Code editor

Android Studio has an intelligent code editor that helps you write excellent code, be more productive and work faster by providing you with smart code completion, code analysis, and refactoring. When writing code, the IDE provides you with a dropdown list with suggestions; you can insert the code by pressing tab key on your keyboard.

Version control

Android Studio has a version control feature to integrate with version control tools such as Github or Bitbucket. With this, it is possible to collaborate with teams in developing your project.

Code templates

Android Studio ships with code and project templates that aid in adding well-established patterns such as a view pager, navigation drawer, Google Maps, among others. Beginners can use these sample app templates to help grasp the whole concept around Android development.

C++ and NDK support

Android Studio completely bolsters altering C/C++ project files so you can rapidly assemble JNI parts in your application. The IDE gives syntax structure featuring and refactoring to C/C++, and a LLDB-based debugger that enables you to troubleshoot your Java and C/C++ code simultaneously. The build tools likewise execute your CMake and ndk-assemble contents without alteration and after that add the common items to your APK.

Testing tools & frameworks

Android Studio gives broad tools to enable you to test your Android applications with JUnit 4 and practical UI test structures. With Espresso Test Recorder, you can create UI test code by recording your interactions with the application on a gadget or emulator. You can run your tests on a gadget, an emulator, a ceaseless coordination condition, or in Firebase Test Lab.

Other features available on this IDE include: Fast and feature-rich emulator, Firebase, and Cloud integration, APK Analyzer and Translations Editor.

What’s new in Android Studio in last 6 months?

The most recent stable version of Android Studio is version 2.3.3. Two of its previews have been released and can be found in the IDE’s canary and dev channels. The following are some of the recent features added in Android Studio in the last 3 months:

Instant Run

Previously, running an android app required a restart of the application. With this feature, the new changes are reflected without having to restart the application.

Chains and Ratios support in Constraint Layout

The recent versions of Android Studio include a layout called ConstraintLayout. With this design, you can now chain two or more Android views bi-directionally together to form a group on one dimension.

Material Icon Wizard

The updated vector asset wizard allows search and filtering. Additionally, labels for each icon asset are included.

App Links Assistant

The latest App Links Assistant enables you to create new intent filters for your URLs smoothly, design your app’s website association through a Digital Asset Links file, and debug your Android App Links support.

How to uninstall Android Studio on Ubuntu.

Run the following command in terminal to completely get rid of Android studio. Please alter the version numbers to match yours.

  rm ~/.local/share/applications/androidstudio.desktop   sudo rm -rf /opt/android-studio/   rm -rf ~/.android/   rm -rf ~/.AndroidStudio2.1/   rm -rf ~/.AndroidStudio2.3/   rm -rf ~/Android   sudo rm -rf /opt/android-studio-ide-143.2790544-linux.zip   rm -rf ~/.gradle  

References

https://developer.android.com/studio/features.html

https://askubuntu.com/questions/873008/uninstalling-android-studio
http://www.androidauthority.com/android-studio-tutorial-beginners-637572/
http://www.instructables.com/id/How-To-Create-An-Android-App-With-Android-Studio/
http://www.javaworld.com/article/3095406/android/android-studio-for-beginners-part-1-installation-and-setup.html

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Install VirtualBox Guest Additions on Ubuntu VirtualBox VM

If you’re using VirtualBox for virtualization, then VirtualBox Guest Additions is a must have tool for you. VirtualBox...

How to install LibreOffice 5.3.3 Office Suite on Ubuntu & Linux Mint

LibreOffice 5.3.3 recently released, is the latest fresh version of LibreOffice 5.3 series which was released in early February. It...
Chưa phân loại, vps giá rẻ
28/12/2020

[NGINX] Thiết lập chứng nhận SSL miễn phí từ Let’s Encrypt cho các website

SSL là chữ viết tắt của Secure Sockets Layer (Lớp socket bảo mật) –...
30/12/2020