bluelinelabs / Conductor

A small, yet full-featured framework that allows building View-based Android applications
Apache License 2.0
3.9k stars 343 forks source link

Sample not building - Android Studio 3.0 #301

Closed jbmlaird closed 7 years ago

jbmlaird commented 7 years ago

On initial build it will show errors that ButterKnife.bind(this)

cannot resolve method bind(com.bluelinelabs.conductor.demo.MainActivity

and Conductor.attachRouter(this, ...)

wrong 1st argument type. Found: com.bluelinelabs.conductor.demo.MainActivity required android.app.Activity.

Changing MainActivity to extend Activity instead of AppCompatActivity throws error:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bluelinelabs.conductor.demo/com.bluelinelabs.conductor.demo.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getId()' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2924) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2985) at android.app.ActivityThread.-wrap14(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1635) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6692) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getId()' on a null object reference at com.bluelinelabs.conductor.internal.LifecycleHandler.getRouterHashKey(LifecycleHandler.java:107) at com.bluelinelabs.conductor.internal.LifecycleHandler.getRouter(LifecycleHandler.java:77) at com.bluelinelabs.conductor.Conductor.attachRouter(Conductor.java:38) at com.bluelinelabs.conductor.demo.MainActivity.onCreate(MainActivity.java:34) at android.app.Activity.performCreate(Activity.java:6912) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2877)

upon launching the app.

EricKuck commented 7 years ago

It builds fine here. Which version of Android Studio are you using? I haven't tested in the 3.0 canary builds yet. Anyone else having issues?

jbmlaird commented 7 years ago

Makes sense. I'm using the current 3.0 canary build. I'll downgrade, cheers.

EricKuck commented 7 years ago

It might be an issue with the demo using android-apt instead of the built-in annotation processor. This was just changed by merging in @friederbluemle's PR, so you might want to try again in 3.0. No promises it'll work, as I still haven't tested it, but I bet it will.

jbmlaird commented 7 years ago

That did indeed fix it. The errors kept appearing in the editor but it ran fine.

Thanks :)