Pocket Studio Academy
HomePart 00.4

What just happened? Anatomy of your app

Free lesson9 min read·4 questions

You have a working app and about twenty files you did not write. This lesson opens the box: what every file in the project is for, which two you will actually edit, and where app-debug.apk came from.

Twenty files, and you only wrote one line

Pocket Studio made a lot of files in Lesson 0.3. You typed into exactly one of them.

That is normal and it is not a trick. Every Android has the same skeleton, because and Android both need certain things in certain places. Once you have seen the skeleton once, you can open any Android project ever made and know where to look.

Ten minutes here saves you from the most demoralising beginner experience there is: opening a project, seeing files you do not recognise, and quietly closing it again.

Think of it like this

Think about a house that has just been built.

There are the architect's plans — big sheets of paper covered in measurements. They are not part of the house. You do not live in them. But without them there is no house.

There are the rooms — the part you actually live in.

There is the plate by the front door with the house number and the family name on it. Tiny, but it is how the postman finds you.

And there is the skip in the driveway, full of offcuts and packaging from the build, which nobody keeps.

Your project has all four. The plans are the Gradle files. The rooms are src. The plate is the manifest. The skip is the build folder, and it is safe to throw away at any time.

The whole tree

Here it is. Ignore the detail for a moment and just notice that it splits cleanly in two.

text
1Hello Pocket/
2├── settings.gradle.kts
3├── build.gradle.kts
4├── gradle.properties
5├── gradlew
6├── gradle/
7│   ├── libs.versions.toml
8│   └── wrapper/
9└── app/
10    ├── build.gradle.kts
11    └── src/main/
12        ├── AndroidManifest.xml
13        ├── java/com/yourname/hellopocket/
14        │   └── MainActivity.kt
15        └── res/
16            ├── values/strings.xml
17            ├── values/themes.xml
18            └── mipmap-anydpi-v26/

Everything ending in .kts, .properties or .toml is how to build it.

Everything under app/src/main is what to build.

Beginners lose hours by not knowing which half a file is in. A build.gradle.kts mistake stops the build before your code is even read; a MainActivity.kt mistake is your app misbehaving. Different problems, different places to look.

Half one — the plans

settings.gradle.kts

Two jobs. It names the project, and it lists which are in the build.

A module is a part of the project that gets built into one thing. Hello Pocket has exactly one, called :app. Big apps split into several; yours will not, all course.

It also lists where Gradle is allowed to download from — Google's repository and Maven Central. Those two lines are why implementation(...) works at all.

build.gradle.kts (the top-level one)

Short and slightly odd. It names the plugins the build uses — the Android plugin, the Kotlin plugin, the Compose plugin — but switches them off with apply false. It is a declaration, not an instruction. The module below turns them on.

app/build.gradle.kts — the one you will edit

This is the most important build file in the project, and the one you come back to whenever you add a . The interesting part:

app/build.gradle.ktskts
1android {
2  namespace = "com.yourname.hellopocket"
3  compileSdk = 35
4
5  defaultConfig {
6    applicationId = "com.yourname.hellopocket"
7    minSdk = 26
8    targetSdk = 35
9    versionCode = 1
10    versionName = "1.0"
11  }
12}
  • — the name your code lives under while it is being compiled.
  • — the app's permanent, globally unique ID on a device and in the Play Store. It starts identical to the namespace, and the two are free to differ later.
  • 35 — which version of Android's code library you are allowed to type against. It does not affect which phones can install the app.
  • 26 — the oldest Android that will accept your APK.
  • 35 — the version you promise you have tested on.
  • versionCode / versionName1 is what Android compares to decide "is this an update?". "1.0" is the human-readable one people see.

Underneath sits a dependencies { } block listing the borrowed code your app uses. Hello Pocket's list is deliberately tiny — Compose, Material 3, and the glue that connects an Activity to Compose. Nothing else.

That matters more here than on a laptop. You are building on a phone: fewer dependencies means faster, cooler builds. Every entry in that list is something Gradle has to fetch, unpack and feed to the compiler on a device running off a battery.

gradle/libs.versions.toml

The : one file listing every version number in the project, so they are declared once rather than sprinkled across files.

gradle/libs.versions.tomltoml
1[versions]
2agp = "8.7.3"
3kotlin = "2.1.0"
4composeBom = "2024.12.01"

When a build file says libs.plugins.kotlin.android, it is reading this file. To upgrade Kotlin across the whole project you change one number here.

gradlew and gradle/wrapper/

The . gradlew is a small launcher script, and beside it is a file naming the exact Gradle version this project wants — gradle-8.11.1-bin.zip.

This is why nobody installs Gradle. Every project carries the exact version it was built with, downloads it on first use, and builds identically for everyone. It is also why your first build had a Downloading gradle-8.11.1-bin.zip line and your second did not.

gradle.properties

Settings for the build process itself, rather than for your app — chiefly how much memory Gradle may use. You will not touch it in this course.

Half two — the rooms

app/src/main/AndroidManifest.xml

Your app's ID card. Android reads this before it will run a single line of your code.

AndroidManifest.xmlxml
1<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2  <application
3    android:icon="@mipmap/ic_launcher"
4    android:label="@string/app_name"
5    android:theme="@style/Theme.HelloPocket">
6    <activity
7      android:name=".MainActivity"
8      android:exported="true">
9      <intent-filter>
10        <action android:name="android.intent.action.MAIN" />
11        <category android:name="android.intent.category.LAUNCHER" />
12      </intent-filter>
13    </activity>
14  </application>
15</manifest>

The <intent-filter> block is the interesting one. MAIN plus LAUNCHER is Android's way of saying "this is the screen to open when someone taps the icon". Delete those five lines and your app builds perfectly, installs perfectly, and has no icon in the launcher at all.

