1

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

Ahmed Nabil
  • 581
  • 1
  • 7
  • 26

2 Answers2

1

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.

kichik
  • 33,220
  • 7
  • 94
  • 114
  • Thank you man I just didn't notice this a user-defined class, I thought it was built-in,it's just I'm writing the code myself, didn't download the project, thanks anyway. – Ahmed Nabil Jul 17 '17 at 01:24
0

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); `
Mehul Kabaria
  • 6,404
  • 4
  • 25
  • 50