AppCompatActivity.onCreate can only be called from within the same library group

pixel picture pixel · Dec 14, 2016 · Viewed 47.4k times · Source

After upgrading to appcompat 25.1.0 I've started getting wired errors.

In my code:

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

I get lint error:

AppCompatActivity.onCreate can only be called from within the same library group (groupId=com.android.support)

How to prevent such behavior?

Answer

DimitrisCBR picture DimitrisCBR · Jul 5, 2017

As previous responses highlighted, it is bug. I recommend not to disable the specific lint warning project-wide, but for that method only. Annotate your method as follows:

@SuppressLint("RestrictedApi")
@Override
public void setupDialog(Dialog dialog, int style) {
    super.setupDialog(dialog, style);
    //your code here
}