I'm following the turbolinks-android documentation, https://github.com/turbolinks/turbolinks-android, trying to setup an android wrapper for a Rails site built with turbolinks 5. Come across an issue with this line, .adapter(this)
in Main Activity.
Below I'll post my MainActivity.java and stack trace. All other code is the same as a previous question I've posted here ( TurbolinksView not being found on Android). Any help is appreciated. Thanks :)
MainActivity.java:
package com.example.turbolinkswrapper;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.basecamp.turbolinks.TurbolinksSession;
import com.basecamp.turbolinks.TurbolinksView;
public class MainActivity extends AppCompatActivity {
private TurbolinksView turbolinksView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Assumes an instance variable is defined. Find the view you added to your
// layout in step 1.
turbolinksView = (TurbolinksView) findViewById(R.id.turbolinks_view);
TurbolinksSession.getDefault(this)
.activity(this)
.adapter(this)
.view(turbolinksView)
.visit("https://basecamp.com");
}
}
stack trace:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.turbolinkswrapper, PID: 5540
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.turbolinkswrapper/com.example.turbolinkswrapper.MainActivity}: java.lang.ClassCastException: com.example.turbolinkswrapper.MainActivity cannot be cast to com.basecamp.turbolinks.TurbolinksAdapter
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.ClassCastException: com.example.turbolinkswrapper.MainActivity cannot be cast to com.basecamp.turbolinks.TurbolinksAdapter
at com.example.turbolinkswrapper.MainActivity.onCreate(MainActivity.java:26)
at android.app.Activity.performCreate(Activity.java:6679)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Application terminated.
According to step two you need to implement the TurboLinksAdapter Interface: