Phonegap CordovaActivity Problem

I am developing a small mobile application with Phonegap for Android and I needed to reinstall my machine. Setting up up Phonegap and all its dependencies on Windows is a huge pain, but that’s another story.

Today, I run into a problem when running the command phonegap run android and it said

[Error: No Java files found which extend CordovaActivity.]

The issue is related to the update in the internals of Cordova projects, the project that Phonegap is running on, and you need to modify your generated java class located in platforms\android\src\path\to\your\app.

Find the HelloWorld.java class and open it. You should see something similar to this

package path.to.your.app;

import android.os.Bundle;
import org.apache.cordova.*;

public class HelloWorld extends DroidGap
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        // Set by <content src="index.html" /> in config.xml
        super.loadUrl(Config.getStartUrl());
        //super.loadUrl("file:///android_asset/www/index.html")
    }
}

Change the parent class to CordovaActivity and run the build again.

public class HelloWorld extends CordovaActivity

And everything should work like it used to do.


Did you like the article? Send me a comment!