Development of mobile applications for Android remains one of the most popular IT specialties: according to data Stack Overflow, more than 40% of professional developers work with this in one way or another platform. But where to start if you've never written code for smartphones? This article will help you understand the basics - from choosing a programming language to publishing a finished application in Google Play.
We will not delve into the theory of algorithms or low-level programming. Instead, let's focus on practical steps: how to install the necessary tools, write your first application in Kotlin or Java, test it on an emulator and avoid typical beginner mistakes. And if you already have experience in developing for other platforms, you will find here a comparison of approaches and tips on adapting existing skills.
It is important to understand: since 2023, Google officially recommends using Kotlin as the main language for Android development, but Java support remains for legacy projects. This doesn't mean that Java is outdated - it's just that Kotlin offers more modern syntax and better integration with the Android SDK. In this article we will look at both options so that you can choose the one that suits you.
1. Choosing a programming language: Kotlin vs Java
The first question that beginners ask: what language to write for Android? The official documentation clearly recommends it, but is still widely used. Let's compare both options: Google definitely recommends Kotlin, But Java is still widely used. Let's compare both options:
- ๐ Kotlin - a modern language with a concise syntax, full compatibility with Java and built-in support for coroutines for asynchronous operations. Ideal for new projects.
- ๐ผ Java - a time-tested language with a huge number of libraries and frameworks. Suitable for supporting older applications or if you plan to develop in enterprise development.
- โก C++/Rust โ used for high-performance components (for example, games or graphics processing), but require deep knowledge.
For absolute beginners, we recommend starting with Kotlin โits syntax is more intuitive, and development tools (for example, Android Studio) are optimized for this language. If you already know Java, you can continue to use it, but gradually master it and Kotlin for new features.
โ ๏ธ Attention: When choosing a language, consider the requirements of the employer or customer. Some companies still use Java for Android projects, especially when it comes to banking applications or systems with high security requirements.
| Criteria | Kotlin | Java |
|---|---|---|
| Ease of learning | โญโญโญโญโญ | โญโญโญ |
| Compatibility with Android SDK | Full (official support) | Full (but some features require wrappers) |
| Performance | Comparable to Java | Slight advantage in some cases |
| Support for coroutines/threads | Built-in (coroutines) | Requires RxJava or other libraries |
2. Installation and configuration of Android Studio
Android Studio is the official development environment (IDE) from Google, which includes everything you need to create Android applications: a code editor, a device emulator, debugging and analytics tools. You can download it for free from the official website. Minimum PC requirements:
- ๐ฅ๏ธ OS: Windows 8/10/11 (64-bit), macOS 10.14 or later, or any modern Linux distribution.
- ๐พ RAM: Minimum 8 GB (16 GB recommended for working with the emulator).
- ๐ฆ Disk space: At least 4 GB for the IDE itself + 1-2 GB for SDK and emulators.
After installing Android Studio, follow these steps:
Install the latest version of Android Studio from the official site|
Download and install the necessary SDK components (the IDE itself will offer you upon first launch)|
Create a new project with the "Empty Activity" template|
Set up a device emulator (Pixel 5 with Android 13 is recommended)|
Connect a physical device debugging device (optional)-->
If you are using Windows, make sure that virtualization is enabled in the BIOS (for the emulator to work). On macOS may need to be installed Homebrew to manage dependencies. For Linux check the availability of packages libc6:i386, libncurses5 and others that the system will require.
โ ๏ธ Attention: When installing the SDK, avoid paths with spaces or Cyrillic characters (for example,C:\app Files\...). This may lead to build errors. Use shortcuts likeC:\Android\SDK.
After setup, check the system's functionality by running an empty project on the emulator. If everything works, you will see the standard application with the inscription "Hello World". If errors occur, refer to the logs in the window Build Output โit usually indicates which component is missing or incorrectly configured.
3. Android project structure: what lies where
When you create a new project in Android Studio, the IDE generates a standard file structure. Understanding it is critical so as not to get lost in the code. Here are the main directories and files:
- ๐
app/src/main/java/โ here is the source code of your application (activities, fragments, classes). - ๐
app/src/main/AndroidManifest.xmlโ application manifest, where all components (activities, services) and permissions are declared. - ๐จ
app/src/main/res/โ resources: layouts (layout/), images (drawable/), lines (values/strings.xml). - ๐ ๏ธ
app/build.gradleโ build configuration, dependencies and SDK version. - ๐ฆ
gradle/โ build system files Gradle.
Pay special attention to the file AndroidManifest.xml. Specify here:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.example.myapp">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
In this file you declare:
- ๐ Application package name (
package). - ๐ง Permissions (for example, access to the Internet or camera).
- ๐ฑ Application components (activities, services, receivers).
Always check AndroidManifest.xml before building the APK. Errors in this file (for example, typos in activity names) cause the application to crash on startup, but are not always obvious at the compilation stage.
4. Creating the first application: "Hello World" in Kotlin
Let's write a simple application that displays text and responds to button clicks. We will use Kotlin and standard components Android SDK.
Step 1: Interface design
Open the file res/layout/activity_main.xml and switch to mode Code (not Design). Replace the content with:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<TextView
android:id="@+id/helloText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, Android!" />
<Button
android:id="@+id/clickButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click me" />
</LinearLayout>
Step 2: Logic in MainActivity
Now open MainActivity.kt (located in java/com.example.myapp/) and add a handler press:
class MainActivity : AppCompatActivity() {override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val button = findViewById<Button>(R.id.clickButton)
val textView = findViewById<TextView>(R.id.helloText)
button.setOnClickListener {
textView.text = "The button is pressed! ๐"
}
}
}
Step 3: Launch on the emulator
Press the green button Run (or Shift + F10) and select the previously configured emulator. In a few seconds you will see your application with a button. When clicked, the text will change.
Always test the application on several versions of Android (for example, 11, 12, 13). Some APIs may behave differently or be missing on older devices.
5. Debugging and testing: how to find and fix errors
Errors in Android development are divided into three types:
- Compilation errors - syntax errors in the code that prevent the project from being built. Fixed in the IDE.
- Runtime errors โexceptions that occur while the application is running (for example,
NullPointerException). - Logical errors โthe application runs, but does not behave as intended.
Basic debugging tools in Android Studio:
- ๐ Logcat โ system message log All logs are displayed here, including errors (
ERROR) and warnings (WARNING). - ๐ Debugger โ allows you to step through the code and monitor the values. variables.
- ๐ Android Profiler โ analyzes the use of CPU, memory and energy.
Example of use Logcat:
// In code (for example, in MainActivity.kt)Log.d("MyApp", "This is a debug message")
Log.e("MyApp", "This is an error message", exception)
// In Logcat, filter logs by tag "MyApp"
For UI testing, we recommend using Espresso (for unit tests) and UI Automator (for complex testing). Example of a simple test with Espresso:
@RunWith(AndroidJUnit4::class)class MainActivityTest {
@get:Rule
val activityRule = ActivityTestRule(MainActivity::class.java)
@Test
fun testButtonClick() {
onView(withId(R.id.clickButton)).perform(click())
onView(withId(R.id.helloText)).check(matches(withText("The button is pressed! ๐")))
}
}
โ ๏ธ Attention: When testing on a physical device, turn on USB debugging in the developer settings. On some devices (for example Xiaomi or Huawei), you additionally need to enable debugging in MIUI/EMUI.
How to enable developer mode on Android
1. Go to Settings โ About phone.
2. Find the item Build number and click on it 7 times.
3. Return to the main settings menu - a new section will appear For Developers.
4. Enable USB debugging and Do not turn off the screen (optional).
6. Publishing to Google Play: Requirements and Process
Once your app is ready, you can publish it to Google Play Console. To do this you will need:
- ๐ฐ Registration fee: $25 (one-time).
- ๐ Developer account: register on
play.google.com/console. - ๐ฆ Signed APK/AAB: the application must be signed by the release key.
- ๐ Manifesto and policies: the application must comply with the rules Google Play (for example, do not collect user data without consent).
Publishing process:
- Collect the release version of the application (
Build โ Generate Signed Bundle / APK). - Download
.aab(Android App Bundle) to Google Play Console. - Fill in information about the application: name, description, screenshots (minimum size - 320px), icon (512x512 px).
- Indicate the category, age rating and price (free or paid).
- Submit for review. Typically, verification takes 1-3 days.
Typical reasons for application rejection:
- ๐ซ Violation of the privacy policy (for example, collecting data without
Privacy Policy). - ๐ Inconsistency with the age rating (for example, adult content without labeling).
- ๐ฑ Poor optimization (app crashes on most devices).
โ ๏ธ Attention: Since 2021, Google requires that all new applications be published in Android App Bundle (.aab)rather than APK format. This allows you to optimize the download file size for different devices.
| File type | APK | AAB |
|---|---|---|
| Format | Universal package | Modular package |
| Size | Fixed (can be large) | Optimized for the device |
| Support for dynamic features | โ No | โ Yes |
| Google Play required? | โ No (can be installed manually) | โ Yes (only for Play Market) |
7. Optimization and monetization: how to make money from the application
Even a simple application can be monetized. Basic ways:
- ๐ณ Paid application โusers pay for downloading. Suitable for niche applications with a unique feature. functionality.
- ๐ฏ Advertising - integration AdMob, Facebook Audience Network or other networks. Income depends on the number of impressions.
- ๐ In-app purchases - sale of premium features, virtual goods or subscriptions.
- ๐ค Affiliate apps โfor example, links to products with Amazon or AliExpress.
To integrate advertising through AdMob:
- Register on
admob.google.comand create a banner or interstitial ad. - Add a dependency to
build.gradle:implementation 'com.google.android.gms:play-services-ads:22.6.0' - Place the ad unit in the layout:
<com.google.android.gms.ads.AdViewandroid:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111"/> - Download the updated application in Google Play.
To optimize performance:
- ๐ Use
RecyclerViewinsteadListViewfor long lists. - ๐ผ๏ธ Compress images using WebP instead of PNG/JPEG.
- ๐๏ธ Remove unnecessary dependencies in
build.gradleโthey increase the size of the APK. - ๐ Optimize your network experience: use caching and execute queries in a background thread.
Before publishing, test the application on devices with different screen resolutions and Android versions. Use Firebase Test Lab for automatic testing on virtual devices.
FAQ: Frequently asked questions about Android development
Is it possible to develop for Android on Mac or Linux?
Yes, Android Studio officially supports macOS and Linux (including Ubuntu, Fedora and other distributions). The only difference is that on Linux you may need to manually install some dependencies (for example lib32z1 or libncurses5). On Mac, make sure you have the latest version installed Xcode (to work with the emulator).
How long does it take to learn Android development from scratch?
Time depends on your programming experience:
- ๐ข Beginner without experience: 3-6 months to master basics Kotlin/Java, Android SDK and creation of first applications.
- ๐ Experienced programmer (knows OOP, works with other languages): 1-2 months to adapt to Android specifics.
We recommend taking the official course Android Basics in Kotlin from Google - it is free and covers all key topics.
How to test an application on a real device without Google Play?
You can install the APK on a physical device device without publishing to Google Play:
- Collect
APKin Android Studio (Build โ Build Bundle(s) / APK(s) โ Build APK). - Transfer the file
.apkto the device (for example, via USB or cloud storage). - On the device allow installation from unknown sources (
Settings โ Security โ Unknown sources). - Run the APK file - the application will be installed.
For convenience, use the command adb install app-debug.apk from the terminal (requires a USB connection and enabled debugging).
What should I do if Google Play rejected my application?
First, carefully read the letter with the reason for rejection. Most often, problems are related to:
- ๐ Violation privacy policy: add a link to
Privacy Policyin the application description. - ๐ฎ Content inconsistency: if your application is for children, but contains advertising without marking, it will be blocked.
- ๐ Crashes on devices: test on emulators with different versions of Android.
Fix the problems and resubmit the application for review. If you do not agree with the decision, you can appeal through the form in Google Play Console.
Do I need to know Java if I want to learn Kotlin?
No, Kotlin is an independent language, and it can be learned without knowledge Java. However, understanding Java will help:
- ๐ Read old documentation or code of legacy projects.
- ๐ง Work with libraries written in Java.
- ๐ผ Pass interviews - some companies still ask for Java in interviews.
If your goal is only Android development, you can limit yourself to Kotlin and study Java as needed.