Using AI to build my first Android app: What worked and what didn’t
Initial Thoughts
Having spent over a decade working in software development and data engineering, I thought, where is AI right now? Is it capable of eliminating the developer or is there still some time? So, I challenged myself with building an Android app. That was an unfamiliar area for me. While it intrigued me, there were a ton of questions developing in my mind:
- Is Android Studio still the IDE everyone uses?
- Should I try Java first or Kotlin?
- How does one get an APK these days?
At last, my curiosity prompted me to, let’s give it a try and see for myself.
My Approach
Like many other people in tech, I manage two phones. The problem is that my second phone is often left behind at places and that causes me to miss out on crucial notifications. The solution is something that has resided in my head for a very long time. An application that reads notifications and then forwards them, a small scenario for which we will implement. As with all things Android, the devil is in the details:
- In what manner can Android give access to notifications to applications? Is it event driven or polling?
- Is it possible for me to omit some notifications?
- What occurs if the user terminates the app or the phone gets restarted?
AI to the (Almost) Invention
With the hype around AI-assisted programming, I thought to myself, why not let the bots do all of the the intellectual heavy lifting? The first stop on my journey was Gemini, Google’s AI assistant.
Round 1: Gemini
To begin, I provided a fairly standard Android development request:
“Create an Android application which listens to notifications and retrieves them actively the moment they come in.”
Gemini has sent back some code he brewed using `NotificationListenerService`. When I requested Kotlin for the Android mobile target language, Gemini again helped out. As my requests started to pile up, Gemini continuously incorporated changes to the code transforming it into a background service that when killed, or restarted, would automatically start again.
It was dramatic to say the least, as I felt like a productivity wizard, copy pasting code and watching everything come together. Until, of course, the curtain came crashing down:
- `R.layout.activity_main` unresolved.
- activity_main.xml missing
- Non working imports, manifests, and every other dreadful scenario arising simultaneously.
Toiling away for a couple hours on resource files and dealing with strange error messages I have never seen before made me realize one thing: While AI is impressive, it cannot save you from the intricacies of Android development without a foundational understanding.
Round 2: Tactics Change with Claude
After trying my best, I gave up but at least switched to Claude. For this task, I streamlined my instruction from a prompt style to a single comprehensive request:
> “Construct an Android app that fully packages a bot token based notification forwarding to Telegram. The app should have a notification feature stating it is sending notification and will not forward its own notifications. In the event that the app is killed or device rebooted, it needs to restart.”
This time, Claude provided a packaged solution Claude provided a complete solution in Java with accompanying assigned directory structure. This time, the code compiled and executed correctly on the virtual device; notifications were forwarded and the app survived restarts. Success!
Replacing Telegram with Slack
As I got more interested in developing the app, my goal became shifting the target for notification forwarding to Slack instead of Telegram. It was clear that this required a new integration approach with incoming webhooks from slack. I created a helper class dedicated to sending messages to Slack and using HTTP requests together with threading and callbacks. By doing this, I was able to forward any notification to a Slack channel instantly. The process was effective, dependable, and integrated seamlessly into my work processes. A fairly simple prompt to do it:
> “Replace the telegram service with slack webhook implementation.”
What AI Did Correctly (Or Incorrectly)
AI was a wonderful accelerator. It streamlined my work in the following ways:
- Saved tons of time by generating all boilerplate code
- Explained concepts when I got stuck
But it also made classic errors such as:
- Resource Management: Code that was generated by AI overlooked Android’s resource system for some reason. The absence of XML files, manifest inaccuracies, and other issues led to endless debugging traces and recursive calls back to the dreaded Stack Overflow.
- Context Awareness: AI lacks knowledge of your projects’ organization. The provided snippets of code do not always integrate seamlessly.
- Knowledge of Android Behavior: Elements such as service lifecycle, filtering, and background execution need the hand of a human. We cannot depend solely on AI.
The User: Why Developers Are Still Essential
AI is merely a tool at our disposal. Not the substitute for engineering work. Your knowledge is important because:
- Domain Knowledge: Understanding how Android deals with its resources, services, and permissions is vital. This is applicable to any domain you are trying.
- Debugging: If things go wrong (and they will), you will have to step through logs, stack traces, and the documentation.
- Design Choices: These are decisions based on tried experience – when to implement a background service, handling reboots, or picking an API for our case. (In case of this app).
Blending AI with HI: My Closing Remarks on This Topic
The first Android app I built took me just a couple of hours to complete due to my integration of AI-generated code, which I then debugged in real-time. I was able to move quickly thanks to AI, but in the end, it was painstaking manual troubleshooting that helped me finish the app.
If you are a developer trying something new, it is completely okay to use AI—but not to circumvent all labor. The results are astonishing when paired with AI, if, you’re the one supplying the knowledge and expertise.
Github Link : Notification Forwarder