java.lang.ClassNotFoundException: android.net.Netw

2019-07-29 14:38发布

问题:

This is little related to Payubiz payment gateway sdk integration. However, the main problem is related to building a project.

Whenever we try to run the application on emulator. We get the following failure:

  • What went wrong: Execution failed for task ':app:transformClassesWithInstantRunForAppDebug'. java.lang.ClassNotFoundException: android.net.Network

However, the application builds and run smoothly on running on a device. We have already contacted the Payu Team for the issue. But as it is an android related problem, not the payment gateway. I feel like SO is the better place.

Emulator Details:

  • Name: Nexus_4_API_19 CPU/ABI: Google APIs Intel Atom (x86)
  • Target: google_apis [Google APIs] (API level 19)
  • runtime.network.speed: full

SOLUTION: Below, is a reply from PayU team. They have confirmed that they were not using any class, neither do i. But after some time/ may be some other dependency/cleaning the project. It works for the emulator as well.

回答1:

The class android.net.Network is added in API 21. You need to use an emulator with the same or higher API level to access it.