About Me

My photo
India
Hey there, lovely people! I'm Hemant Menaria, and I'm passionate about programming. Having completed my MCA in 2011, I've delved into the world of coding with fervor. I believe in sharing knowledge, making complex concepts easy to grasp for everyone. JAVA, PHP, and ANDROID hold a special place in my heart, and I spend most of my time immersed in them. Currently, I'm deeply engaged in API/Webservice frameworks and crafting Hybrid mobile applications to enhance flexibility in the digital realm. If you ever find yourself stuck with a programming challenge, feel free to reach out to me at +91-8955499900 or drop me a line at hemantmenaria008@gmail.com. I'm always eager to help fellow enthusiasts navigate the intricacies of coding!

Sunday, November 7, 2021

Apache Cordova app issues

Here I am sharing all the issues/errors which I get during Cordova mobile app development-

1-Call to undefined method mysqli_stmt::get_result

Solution: https://stackoverflow.com/questions/8321096/call-to-undefined-method-mysqli-stmtget-result

cpanel dispable mysqli and enable nd_mysqli


2- Server origin access issue  (Unable to access API hosted on server)

   v1=> .htaccess => added following lines

<IfModule mod_headers.c>

    Header set Access-Control-Allow-Origin "*"

</IfModule>


3- Emulator : net not working. 

   First change DNS to 8.8.8.8 of the computer where avd running.

   Now open android studio=> tools=>AVD manager=> select drop down arrow of the AVD(Emulator)=> click on "Cold Boot Now"


4- Add platform: cordova platform add android

                 cordova platform rm android

cordova platform add browser


5- Run app into emulator:

cordova build --emulator

cordova run android --emulator

To run in mobile-> cordova run or cordova run android

To browser  cordova run browser


6- Biggest Issue: 

i) Why am I seeing net::ERR_CLEARTEXT_NOT_PERMITTED errors in cordova 8/9.....?

        ii) was unable to call API using jquery ajax : Error was cordova app ajax api call returning xhr.status 0

Solution: go to config.xml

<widget id="com.my.awesomeapp" version="1.0.0" xmlns="http://www.w3.org/ns/widgets"

xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">

this line already in config.xml but here you can see xmln:android  not there so just copy xmlns:android="http://schemas.android.com/apk/res/android" 

and past it there.

now past below <edit-config....>....</edit-config> into <plateform name="android"> ..../<platform> section.

<platform name="android">

  <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">

      <application android:usesCleartextTraffic="true" />

  </edit-config>

</platform>

for more details please check https://stackoverflow.com/questions/54752716/why-am-i-seeing-neterr-cleartext-not-permitted-errors-after-upgrading-to-cordo


7- Issue : if you want to use <script> in .html file then need to add follwoing

 <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' http://* 'unsafe-inline'; script-src 'self' http://* 'unsafe-inline' 'unsafe-eval'" />

No comments:

Post a Comment