0

I am currently coding on the Android Bootstrap app, I want to have the new DataPickers en make use of new widgets without worrying about porting back to 2.1+ so I use the HoloEveryWhere Library. I also use the Android Bootstrap with Butterknife library

When I debug I get this exception

E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{nl.webridge.whtsnxt.debug/nl.webridge.whtsnxt.authenticator.BootstrapAuthenticatorActivity}: butterknife.ButterKnife$UnableToInjectException: Unable to inject views for nl.webridge.whtsnxt.authenticator.BootstrapAuthenticatorActivity@40619210
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
            at android.app.ActivityThread.access$1500(ActivityThread.java:117)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:130)
            at android.app.ActivityThread.main(ActivityThread.java:3687)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: butterknife.ButterKnife$UnableToInjectException: Unable to inject views for nl.webridge.whtsnxt.authenticator.BootstrapAuthenticatorActivity@40619210
            at butterknife.ButterKnife.inject(ButterKnife.java:176)
            at butterknife.ButterKnife.inject(ButterKnife.java:104)
            at nl.webridge.whtsnxt.authenticator.BootstrapAuthenticatorActivity.onCreate(BootstrapAuthenticatorActivity.java:140)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
            at android.app.ActivityThread.access$1500(ActivityThread.java:117)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:130)
            at android.app.ActivityThread.main(ActivityThread.java:3687)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.reflect.InvocationTargetException
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
            at butterknife.ButterKnife.inject(ButterKnife.java:171)
            at butterknife.ButterKnife.inject(ButterKnife.java:104)
            at nl.webridge.whtsnxt.authenticator.BootstrapAuthenticatorActivity.onCreate(BootstrapAuthenticatorActivity.java:140)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
            at android.app.ActivityThread.access$1500(ActivityThread.java:117)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:130)
            at android.app.ActivityThread.main(ActivityThread.java:3687)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.ClassCastException: org.holoeverywhere.widget.AutoCompleteTextView
            at nl.webridge.whtsnxt.authenticator.BootstrapAuthenticatorActivity$$ViewInjector.inject(BootstrapAuthenticatorActivity$$ViewInjector.java:14)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:507)

I think there's a problem with the HoloEverywhere activity I use in my app.

For example I use the import org.holoeverywhere.app.Activity; in all my Activity classes.

But the Butterknife use android.app.Activity; The problem is, I can't change code in the Butterknife to use the Activity from HoloEverywhere.

Please tell me your thoughts on this I use the latest version of Butterknife and HoloEveryWhere.

Richard Lindhout
  • 2,038
  • 2
  • 23
  • 38
  • HE is great but if you only want the DataPicker you can use https://github.com/derekbrameyer/android-betterpickers or another library. It'll be easier. – Brais Gabin Apr 03 '14 at 13:20
  • 1
    Yeah I know but I just like the library because it fixes bugs with older devices so I don't have to look after! Anyways thanks for your help! – Richard Lindhout Apr 03 '14 at 13:21

3 Answers3

1

Try to set up in your AndroidManifest.xml the holo theme:

<application
     android:theme="@style/Holo.Theme.NoActionBar.Fullscreen"

or maybe only the in activity that is happening your problem (also in the manifest)

<activity
     android:theme="@style/Holo.Theme.NoActionBar.Fullscreen"

Of course in your java class, if the component is defined as a holo component in the xml layout, in your java class you have to import that component from the holo library like you are doing:

  import org.holoeverywhere.app.Activity

or

  import org.holoeverywhere. whatever  (like button, switch, whatever)
Juan Pedro Martinez
  • 1,924
  • 1
  • 15
  • 24
  • I was so convinced that it was in the butterknife library that I have not looked at the imports in the activity properly. Thanks! Also Holo.Theme.NoActionBar.Fullscreen works alot better than actionbarcompat because fullscreen is now working on older devices! – Richard Lindhout Apr 03 '14 at 13:10
  • One stuff more: I have written you Holo.theme.noactionbar.fullscreen but there are another themes that you can apply for your app...no only that one. – Juan Pedro Martinez Apr 03 '14 at 13:12
  • Yep I know I've already have a custom theme which is built on Holo.Theme.Light that was working but I forgot to apply the Holo theme to the Authenticator! – Richard Lindhout Apr 03 '14 at 13:13
0

Check if your @InjectViews has correct type.

I've used ImageView instead of LinearLayout.

ViliusK
  • 11,345
  • 4
  • 67
  • 71
  • 1
    Okay :) I've switched from HoloEverywhere back to just ActionBarCompat so I removed all the things. But thanks for answer maybe helpfull for other people!!, – Richard Lindhout Jun 18 '14 at 08:07
0

Also check if you are not using other ButterKnife's injection annotations incorrectly. I've used @OnItemClick annotation for RecyclerView, which was causing RuntimeException.

ViliusK
  • 11,345
  • 4
  • 67
  • 71