System Prerequisites and JDK Setup
A 64-bit Linux distribution is required to run the IDE efficiently. Before installing the IDE itself, ensure the Java Development Kit is present on the system. For Ubuntu or Debian-based systems, execute the following commands to update package lists and install OpenJDK 17:
sudo apt update
sudo apt install openjdk-17-jdk -y
IDE Installation and Execution
Obtain the latest tarball from the official developer site. Once downloaded, extract the archive to a system-wide directory such as /opt to make it accessible for all users. Navigate to the binary folder and initiate the startup script:
sudo tar -xzf android-studio-*.tar.gz -C /opt
cd /opt/android-studio/bin
./studio.sh
Upon the first launch, the setup wizard will prompt for Android SDK comopnents. Follow the on-screen instructions to download necessary platform tools and build tools.
Basic Application Implementation
The following class demonstrates a simple interaction where a button press updates a text view with the current timestamp. This replaces the stanadrd "Hello World" template logic.
package com.example.linuxdemo;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class MainActivity extends AppCompatActivity {
private TextView statusDisplay;
private Button triggerAction;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
statusDisplay = findViewById(R.id.status_text);
triggerAction = findViewById(R.id.action_button);
triggerAction.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
String currentTime = formatter.format(new Date());
statusDisplay.setText("Last Click: " + currentTime);
}
});
}
}
Ensure the corresponding layout XML file defines the status_text and action_button IDs to match the Java references.