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.
- 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). - Clone your new repository to your computer, e.g.
gh repo clone <your-username>/<your-repo>. - 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.
- 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.
app/src/main/java/com/firstdraft/androidtemplate/MainActivity.kt: therootURLand the navigator configuration that loads it.app/src/main/java/com/firstdraft/androidtemplate/AndroidTemplate.kt: theApplicationclass; registers the Bridge Components.app/src/main/AndroidManifest.xml: internet permission and plainhttpfor development (usesCleartextTraffic).app/build.gradle.kts: thedev.hotwireandbridge-componentsdependencies (JitPack is insettings.gradle.kts).
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.
- "Error loading page": the Rails app isn't reachable on port 3000 of your computer. Check
bin/devis running and, for a Codespace, that thegh codespace ports forwardcommand 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.