Generating a Wearable Apps using AI with OpenAI Codex

Codex is an experimental tool developed by OpenAI to provide a coding agent ability on the CLI. In this demo, we try to use Codex to generate an Android wearable app without writing any code ourselves.


Steps to install

1) Install globally via NPM.

npm i -g @openai/codex

2) Attach an OpenAI API key.

~/.zshrc

export OPENAI_API_KEY="your-api-key-here"

In Android Studio

1) Create a blank wearable project.


In your Terminal

1) Go to the project directory.

2) Run Codex with a prompt, and describe what you want to build.

$ codex "Use the android studio project in this folder, create a wearable android app that runs a mini game. Each round, the screen is divided into 4 partitions, each has a different background color. a white dot appear randomly within 1 of the partition. user has to tap on the partition with the white dot to proceed to the next round. if user does not tap within 3 seconds, or tapping on a wrong partition, the game ends. otherwise, the game continues to up to 1 minute and print total correct tapping when it ends."

3) After about 7 minutes of waiting, the draft version is created.

4) Trying to build the project results in an error. We sent the error to Codex, and it was fixed.

I have this error when build. e: MainActivity.kt:133:14 Expression 'weight' of type 'kotlin.Float' cannot be invoked as a function. Function 'invoke()' is not found.

5) Now the game runs successfully on the watch emulator.

6) Next, we get it to update the background colors and request it to propose a suitable foreground color.

change the partition colors to #328E6E, #67AE6E, #90C67C, #E1EEBC, and find a suitable color for the dot so it has enough contrast over the background colors

7) Finally, the app is ready.


Test our App

1) In a watch emulator.

2) On an actual watch


Notes

1) Codex can run in full auto mode.

codex --approval-mode full-auto "your prompt"

2) Codex logs are available in JSON.

cd ~/.codex/sessions

3) "System Prompt" can be supplied.

cat ~/.codex/instructions.md

4) As of today (18th April 2025), it is still unstable with several bugs. But good enough just for fun.


AI Summary AI Summary
gpt-4o-2024-08-06 2025-04-19 20:11:52
The blog post explores how OpenAI's Codex can automate the creation of an Android wearable app. The process involves minimal coding, relying instead on Codex to generate the app based on user prompts. Despite initial errors, adjustments lead to a functional mini-game on a wearable device, demonstrating Codex's potential in app development.
Chrome On-device AI 2025-05-24 12:10:28
Writing

Share Share this Post