0
votes

How to resolve the following error when using native HTML5 geolocation or Android Cordova plugin geolocation?

06-09 12:39:28.123 1552-1712/? D/WifiService: releaseWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@a1995d8}
06-09 12:39:33.126 1552-1711/? D/WifiService: acquireWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@a1995d8}
06-09 12:39:33.309 1826-2282/? W/System.err: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
06-09 12:39:33.309 1826-2282/? W/System.err:     at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:328)
06-09 12:39:33.309 1826-2282/? W/System.err:     at android.net.SSLCertificateSocketFactory.verifyHostname(SSLCertificateSocketFactory.java:198)
06-09 12:39:33.309 1826-2282/? W/System.err:     at android.net.SSLCertificateSocketFactory.createSocket(SSLCertificateSocketFactory.java:443)
06-09 12:39:33.310 1826-2282/? W/System.err:     at com.android.okhttp.internal.http.SocketConnector.connectTls(SocketConnector.java:89)
06-09 12:39:33.310 1826-2282/? W/System.err:     at com.android.okhttp.Connection.connect(Connection.java:143)
06-09 12:39:33.310 1826-2282/? W/System.err:     at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:185)
06-09 12:39:33.310 1826-2282/? W/System.err:     at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128)
06-09 12:39:33.310 1826-2282/? W/System.err:     at com.android.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:341)
06-09 12:39:33.310 1826-2282/? W/System.err:     at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330)
06-09 12:39:33.315 1826-2282/? W/System.err:     at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248)
06-09 12:39:33.316 1826-2282/? W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:433)
06-09 12:39:33.317 1826-2282/? W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:114)
06-09 12:39:33.317 1826-2282/? W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:245)
06-09 12:39:33.317 1826-2282/? W/System.err:     at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218)
06-09 12:39:33.317 1826-2282/? W/System.err:     at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java)
06-09 12:39:33.317 1826-2282/? W/System.err:     at com.google.android.gms.http.GoogleHttpClient.a(SourceFile:948)
06-09 12:39:33.317 1826-2282/? W/System.err:     at com.google.android.gms.http.GoogleHttpClient.a(SourceFile:766)
06-09 12:39:33.317 1826-2282/? W/System.err:     at com.google.android.gms.http.GoogleHttpClient.execute(SourceFile:674)
06-09 12:39:33.319 1826-2282/? W/System.err:     at com.google.android.gms.http.GoogleHttpClient.execute(SourceFile:658)
06-09 12:39:33.319 1826-2282/? W/System.err:     at com.google.r.a.b.a.b.g(SourceFile:126)
06-09 12:39:33.319 1826-2282/? W/System.err:     at com.google.r.a.b.a.b.c(SourceFile:172)
06-09 12:39:33.319 1826-2282/? W/System.err:     at com.google.z.a.d.run(SourceFile:434)
06-09 12:39:33.319 1826-2282/? W/System.err:     at com.google.z.a.c.c(SourceFile:230)
06-09 12:39:33.319 1826-2282/? W/System.err:     at com.google.z.a.c.run(SourceFile:204)
06-09 12:39:33.319 1826-2282/? W/System.err:     at com.google.r.a.c.b.run(SourceFile:96)
06-09 12:39:33.323 1826-2282/? W/System.err: Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
06-09 12:39:33.324 1826-2282/? W/System.err:     at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:318)
06-09 12:39:33.324 1826-2282/? W/System.err:     at com.android.org.conscrypt.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:219)
06-09 12:39:33.324 1826-2282/? W/System.err:     at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:115)
06-09 12:39:33.324 1826-2282/? W/System.err:     at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:556)
06-09 12:39:33.324 1826-2282/? W/System.err:     at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
06-09 12:39:33.324 1826-2282/? W/System.err:     at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:324)
06-09 12:39:33.324 1826-2282/? W/System.err: 	... 24 more

I am trying to use - navigator.geolocation.getCurrentPosition(onSuccess, onError,{enableHighAccuracy:true}); or simple HTML5 -

        function getLocation() {

          console.log("get geolocation...");
            if (navigator.geolocation) {
              console.log("Possible..navigation...");
                navigator.geolocation.getCurrentPosition(showPosition, showError);
            } else { 
               console.log("Geolocation is not supported by this browser.");
            }
        }

Bith are not working in Nexus emulator, Asus zenfone 5 - android 4.4.

How to resolve this?

1
Have you added the plugin correctly? cordova.apache.org/docs/en/latest/reference/… also is the geolocation activated in the device? and the geolocation permission of the app? - Víctor
How do I added it? I have - <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> in manifest and cordova-plugin-geolocation in plugins list? anything els eto be mentioned in config.xml? - Smitha
If you installed it via 'cordova plugin add' It should be added by itself, if you do it manually you have to add it. - Víctor
also if i test - document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { if(navigator.geolocation){ console.log("navigator.geolocation works well");} else{console.log("navigator.geolocation doesnt works well");} }, it says - navigator.geolocation works well - Smitha
I have installed it through - cordova plugin add cordova-plugin-geolocation - Smitha

1 Answers

0
votes

I believe this issue happens when the device location/GPS is turned off. To ensure the device GPS is turned on, you can make use of the gps dialog plugin.

This plugin displays a dialog and redirect to GPS settings when the GPS is disabled in device.

Also request you to please have a look at this SO Post which can provide more info.