Skip to content
Winter Sale from $619, until 31st December 2026 Book now
Agentic coding tools & comparisons Android · Google Play OpenAI Codex

OpenAI Codex for Android and Kotlin: A Setup for Cloud Tasks and Local Runs

Android is where Codex cloud tasks can do real work: the Android SDK and Gradle run on Linux, so a task can compile, lint and unit-test its own change before it opens a pull request. The effort goes into the environment – JDK, SDK packages and a warm Gradle cache in the setup script, because the agent phase has no internet by default – and into an AGENTS.md that names the exact tasks.

8 min read

Key takeaways

  • Unlike iOS, Android builds run on Linux, so Codex cloud tasks can verify their own changes with Gradle.
  • Install the SDK and warm the Gradle cache in the setup script; the agent phase is offline by default.
  • Tell Codex to run Gradle with --offline and to stop and ask when a task needs a new dependency.
  • Emulator work, signing and anything that touches Google Play policy stay local or with a human.
  • CI on every pull request plus Codex code review plus a human approval is the review stack that holds.

Why Android fits Codex cloud tasks

Codex cloud tasks run in Linux containers. For an iOS app that is a hard limit; for Android it is the platform's home ground. Gradle, a JDK and Google's SDK tools are all at home on Linux, so a cloud task can do what a developer does before opening a pull request: compile the code, run the unit tests and run Android Lint.

What you should not expect from a cloud container is an emulator. Instrumented tests, UI checks and anything that needs to be seen on a screen belong on a developer machine or on a CI runner set up for emulators. The same goes for everything that touches your Play Console account. With that split in mind, cloud tasks become a reliable way to work through a backlog of small, verifiable Android changes in parallel.

The cloud environment: JDK, SDK and a warm Gradle cache

A Codex cloud environment has two phases. The setup script runs first, with internet access. Then the agent works – by default without internet. Environment secrets are only available to the setup script and are removed before the agent starts. For Android that means: everything Gradle will ever download has to arrive during setup.

#!/usr/bin/env bash
set -euo pipefail
java -version   # check the image's JDK against what your Android Gradle Plugin requires

# Android command-line tools: download link from developer.android.com/studio ("Command line tools only")
export ANDROID_HOME="$HOME/android-sdk"
mkdir -p "$ANDROID_HOME/cmdline-tools"
curl -sSL -o /tmp/cmdline-tools.zip "<command-line tools download link>"
unzip -q /tmp/cmdline-tools.zip -d "$ANDROID_HOME/cmdline-tools"
mv "$ANDROID_HOME/cmdline-tools/cmdline-tools" "$ANDROID_HOME/cmdline-tools/latest"

SDKMANAGER="$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager"
yes | "$SDKMANAGER" --licenses > /dev/null
"$SDKMANAGER" "platform-tools" "platforms;android-36" "build-tools;36.0.0"

# Gradle reads the SDK location from local.properties, so later shells do not need the variable
echo "sdk.dir=$ANDROID_HOME" > local.properties

# Download every dependency while the network is still available
./gradlew --console=plain assembleDebug testDebugUnitTest lintDebug

The last line matters most. Running the same tasks the agent will run fills the Gradle cache with every plugin, library and lint artifact, so --offline works later. Match the platform and build-tools versions to your compileSdk, and check the environment's caching options so the full setup does not repeat for every task.

If you prefer to give the agent limited internet access instead, allow only the hosts Gradle needs – Google's Maven repository, Maven Central and the Gradle Plugin Portal – rather than switching access on for everything.

Talk to an AI Code Engineer about shipping your app to Google Play.

In a free call we look at what you built, tell you honestly what stands between it and an approved release – and whether you need us at all.

AGENTS.md for a Kotlin repository

Codex reads AGENTS.md from the repository root and from subfolders, with the nearest file taking precedence. The root file sets the rules every task must follow:

# AGENTS.md – Android

## Build rules
- Always run Gradle with --offline --console=plain. Cloud tasks have no network after setup.
- Before finishing: ./gradlew --offline :app:compileDebugKotlin testDebugUnitTest lintDebug
- If a task needs a new dependency, stop and describe it in the PR instead of adding it.

## Architecture
- Kotlin only; no new Java files. Compose UI, ViewModels exposing StateFlow, Hilt for injection.
- Repositories live in :core:data. UI code never calls Room DAOs directly.
- Versions only in gradle/libs.versions.toml.

## Tests
- Every bug fix starts with a failing unit test.
- Flows are tested with Turbine; prefer fakes over mocks of Android classes.

## Off limits – propose, do not change
- signingConfigs, applicationId, minSdk, targetSdk, versionCode, versionName
- AndroidManifest.xml permissions, google-services.json, R8/ProGuard rules

