How to load web content on turbolinks-android

393 views Asked by At

I have a web app which made with Ruby on Rails and enabled Turbolinks 5 but currently, I need to make a native Android app which actually designed by Basecamp.

On their GitHub repository have step by step setup I'm following this steps because here (google) is not enough help for turbolinks-android based on their tutorial I'm setup but not loading any content like

#=> If I use Basecamp URL
private static final String BASE_URL = "https://basecamp.com";

Not changing anything always showing blank screen

#=> My local project
private static final String BASE_URL = "http://localhost:3000";

Also same not changing anything showing blank screen

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical">

  <com.basecamp.turbolinks.TurbolinksView
    android:id="@+id/turbolinks_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
</LinearLayout>

MainActivity.java

import com.basecamp.turbolinks.TurbolinksSession;
import com.basecamp.turbolinks.TurbolinksAdapter;
import com.basecamp.turbolinks.TurbolinksView;

All are same as their documentation

Appreciate if any help

Thanks

2

There are 2 answers

0
Yunus Emre On

Their example project is not working anymore. Probably because of its deprecated. But they use it in their application so it's not dead yet. Example project's first problem is it needs 2 additional libraries to use:

implementation 'com.basecamp:turbolinks:1.0.9' // Turbolinks
implementation 'com.google.code.gson:gson:2.8.2' // Important addition 1
implementation 'org.apache.commons:commons-lang3:3.1' // Important addition 2

Also, HTTP without SSL isn't working so you need to use something like ngrok to tunnel your connection with HTTPS.

You can look at my working example at Github

0
Kirill Platonov On

Not sure if you still looking for an answer. I had exact the same problem with turbolinks-android and Rails 5.2 web application.

Problem was caused by content_security_policy which is enabled by default in newest Rails versions. I fixed it by commenting out content in config/initializers/content_security_policy.rb file.

Also a good tip for future problems - use adb logcat command with devise connected via USB. It will show you what exactly causing an error.