javac -version
'.JAVA_HOME
is set to the JDK installation directory via command 'set JAVA_HOME
'. Otherwise, Follow the steps HERE.android-studio-ide-182.xxxxxxx-windows.exe
.C:Program FilesAndroidAndroid Studio
' ⇒ Follow the on-screen instruction and accept the defaults to complete the installation. You need about 3-4GB of free disk space! Take note (and take photo) on the installation locations of 'Android Studio' (by default @ 'C:Program FilesAndroidAndroid Studio
') and the 'Android SDK' (by default @ c:UsersusernameAppDataLocalAndroidSdk
).android-studio-ide-182.xxxxxxx-mac.dmg
..dmg
' installation file ⇒ You may watch a short video @ https://developer.android.com/studio/install.~/Library/Android/sdk
' by default, where ~ denotes your home directory.c:UsersusernameAppDataLocalAndroidSdk
⇒ Finish. /Users/username/Library/Android/sdk
' (aka '~/Library/Android/sdk
') ⇒ Finish. compileSdkVersion
' and 'targetSdkVersion
' from 26 to 27 (we have installed API-27) and 'com.android.support:appcompat-v7:26.x.x
' to '27.0.0
'.C:Usersusername.gradlewrapperdists
' and delete 'gradle-x.x-all
'. Take note the '.gradle
' is a hidden directory and you need to enable viewing of hidden directory.~.gradlewrapperdists
' and delete 'gradle-x.x-all
'. Take note the '.gradle
' is a hidden directory and you need to enable viewing of hidden directory.C:Usersyour-usernameAppDataLocalAndroidSdkextrasintelHardware_Accelerated_Execution_Manager
' for Windows or '~/Library/Android/sdk
/extras/intel/Hardware_Accelerated_Execution_Manager
' for Mac OS X) ⇒ run 'intelhaxm-android.exe
' to install HAXM ⇒ Be patient! The installer may take a while to launch ⇒ Follow the screen instructions to complete the setup.AppData
' directory is hidden. You need to unhide via 'Control Panel' ⇒ 'Folder Options' (or 'File Explorer Options' in Windows 10) ⇒ Check 'Show hidden files, folders, and drives'. (b) In Mac OS X, the 'Library
' folder is hidden. You can unhide via 'Finder' ⇒ Go ⇒ Home ⇒ Settings ⇒ Show View Option.app
' node. Expand the 'java
' node. Expand the 'com.example.helloandroid
' package node. Open the 'MainActivity.java
' (which actually has already been opened). REPLACE the onCreate()
method as follows and add the import statement. Do not touch the rest of the codes.Activity
.Activity
, which usually has a screen, is a single, focused thing that the user can interact with the application (hence called activity). The MainActivity
extends the android.app.Activity
class (or android.support.v7.app.AppCompatActivity
in the later version), and overrides the onCreate()
method. The onCreate()
is a call-back method, which is called back by the Android system when the activity is launched.View
is a UI component (or widget, or control). We construct a TextView
(which is a subclass View
for showing a text message), and set its text. We then set the content-view of the MainActivity
screen to this TextView
.AndroidManifest.xml
under 'app' ⇒ 'manifests'. It describes the Android app. Hello Android
' application, with an activity called MainActivity
, has the following manifest (generated automatically by the Android Studio when the project was built):<manifest>
element specifies the package name.<manifest>
contains one <application>
element.<application>
element specifies the icon, label (the app's title) and theme of this application. It contains one ore more <activity>
elements.<activity>
element declares its program name ('MainActivity
' in current package '.
'). It may contain <intent-filter>
.<intent-filter>
declares that this activity is the entry point (android.intent.action.MAIN
) of the application. This activity is to be added to the application launcher (android.intent.category.LAUNCHER
).TextView
component). It is more flexible and therefore recommended to layout your UI components via a descriptive XML layout file. In this way, you don't need to hardcode the views, and you can easily modify the look and feel of the application by editing the XML markups. The Java codes can therefore focus on the business logic.Hello Android XML
'.activity_main.xml
' (which is actually already opened). Android Studio provides two views for this XML file: 'Design (or Graphical)' and 'Text (or XML)' - selectable at the bottom of the panel.TextView
(text field) that holds a text string 'Hello World!
'. The TextView
component has width and height big enough to hold its content ('wrap_content
').TextView
(as in the above XML file), we shall use a string reference (similar to a variable) for better flexibility.res/values
node. Open strings.xml
, and ADD the line in red:string.xml
' defines 2 references/values:app_name
' contains the application's name, that you entered when you created the project.hello
' contains the value of 'Hello world from XML!
'.activity_main.xml
' to use the string reference 'hello
', in the format '@string/hello
', as follows:MainActitivy.java
' (under app/java/com.example.helloandroidxml
), as follows:MainActivity
' sets its content-view to 'R.layout.activity_main
', which is mapped to the XML layout file 'reslayoutactivity_main.xml
' that we have modified earlier.Hello, from XML!
' displayed.