android:exported="true" says other apps — including the home screen — are allowed to start this . A launcher screen must be exported; screens deep inside your app usually should not be.

Notice that nothing here says "Hello Pocket". It says @string/app_name, which is a pointer. Which brings us to:

app/src/main/res/ — the

Everything in your app that is not code: text, colours, icons, shapes.

res/values/strings.xmlxml
1<resources>
2  <string name="app_name">Hello Pocket</string>
3</resources>

That is where the words under your icon actually live. Keeping text out of the code is what makes translating an app possible later: add a values-fr/strings.xml and French phones pick it up with no code change at all.

values/themes.xml holds the theme the manifest points at. mipmap-anydpi-v26/ holds the launcher icon, which Part 6 replaces with something you designed.

app/src/main/java/.../MainActivity.kt

Your code. The only file you have written in so far, and the file the manifest names with android:name=".MainActivity".

The folder path matches the package line at the top of the file. That is not a coincidence — if you move the file without changing the package line, the build fails.

9:41▲ ▮
Hello Pocket
▾ app
▾ src / main
AndroidManifest.xml
▾ java / com / yourname
MainActivity.kt
▾ res / values
strings.xml
themes.xml
build.gradle.kts
build.gradle.kts
settings.gradle.kts
▸ gradle
▸ build  (generated)
green = how to build it
amber = what to build
Projects
Editor
Build

The project tree in Pocket Studio. Plans at the top, rooms inside app/src.

And the thing that came out

There is one more folder: app/build/. You did not make it — Gradle did, during the build. Everything in it can be deleted safely, and Gradle will make it again next time.

Deep inside is the file that is your app:

text
app/build/outputs/apk/debug/app-debug.apk

Unzip an — it really is a zip file — and you find roughly this:

text
1app-debug.apk
2├── AndroidManifest.xml    packed into a compact binary form
3├── classes.dex            all your compiled code, in one file
4├── resources.arsc         your text and colours, indexed
5├── res/                   icons and other picture files
6└── META-INF/              the signature that proves it is yours

classes.dex is the interesting one. Your was compiled into an intermediate form, and then a tool called d8 repacked it into , the format Android's runtime actually executes. That is the dexBuilderDebug line you watched scroll past.

META-INF/ holds the signature. Yours came from an automatic throwaway key, which is what makes it a — instantly installable on your own phone, and not publishable. Part 6 covers the other kind.

Try it in Pocket Studio

Two edits, one build, and the app on your home screen changes its name.

  1. Open Hello Pocket in Pocket Studio.
  2. In the project tree, open appsrcmainresvaluesstrings.xml.
  3. Change Hello Pocket between the <string> tags to something else — My First App works. Do not change name="app_name", only the text between the tags.
  4. Open AndroidManifest.xml and find android:label="@string/app_name". Notice that it still says @string/app_name and does not need changing. That is the pointer doing its job.
  5. Tap BuildRun ▶. This build should take well under a minute.
  6. Press Home. The label under your icon has changed.
  7. Now open app/build/outputs/apk/debug/ in the project tree and confirm app-debug.apk is sitting there. That file is your app.
  8. Optional, and safe: delete the whole app/build folder, then press Run again. Watch Gradle rebuild it from nothing — quickly, because the downloads are still cached.
Error Doctor5 common errors
error: resource string/app_name (aka com.yourname.hellopocket:string/app_name) not found.
MeansSomething — almost always the manifest — is pointing at a string that does not exist. You either renamed app_name in strings.xml or deleted the line.
FixOpen res/values/strings.xml and make sure a line reads <string name="app_name">...</string>. The name must match exactly, including underscores.
AAPT: error: resource style/Theme.HelloPocket not found.
MeansThe manifest asks for a theme that no longer exists under that name. Renaming a theme in themes.xml without updating the manifest gives you this every time.
FixOpen res/values/themes.xml, read the exact name= of the style, and make android:theme="@style/..." in the manifest match it character for character.
SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in your project's local.properties file.
MeansThe build cannot find the Android SDK. This appears when a project was created on a computer and copied here — its local.properties still points at a folder that exists only on that computer.
FixDelete local.properties from the project and let Pocket Studio supply its own SDK location. Projects you create on the phone never have this file, and never have this problem.
Plugin [id: 'com.android.application', version: '8.7.3'] was not found in any of the following sources:
MeansGradle was told to use the Android plugin but had nowhere to download it from. The pluginManagement { repositories { ... } } block in settings.gradle.kts is missing or has been emptied.
FixOpen settings.gradle.kts and make sure google(), mavenCentral() and gradlePluginPortal() are all listed inside pluginManagement { repositories { } }.
Script compilation error: Line 9: implementation(libs.androidx.material3) ^ Unresolved reference: libs
MeansA build file is referring to the version catalog, but Gradle cannot see it. Usually gradle/libs.versions.toml has been renamed, moved out of the gradle/ folder, or deleted.
FixConfirm the file is at exactly gradle/libs.versions.toml, spelled that way. The name and location are fixed — Gradle does not go looking for it anywhere else.
Recap
  • A project splits in two: build files (how to build it) and app/src/main (what to build).
  • app/build.gradle.kts holds , , and the list — fewer dependencies means faster builds on a phone.
  • The is your app's ID card, and its MAIN + LAUNCHER is what puts an icon on the home screen.
  • Text, colours and icons are under res/, referenced as @string/app_name rather than written into code.
  • The build produces app-debug.apk — a zip holding your compiled code as , your resources, and a signature.
  • Next: we slow right down and look at code itself. What it is, why the machine is so literal about it, and how to read a line you have never seen.