3

I have recently updated my Android Studio to 3.0. I tried using Preconditions.checkNotNull() but it shows an error with following message.

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

I searched some other links and found something similar happening when older support library versions were rolled out.

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

Suggested answers tells me to disable lint warnings but I don't think it's the right thing to do in the long run.

Any explanation on why this particular error shows up?

Sahil Patel
  • 684
  • 7
  • 19

2 Answers2

0

Use androidx instead.

import androidx.core.util.Preconditions;

ref = Preconditions.checkNotNull(anotherRef);
Zsolt Safrany
  • 13,290
  • 6
  • 50
  • 62
  • Getting error for this also. "Preconditions can only be called from within the same library group prefix (referenced groupId=androidx.core " – sandeep549 May 18 '21 at 17:16
0

You can use the inline function:

requireNotNull

This does not show a warning like Preconditions.checkNotNull(ref)

Otieno Rowland
  • 2,182
  • 1
  • 26
  • 34