0

I'm having an issue injecting views with injectViewMembers,

the error I get is this:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rgainternalapps.devicemanager/com.rgainternalapps.devicemanager.DeviceActivity}: java.lang.UnsupportedOperationException: internal error, how did you get here?

Here is the relevant code:

public class DeviceActivity extends SherlockActivity {
RelativeLayout layout;
Device currentDevice;
ArrayList<User> assigneesList;
ProgressDialog progressDialog;

@Inject
DevicesHelpers devicesHelpers;

@Inject
DevicesData devicesData;

@Inject
UsersData usersData;

@InjectView(R.id.device_model)
TextView deviceModel;

@InjectView(R.id.name)
TextView name;

@InjectView(R.id.os)
TextView os;

@InjectView(R.id.version)
TextView version;

@InjectView(R.id.serial_number)
TextView serialNumber;

@InjectView(R.id.assign_to_me)
Button assignToMeButton;

@InjectView(R.id.owner_photo)
ImageView ownerPhoto;

@InjectView(R.id.owner_info)
RelativeLayout ownerInfo;

@InjectView(R.id.owner_name)
TextView ownerName;

@InjectView(R.id.owner_email)
TextView ownerEmail;

@InjectView(R.id.device_not_assigned)
TextView deviceNotAssigned;

@InjectView(R.id.device_assigned_to_you)
TextView deviceAssignedToYou;

@InjectView(R.id.assignee_selection)
LinearLayout assigneeSelection;

@InjectView(R.id.assign_to_other)
Button assignToOtherButton;

@InjectView(R.id.assignee_selector)
AutoCompleteTextView assigneeSelector;

User currentAssignee;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_device);

    //RoboGuice.injectMembers(this.getApplication(), this);
    //RoboGuice.getInjector(getApplicationContext()).injectMembersWithoutViews(this);
    RoboGuice.getInjector(getApplicationContext()).injectViewMembers(this);
}

}

Also, I tried

RoboGuice.injectMembers(getApplicationContext(), this);

but it seems to only inject all but the Views

I'm using RoboGuice 2.0 (roboguice-2.0.jar, guice-3.0-no_aop.jar).

Android SDK is 4.1.2

I didn't have any problems injecting views inside Fragments.

Thanks

Pablo

DeltaCap019
  • 6,532
  • 3
  • 48
  • 70
Pablo
  • 1
  • You say it works with fragments so it's a weak probability but can you try disabling proguard before compiling to see if obfuscations are causing this? I saw a similar situation in ButterKnife(view injection library). – basar Jun 28 '13 at 07:09

1 Answers1

0

I am not sure of what is causing this error, but if you want to use ActionBarSherlock with RoboGuice, you can have a look at the roboguice-sherlock library.

Pluging RoboGuice in an Activity requires a bit more plumbing than what is shown in your code. Check the RoboSherlockActivity code for example.

For your information, RoboGuice.injectMembers() is a shorcut to do standard Guice injection, so it will not process @InjectView annotations as it is RoboGuice specific.

nicopico
  • 3,606
  • 1
  • 28
  • 30