Following Android getting started - 'Error loading page'?

So I followed Hotwire Native Android: Getting Started and I can see https://hotwire-native-demo.dev in the emulator, but when I change the URL at

    NavigatorConfiguration(
        name = "main",
        startLocation = "https://hotwire-native-demo.dev",
        navigatorHostId = R.id.main_nav_host
    )

to any other site, I just get ‘Error loading page’, why is that?

Had the same ‘error’, I found the problem by setting a debug config (android)

Through logging in Android Studio, I could see that Turbo wasn’t detected from the native app (through the TurboIsNotReady event), even though it was present in the Rails app. Opening the app through the dev tools (see chrome docs above) I could see that assets were not downloaded (“connection refused”).
That’s because in our app, we have a separated assets host, and since in Android Studio we have to use the 10.0.2.2 alias to actually connect to the localhost (in dev env), the native app could not download assets from 10.0.2.2 (because that address doesn’t exists). So I had to change the config.asset_host in my case to make it work

1 Like

Adding to what @Mate2xo said. Here is an example of what you need to have in your development.rb config:

I added this at the top:

Rails.application.default_url_options = {
  host: 'garyharan.local',
  port: 3000
}

Rails.application.configure do
  config.action_controller.asset_host = 'http://garyharan.local:3000'
  config.hosts << "garyharan.local"
 [...]
end

Where of course garyharan.local is my hostname. You can figure out from the command line what your hostname is with the hostname command.