A nested file then adds the rules of one area. A feature/checkout/AGENTS.md might say that purchases of digital goods only go through the existing wrapper around Google Play Billing, and that prices are never hard-coded in the app. Codex picks it up whenever it works in that folder. Our article on CLAUDE.md and AGENTS.md for mobile projects covers structure and sharing in more depth.

Writing Android tasks Codex can finish

A cloud task succeeds when its result can be verified with the tasks in AGENTS.md. Sort your backlog accordingly:

Good cloud taskBetter locally or with a human
"Add unit tests for CartViewModel covering empty, loading and error states.""Make onboarding feel smoother." – needs eyes on a device.
"Replace the deprecated API flagged by lint in :feature:profile."Upgrading the Android Gradle Plugin or Kotlin – needs network and judgement.
"Fix this crash" with the stack trace from Play Console vitals, reproduced in a unit test first.Raising targetSdk – behaviour changes such as edge-to-edge layouts need visual checks.
"Move date formatting out of the composables into a tested formatter."Anything touching signing, permissions or billing flows.

Keep one task per module where you can. Parallel tasks that edit the same Gradle files or the same screen produce merge conflicts that cost more time than they saved.

Local Codex for emulator and UI work

For work that needs a screen, run the Codex CLI or IDE extension on your machine next to a running emulator. The agent can install the debug build with ./gradlew installDebug, run connectedDebugAndroidTest, and capture the screen with adb exec-out screencap -p so you can attach the image to your next prompt.

One sandbox detail: adb talks to its server over a local network socket. With network access disabled in the sandbox, adb commands may fail, so either approve them when Codex asks or allow network access for this project only. Keep your personal Google account off the emulator image the agent drives.

Pull requests: CI first, then Codex review, then you

Codex cloud tasks end in a pull request. Three checks should meet it:

  1. CI runs the same Gradle tasks with network access, plus a minified release build, because R8 rules that break reflection-based code only show up there.
  2. Codex code review on GitHub comments on the diff. Tell it what matters on Android: lifecycle leaks, work on the main thread, exported components, new permissions.
  3. A human approves the merge and checks anything that changes what Google Play sees.

Our guide to reviewing agent-generated code describes a lightweight process for small teams.

Release work stays outside the container

The upload key, its password and the Play Console service account belong in your CI secrets, not in a Codex environment. New apps ship as App Bundles with Play App Signing, must target Android 16 (API level 36) since August 31, 2026, and need a complete Data safety form – a new SDK that the agent added can change your answers, which is why Data safety with AI agents is worth a read. The full release path is in Codex app to Google Play.

Our AI Code Engineers set up signing, CI/CD, testing tracks and the listing in your own Play Console through the Android submission service, and run hands-on Codex workshops for Android teams.

Codex for Android checklist

  • The setup script installs the right JDK, the SDK platform and build tools, and writes local.properties.
  • The setup script runs the same Gradle tasks the agent will run, so --offline works afterwards.
  • AGENTS.md lists the Gradle commands, architecture rules and the off-limits build settings.
  • Nested AGENTS.md files cover sensitive areas such as billing.
  • Cloud tasks are scoped to one module and can be verified with Gradle.
  • CI runs unit tests, lint and a minified release build on every pull request.
  • Upload key, passwords and the Play service account never enter the Codex environment.

Frequently asked questions

Can Codex cloud run the Android emulator?

Do not plan on it. Cloud containers are built for compiling and testing code, and emulators need hardware acceleration. Use JVM tests and screenshot tests in the cloud, and run instrumented tests locally or on a CI runner set up for emulators.

Why does Gradle fail with "Could not resolve" in a Codex task?

The agent phase is offline by default, so any dependency that was not downloaded during setup is missing. Run the same Gradle tasks in the setup script, or allow limited internet access for the repository hosts Gradle needs.

Should I use Codex or Gemini in Android Studio?

They fit different moments. Gemini works inside the IDE while you code; Codex cloud tasks work through a backlog in parallel and return pull requests. Many teams use an IDE agent for interactive work and a cloud agent for well-defined tasks.

Can appsubmitter.io release a Codex-built Android app for us?

Yes. In a free call we look at your repository and environment together. If you hand the release over, our AI Code Engineers configure signing, CI/CD, testing tracks and the Play listing inside your developer account.

Free, 15 minutes, no obligation

Get your app from agent output to approved release.

Our AI Code Engineers take apps built with Claude Code, Codex, Cursor, Lovable, Base44 and co. through signing, CI/CD, store listings and review – in your own developer accounts.

AI tools, store policies and requirements change quickly – always check the current documentation of the tools and stores you use. This article is independent advice and not affiliated with or endorsed by Apple, Google, Anthropic, OpenAI or any other company or product mentioned; all trademarks belong to their owners.

Ready to ship?

Talk to an AI Code Engineer – free, 15 minutes, in English or German.

Book a call for free

Chat and hotline are open 24/7. Answers from our senior AI Code Engineers (real humans) usually take closer to 72 hours than 1 hour.