Skip to content
Public template

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

android-template

A minimal Hotwire Native Android app: a native shell that shows your Rails app's pages, with Joe Masilotti's Bridge Components already installed. It's the starting point for First Draft's Hotwire Native lessons, and for your own apps.

Use it

  1. Click Use this template → Create a new repository. If you already made one from this template, give the new one a different name (e.g. android-bridge-components-sandbox).
  2. Clone your new repository to your computer, e.g. gh repo clone <your-username>/<your-repo>.
  3. Open the folder in Android Studio (File → Open) and wait for the Gradle sync to finish; the first one downloads a lot and can take several minutes.
  4. Pick a device in the toolbar and click Run (▶). If there's none, create one in Device Manager with a recent Android version (API 36) and a "Google Play" system image.

The app loads http://10.0.2.2:3000: inside the emulator, 10.0.2.2 is your computer, so start your Rails app on port 3000 first. In a Codespace, forward the port to your computer with gh codespace ports forward 3000:3000. The first launch on a fresh emulator can sit on a spinner for half a minute while the emulator warms up.

What's inside

  • app/src/main/java/com/firstdraft/androidtemplate/MainActivity.kt: the rootURL and the navigator configuration that loads it.
  • app/src/main/java/com/firstdraft/androidtemplate/AndroidTemplate.kt: the Application class; registers the Bridge Components.
  • app/src/main/AndroidManifest.xml: internet permission and plain http for development (usesCleartextTraffic).
  • app/build.gradle.kts: the dev.hotwire and bridge-components dependencies (JitPack is in settings.gradle.kts).

Before you ship

Rename the app and give it your own application ID: change app_name in app/src/main/res/values/strings.xml and applicationId in app/build.gradle.kts (e.g. com.yourname.yourapp). Then point rootURL at your production https URL and remove usesCleartextTraffic.

Troubleshooting

  • "Error loading page": the Rails app isn't reachable on port 3000 of your computer. Check bin/dev is running and, for a Codespace, that the gh codespace ports forward command is still running, then tap Connect. (An app that loaded the page before may show a saved copy of it instead of the error, which can hide the problem.)
  • "Error loading screen" in the emulator: the device's Android version is older than the app's compileSdk. Create a device with API 36.
  • The "Android" project view is missing: it appears after the first Gradle sync finishes.

All files are covered by the MIT license, see LICENSE.txt.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages