Skip to content
papuh

Building apps

Tools and the first build

Claude Code, Android Studio, a cable and a phone. Code written blind, a hurdle with Java and sixteen tests, one of which failed for a good reason.

Treatment decisions are made by a doctor. This describes building an app, not advice.

What I needed

The list was shorter than I expected:

  • Claude Code, an AI tool that works directly on the computer. It runs as part of a Claude subscription.
  • Android Studio, the development environment for Android. It is free. It brings the tools to build an app and a phone emulator.
  • A cable between the computer and the phone.
  • A phone in developer mode with USB debugging turned on. That is in the next part.

Code written blind

An interesting detail: all the code of the first version was written before I had Android Studio on the computer. The AI wrote it without a compiler, so without any way to check whether it would even build. The calculation, the schedule, storage, export, reminders, six screens and automated tests on top.

The AI said so itself in the brief: the tool versions are a guess and errors at the first build are likely. The brief even warned in advance about one specific trap: the build tool in the chosen version does not run on the newest Java.

First hurdle: Java

That is exactly what happened. Android Studio has its own, newer Java. The build tool would not run on it. The first time I opened the project, Studio itself offered to switch to Java 21, and I accepted.

So that it would not depend on whatever Studio happens to pick, the AI changed the project’s start script so that it always uses Java 21 on its own. Since then everything I do with the app goes through one script with a few commands: tests, building the install file and installing on the phone.

The first build

Once Java was sorted, the first build passed without a single change to the app’s code. The compiler did not print even a warning. The code written blind was fine.

There were sixteen tests. Fifteen passed. One failed.

A test that failed correctly

This is where it became clear why the brief had the point “do not change the meaning of the calculation to make a test pass”. When a test fails, the easiest thing is to change the code so it gives the expected number. But the bug was not in the app. It was in the test.

When writing the test, the AI miscalculated one expected value, the product of two numbers. The app calculated correctly; the test expected a wrong number. So the fix went into the test, not the app, together with an explanation of why the original expectation was wrong.

Without that rule the opposite could have happened: the app would have been “fixed” to match the wrong test, and the two would have confirmed each other’s mistake.

What a test is and why I trust it more than my eyes

A test is a small piece of code that calls the calculation with values known in advance and compares the result with what it should be. The tests in this app run on the computer without the phone. With every change I run them and see whether something that worked yesterday has stopped working today.

On the phone screen I might not notice a mistake in one number. A test notices it every time. That is why there is a rule that every change to the calculation has a test.

But tests have a limit that I only understood later. They check that the app calculates correctly with the values it gets. They do not check that the values I enter are correct. That is the story of part five.

The app’s interface and the reminders are not covered by automated tests. I check those by hand on the phone.

The result of the day

At the end of the first day I had:

  • sixteen green tests,
  • an install file for the app, around 10 MB,
  • the tool versions that actually work written down, so nobody has to guess them next time.

On the same day the app also ended up on my phone. How, is in the next part.