2

I recently upgraded my app from Phonegap 1.6 to 2.2. I've refactored everything (ex Plugin --> CordovaPlugin) and I'm also using the new config.xml.

The app compiles and builds, however I constantly am getting an error in logcat and an error dialog box. The dialog says [ERROR] Error initializing Cordova: Class not found.

The logcat error is: Line 6048 : Error initializing Network Connection: Class not found

What could I be missing? The issue happens on multiple devices.

Update

I've already changed the config.xml for the network status plugin from Network Status to NetworkStatus. It reads: <plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>

Sababado
  • 2,524
  • 5
  • 33
  • 51

3 Answers3

2

I had this problem and made it go away by adding the following to the config.xml:

<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>

And adding this to the Manifest file:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

I originally took them out because I "knew" that my app wouldn't be using any communications. I had forgotten about the emulator "communicating" with the ADK.

I'll take these 2 lines out when I convert the project over to "production" so that the app is ready for Google Play.

slm
  • 15,396
  • 12
  • 109
  • 124
0

I had this problem using phonegap 3.x and the problem turned out to be that phonegap hadn't properly installed the plugins, or they just messed up along the way. Basically when you install the plugins and build for a platform it takes the javascript files from plugins/org.apache.cordova.core.specific-plugin/www and puts them in platforms/android/assets/www/plugins/org.apache.cordova.core.specific-plugin/www and then it takes the Java files (or objective C for iOS) and puts them in platforms/android/src/org/apache/cordova/specificplugin

And all of this is specified by plugins/org.apache.cordova.core.specific-plugin/plugin.xml. If you look in a plugins.xml you should see something like:

<source-file src="src/android/NetworkManager.java" target-dir="src/org/apache/cordova/networkinformation" />

So this tells you that in platforms/android/src/org/apache/cordova/networkinformation, there should be NetworkManager.java. And right that file can be copied from plugins/org.apache.cordova.core.network-information/src/android/NetworkManager.java

Now all of this is supposed to happen automatically without having to touch the platforms folder. But if it messes up you can fix it by copying the correct java files into the correct folders.

aharris88
  • 3,560
  • 3
  • 27
  • 45
0

The following line in config.xml works for cordova 6.2 with android

<plugin name="cordova-plugin-network-information" value="org.apache.cordova.networkinformation"/>

The name should be the same as in what your plugin contains. You can find it in the your project folder at the following path plugins/name-of-the-plugin/package.json. The value should be the package name for the plugin which can be found in the native implementation file.

avck
  • 3,535
  • 3
  • 26
  • 38