Ahmed Nabil
Ahmed Nabil

Reputation: 751

Can't resolve NetworkUtils

I'm trying to use NetworkUtils class in android and it shows the error like in the following image, how is this even possible? enter image description here

Upvotes: 1

Views: 2858

Answers (2)

Mehul Kabaria
Mehul Kabaria

Reputation: 6622

I think you are using

compile 'com.blankj:utilcode:1.5.0' 

AndroidUtils lib for common utils.

If you are using this lib then you have to write below line in Application class

`com.blankj.utilcode.util.Utils.init(this); `

Upvotes: 0

kichik
kichik

Reputation: 34744

I assume you're talking about the Udacity class and not the built-in Android class because the latter doesn't have a method called buildUrl() (and isn't public as mentioned in the comments).

In that case, you should make sure you:

  1. Have NetworkUtils.java in your source code
  2. Properly import it at the top of your file like in the example with import com.example.android.datafrominternet.utilities.NetworkUtils; (unless you moved it to another package)

If the file is already in the source code, or in a library you are using, you can also hit Alt+Enter while the cursor is on the error. It should open a quick fix window. The first option should be importing the class from the appropriate place.

Upvotes: 1

Related Questions