I'm trying to use NetworkUtils class in android and it shows the error like in the following image, how is this even possible?
Asked
Active
Viewed 2,547 times
1

Ahmed Nabil
- 581
- 1
- 7
- 26
-
2`NetworkUtils` is not a public API. See https://stackoverflow.com/questions/17035271/what-does-hide-mean-in-the-android-source-code – Andrew Sun Jul 17 '17 at 00:49
-
Still can't figure out how to import it, can you tell me please? – Ahmed Nabil Jul 17 '17 at 00:58
2 Answers
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:
- Have
NetworkUtils.java
in your source code - 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