Attempt to invoke virtual method 'void com.phonegap.CallbackServer.sendJavascript(java.lang.String)'

9 views
Skip to first unread message

Brian Byaruhanga

unread,
Nov 25, 2016, 2:31:32 PM11/25/16
to phonegap
Hello guys. So am developing an Android App using the phonegap.jar library as well as cordova js as instructed. I am basically picking contents from my server/ The issue come is that the app having compiled well, crashes on Some devices, typically with the message that the App has stopped working. I ran the logcats and this is the message i got from the moment of the crash:
 FATAL EXCEPTION: main
11-25 10:27:13.000  9934  9934 E AndroidRuntime: Process: com.app.package, PID: 9934
11-25 10:27:13.000  9934  9934 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.phonegap.CallbackServer.sendJavascript(java.lang.String)' on a null object reference
11-25 10:27:13.000  9934  9934 E AndroidRuntime: at com.phonegap.DroidGap$LinearLayoutSoftKeyboardDetect.onMeasure(DroidGap.java:1699)


My code is as shown below:
public class Main extends DroidGap {

ConnectivityManager connectivity;
NetworkInfo activeNetwork;
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.setIntegerProperty("splashscreen", R.drawable.splash);
        
        connectivity  = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
        activeNetwork = connectivity.getActiveNetworkInfo(); 
        
        if(activeNetwork != null) {
        if(activeNetwork.getType() == ConnectivityManager.TYPE_WIFI)
        {Toast.makeText(this,activeNetwork.getTypeName(), Toast.LENGTH_SHORT).show();
        super.loadUrl("URL", 1000);}
       
        else if(activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) 
        {Toast.makeText(this, activeNetwork.getTypeName(), Toast.LENGTH_SHORT).show();
        super.loadUrl("URL", 1000);}
        }//Connected to the Internet
        
        else {
        super.loadUrl("file:///android_asset/www/index.html", 1000);}    
        //No Internet Connection
}
public void onReceivedError( int errorCode, String description, String failingUrl)
{
super.loadUrl("file:///android_asset/www/index.html", 1000);
//Server down.
}
}


What am not sure of, is it that i need to update phonegap. How would this be done since i cannot even find any latest phonegap jars.
I am really in need of help. 

Thank you.  

Kerri Shotts

unread,
Nov 25, 2016, 2:45:45 PM11/25/16
to phonegap
What version of PhoneGap are you using? Note that PhoneGap now uses a CLI to manage projects, so I suspect you 're on a really ancient version, which would also prevent your acceptance to the Google Play Market.

On Friday, November 25, 2016 at 1:31:32 PM UTC-6, Brian Byaruhanga wrote:
...
Reply all
Reply to author
Forward
0 new messages