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

4

1 回答 1

0

我不确定是什么导致了这个错误,但如果你想将 ActionBarSherlock 与 RoboGuice 一起使用,你可以查看roboguice-sherlock库。

将 RoboGuice 插入 Activity 需要比代码中显示的更多的管道。例如,检查RoboSherlockActivity代码。

供您参考,RoboGuice.injectMembers()这是执行标准Guice注入的捷径,因此它不会处理@InjectView注释,因为它是 RoboGuice 特定的。

于 2013-06-28T23:08:41.657 回答