Developing mobile games on Android is an exciting process that combines programming, design and creativity. With the advent Android Studio and powerful game engines, even a beginner can create his first game from scratch. But where to start? Which engine to choose? And how to avoid typical mistakes that slow down development?
This article will help you understand all the stages - from installing the necessary software to publishing the game in Google Play. We will consider two main approaches: creating a game in pure Java/Kotlin and using a popular engine Unity (through integration with Android Studio). We will pay special attention to performance optimization, adaptation to different screens and monetization. If you dream of your own game, but donโt know which way to approach it, youโre in the right place.
1. Preparing the working environment: what needs to be installed
Before you start development, you need to set up the working environment. Without the tools installed correctly, you risk running into compilation errors or compatibility issues. Here is the minimum set of software:
- ๐ฑ Android Studio (latest stable version) - official IDE for Android development. Download only from official websiteto avoid viruses.
- ๐ง Java Development Kit (JDK) versions 11 or 17. Android Studio may offer to install it automatically the first time you start it.
- ๐ฎ Unity Hub (if you plan to use Unity) + module
Android Build Support. - ๐ฆ Android SDK with packages for the latest versions of the API (API 33+ is recommended for new projects).
After installing Android Studio, launch it and wait for the initial setup to complete. Then go to SDK Manager (Tools โ SDK Manager) and install:
- Packages
Android SDK Platformfor the selected API. - Tools
Android SDK Build-Tools. - Emulators for testing (we recommend
Pixel 5c API 33).
โ ๏ธ Attention: If you are using Mac with an M1/M2 chip, make sure to download the version of Android Studio for Apple Silicon. Otherwise, emulators may not start or work extremely slowly.
For the convenience of game development, it is also useful:
- ๐ผ๏ธ GIMP or Photoshop to create 2D graphics.
- ๐ต Audacity or FL Studio for sound effects.
- ๐ Trello or Notion for scheduling tasks.
2. Choosing an engine: pure Android or Unity?
One โโof the key questions is what to write the game in. Each approach has pros and cons:
| Criterion | Pure Android (Java/Kotlin) | Unity (C#) |
|---|---|---|
| Difficulty for beginners | High (you need to know OOP, working with outline, physics) | Average (visual editor, ready-made assets) |
| Performance | Higher (native code) | Below (intermediate layer) |
| 3D support | Limited (must be used OpenGL ES) |
Full (built-in tools) |
| Monetization | Manual SDK integration (AdMob, in-app purchases) | Ready plugins (Unity Ads, IAP) |
Pure Android suitable if:
- You already know Java or Kotlin and want full control over the code.
- Planning a simple 2D game (for example, Flappy Bird or 2048).
- Maximum performance is important (for example, for arcade games with high FPS).
Unity choose if:
- You need cross-platform (iOS, PC, consoles).
- You want to create a 3D game with physics and animations.
- A quick prototype with minimal code is important.
If you are a beginner, start with a simple 2D project on pure Android. This will help you understand. the basics of the game loop, touch processing and rendering. It is better to master Unity after basic programming experience.
3. Creating the first project: step by step
Let's consider the process using the example of a simple 2D game in Kotlin (similarly for Java). avoiding falling objects.
3.1. Creating a new project
In Android Studio, select New Project โ Empty Activity. Specify:
- Project name:
SimpleGame. - Language: Kotlin.
- Minimum SDK:
API 24 (Android 7.0)(covers ~95% of devices).
3.2. Setting up the playing field
Open the file activity_main.xml and replace the contents with SurfaceView โit will allow you to draw graphics in real time:
<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<SurfaceView
android:id="@+id/gameSurface"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>
3.3. Game logic: touch processing and rendering
Create a class GameView, inherited from SurfaceView, and implement in it:
- Thread for updating the game state (
Thread). - Touch handler (
onTouchEvent). - Method
drawfor displaying objects.
Example code for moving a square:
class GameView(context: Context) : SurfaceView(context), Runnable {private var playerX = 100f
private var playerY = 100f
private var thread: Thread? = null
private var isPlaying = false
init {
holder.addCallback(object : SurfaceHolder.Callback {
override fun surfaceCreated(holder: SurfaceHolder) {
startGame()
}
// ... other methods
})
}
override fun run() {
while (isPlaying) {
update() // Update the player's position
draw() // Redrawing the screen
Thread.sleep(17) // ~60 FPS
}
}
private fun update() {
// Motion logic
}
override fun onTouchEvent(event: MotionEvent): Boolean {
when (event.action) {
MotionEvent.ACTION_MOVE -> {
playerX = event.x
playerY = event.y
}
}
return true
}
}
โ๏ธ Preparing to test the game
4. Adding graphics and animations
Static objects are boring - let's add animation and sprites. To do this:
4.1. Uploading images
Place graphics files (for example, player.png) in the folder res/drawable. To support different resolutions, use subfolders:
drawable-mdpi(160 dpi)drawable-hdpi(240 dpi)drawable-xhdpi(320 dpi)
To upload an image to code:
val bitmap = BitmapFactory.decodeResource(resources, R.drawable.player)
4.2. Sprite animation
For smooth animation (for example, a character running), use AnimationDrawable or a custom class. Example for animation of 4 frames:
val frame1 = BitmapFactory.decodeResource(resources, R.drawable.run1)val frame2 = BitmapFactory.decodeResource(resources, R.drawable.run2)
// ... frame3, frame4
val frames = listOf(frame1, frame2, frame3, frame4)
var currentFrame = 0
fun update() {
currentFrame = (currentFrame + 1) % frames.size
// Rendering frames[currentFrame]
}
4.3. Graphics optimization
Using vector images (SVG) via VectorDrawable can reduce APK size by 30-50% compared to raster graphics. To convert SVG to XML, use Android Studio Vector Asset Studio (File โ New โ Vector Asset).
โ ๏ธ Attention: Avoid loading highly detailed textures (more than 2048x2048 in size) on mobile devices. This can lead to OutOfMemoryError on weak devices.
How to reduce the size of APK?
1. Use WebP format instead of PNG/JPG (lossless compression). 2. Remove unused resources via Refactor โ Remove Unused Resources. 3. Enable texture compression in build.gradle:
android {buildTypes {
release {
crunchPngs true // PNG compression
}
}
}
5. Working with sound and music
Sound effects and background music make the game come alive. In Android there is a class for this SoundPool (for short sounds) and MediaPlayer (for music).
5.1. Adding sound files
Place files in the format .mp3 or .ogg to the folder res/raw. For example, res/raw/background_music.mp3.
5.2. Playing sounds
Initialization SoundPool:
val soundPool = SoundPool.Builder().setMaxStreams(5) // Maximum 5 sounds simultaneously
.build()
val soundId = soundPool.load(context, R.raw.explosion, 1)
Playing:
soundPool.play(soundId, 1f, 1f, 0, 0, 1f)
5.3. Background music
For music, use MediaPlayer:
val mediaPlayer = MediaPlayer.create(context, R.raw.background_music)mediaPlayer.isLooping = true // Looping
mediaPlayer.start()
โ ๏ธ Attention: Always release audio object resources in theonDestroy()activity method to avoid memory leaks:override fun onDestroy() {super.onDestroy()
soundPool.release()
mediaPlayer.release()
}
6. Testing and optimization
Before release, the game must be tested on different devices and optimized. Here are the key aspects:
6.1. Testing on real devices
Emulators do not always show real performance. Use:
- ๐ฑ Devices with different screens (4", 5.5", 6.5").
- ๐ Different versions of Android (from 7.0 to 14).
- ๐ฎ Gamepads (if you support).
6.2. Performance profiling
Android Studio has built-in analysis tools:
- CPU Profiler โshows processor load.
- Memory Profiler โmonitors memory leaks.
- GPU Rendering โidentifies rendering problems.
To open the profiler, select View โ Tool Windows โ Profiler.
6.3. Code optimization
Some tricks to speed up the game:
- ๐ Use
Object Poolto reuse objects (for example, bullets or enemies). - ๐๏ธ Avoid creating objects in a loop
update(). - ๐ผ๏ธ Turn off unnecessary transparency layers (
setHasTranslucentBackground(false)).
Test the game on devices with 2 GB of RAM - if it runs smoothly there, then there will be no problems on flagships.
7. Publishing on Google Play
When the game is ready, it's time to share it with world! The publishing process in Google Play Console consists of several steps:
7.1. Preparation of materials
You will need:
- ๐ APK/AAB file (recommended
.aab- it is 15-20% less). - ๐ผ๏ธ Game icon (512ร512, without transparency).
- ๐ธ Screenshots (minimum 2, preferably 4-6 for different resolutions).
- ๐ฌ Video preview (optional, but increases conversion).
- ๐ Description in Russian and English (up to 4000 characters).
7.2. Assembly of the release version
B build.gradle set up a signature:
android {signingConfigs {
release {
storeFile file("keystore.jks")
storePassword "your_password"
keyAlias "your_alias"
keyPassword "your_password"
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Collect .aab via Build โ Generate Signed Bundle / APK.
7.3. Upload to Google Play Console
Go to Google Play Console i:
- Create a new application.
- Fill in the information about the game (name, category, age rating).
- Upload
.aabto the sectionProduction. - Indicate the price (free or paid).
- Set up monetization (advertising, purchases).
- Submit for review (usually takes 1-3 days).
โ ๏ธ Attention: Google charges one-time fee of $25 for registering a developer account. Also, a commission of 15-30% is charged on sales, depending on the type of monetization.
8. Monetization: how to make money on the game
There are several ways to monetize mobile games:
| Method | Pros | Cons | Tools |
|---|---|---|---|
| Advertising (banners, videos) | Passive income, easy to integrate | May annoy players | AdMob, Unity Ads |
| Paid application | Pay once - play without restrictions | Difficult to compete with free games | Google Play Billing |
| In-app purchases (IAP) | Flexibility (you can sell skins, levels) | Requires balance so as not to make the game "pay-to-win" | Google Play Billing |
| Subscription | Stable income | Not suitable for all genres | Google Play Billing |
For integration AdMob add dependency to build.gradle:
implementation 'com.google.android.gms:play-services-ads:22.6.0'
Example of banner display:
val adView = AdView(this)adView.adUnitId = "ca-app-pub-3940256099942544/6300978111" // Test ID
adView.adSize = AdSize.BANNER
adView.loadAd(AdRequest.Builder().build())
The most profitable model for indie games is a combination of advertising + optional purchases (for example, removing ads for $2).
FAQ: Frequently asked questions about creating games in Android Studio
Is it possible to create a 3D game without Unity?
Yes, but this will require deep knowledge OpenGL ES or Vulkan. For 3D rendering on pure Android, use the following libraries:
- Rajawali โa simplified 3D engine.
- LibGDX โa cross-platform framework with 3D support.
However, for most 3D projects Unity or Unreal Engine will be more effective solutions.
How to test a game on several devices at the same time?
Use a service Firebase Test Labthat allows you to:
- Run tests on real devices in the cloud.
- Check compatibility with different versions Android.
- Receive screenshots and error logs.
For local testing, connect several devices via USB and select them in Android Studio via Run โ Select Device.
How long does it take to develop a simple game?
Time depends on complexity:
- 2D platformer (type Doodle Jump): 1-3 months (for a beginner).
- Puzzle (type Candy Crush): 3-6 months.
- 3D game (even simple): 6+ months.
Tip: start with MVP (minimally working version) and gradually add features.
Do I need to register an individual entrepreneur to publish a game?
No, an individual can publish games in Google Play without an individual entrepreneur. However:
- If income exceeds 300 thousand rubles. per year, you need to pay personal income tax (13%).
- To work with foreign payment systems (for example, Stripe), you may need an individual entrepreneur.
- When registering on Google Play, provide your real data - they will be checked.
How to protect the game from piracy?
There is no complete protection, but you can make life difficult for pirates:
- Use
ProGuardto obfuscate the code (included inbuild.gradledefault). - Check license via Google Play Licensing.
- Implement server-side validation of purchases (for IAP).
- Add online activation (but this may annoy legitimate users).
Remember: most pirated copies are distributed through third-party sites, not Google Play.