Question

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.

Was it helpful?

Solution

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)

OTHER TIPS

Check if your @InjectViews has correct type.

I've used ImageView instead of LinearLayout.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top