Software Archive
Read-only legacy content
17060 Discussions

Cordova Hybrid App fails, Legacy Android Build Works

Priyabrata_C_
Beginner
802 Views

I've written a small application to test the working of cordova app on XDK.
However, I am attaching the code here :

    (function()
    {
     "use strict";
     /*
       hook up event handlers 
     */
     function register_event_handlers()
     {
        
        
         /* button  Login */
        $(document).on("click", ".uib_w_9", function(evt)
        {
            //intel.xdk.notification.showBusyIndicator(); 
           /*$.post("http://url/test.php", {test:'1'}, 
                function(res){
                    alert(res);
                }
           );*/
            $.ajax({
              beforeSend: function(){
                intel.xdk.notification.showBusyIndicator();
              },
              type: "GET",
              url: 'http://url/test.php',
              data:{test:'1'},
              success: function(res){
                  alert(res);
                  intel.xdk.notification.hideBusyIndicator(); 
              },
              error:function(res){
                  alert(res);
                  intel.xdk.notification.hideBusyIndicator(); 
              },
              dataType: 'text'
            });
            
        });
        
        }
     document.addEventListener("app.Ready", register_event_handlers, false);
    })();

This is the JS file of the application.

The screenshot of the app in XDK emulator :

1.jpg

 

2.jpg

Now When I do a build of the app using XDK cloud, I get a .apk file.

On uploading the file to GenyMotion Emulator, screen below :

3.jpg

The click doesn't do anything, nor does the `showBusyIndicator()` show, nor the alert appear.

What am I missing and what is going wrong ?
I've plans to use this ide for a proper project and hence the testing, some help will be appreciated.

*UPDATE*

4.jpg
I did a Cordova Hybrid App build initially and that caused the problem.

When I did a legacy android build, then the problem was solved.

So what do I need to do to get it to work with the Cordova Build ?

0 Kudos
6 Replies
Rakshith_K_Intel
Employee
802 Views

There is a known issue with AJAX when Intel XDK builds apk with Cordova CLI version 4.1.2. on Android version > 4.4

There is a workaround, go to Project Settings -> Build Settings -> Android, change Cordova CLI version from 4.1.2 to 3.5 and AJAX should work.

0 Kudos
Priyabrata_C_
Beginner
802 Views

Rakshith Krishnappa (Intel) wrote:

There is a known issue with AJAX when Intel XDK builds apk with Cordova CLI version 4.1.2. on Android version > 4.4

There is a workaround, go to Project Settings -> Build Settings -> Android, change Cordova CLI version from 4.1.2 to 3.5 and AJAX should work.

I did that and it didn't solve the issue.

Here is the build log of my application :

Installing "org.apache.cordova.device" for android
sourcefile check passed
Installing "org.apache.cordova.vibration" for android
sourcefile check passed
Installing "org.apache.cordova.dialogs" for android
sourcefile check passed
cordova library for "android" already exists. No need to download. Continuing.
Generating config.xml from defaults for platform "android"
Calling plugman.prepare for platform "android"
Preparing android project
Processing configuration changes for plugins.
Iterating over installed plugins: [ 'org.apache.cordova.device',
  'org.apache.cordova.vibration',
  'org.apache.cordova.dialogs' ]
Writing out cordova_plugins.js...
Wrote out Android application name to "eNotice"
splash screens: []
Wrote out Android package name to "xdk.intel.blank.ad.template"
************* Processing the main config.xml file (after_prepare)  *****************
App Directory = [.../eNotice]
Will process and update the following config files:
    Config.xml = [.../eNotice/config.xml]
Namespaces:
    prefix/uri ''/'http://www.w3.org/ns/widgets'
    prefix/uri 'intelxdk'/'http://xdk.intel.com/ns/v1'
Android Manifest Namespaces:
    prefix/uri 'android'/'http://schemas.android.com/apk/res/android'
Name of the app is [eNotice]
Updating full app name to [eNotice]
Processing preference android-minSdkVersion [10]
Processing preference android-targetSdkVersion [19]
Processing preference android-installLocation [preferExternal]
Processing preference permissions
Updating the versionCode
Updating the versionName
Processing debuggable
Added [{http://schemas.android.com/apk/res/android}debuggable] with [false]
Processing config file values
No splash screen supplied for drawable-land-mdpi.  Cleaning up.
Removing unused density: .../eNotice/platforms/android/res/drawable-land-mdpi
No splash screen supplied for drawable-port-xhdpi.  Cleaning up.
Removing unused density: .../eNotice/platforms/android/res/drawable-port-xhdpi
No splash screen supplied for drawable-port-ldpi.  Cleaning up.
Removing unused density: .../eNotice/platforms/android/res/drawable-port-ldpi
No splash screen supplied for drawable-land-ldpi.  Cleaning up.
Removing unused density: .../eNotice/platforms/android/res/drawable-land-ldpi
No splash screen supplied for drawable-port-hdpi.  Cleaning up.
Removing unused density: .../eNotice/platforms/android/res/drawable-port-hdpi
No splash screen supplied for drawable-land-xhdpi.  Cleaning up.
Removing unused density: .../eNotice/platforms/android/res/drawable-land-xhdpi
No splash screen supplied for drawable-land-hdpi.  Cleaning up.
Removing unused density: .../eNotice/platforms/android/res/drawable-land-hdpi
No splash screen supplied for drawable-port-mdpi.  Cleaning up.
Removing unused density: .../eNotice/platforms/android/res/drawable-port-mdpi
Saving config.xml to [.../eNotice/config.xml]
************* Completed processing the main config.xml file (after_prepare)  *****************
Running command: .../eNotice/platforms/android/cordova/build --release
Buildfile: .../eNotice/platforms/android/build.xml

-set-mode-check:

-set-release-mode:

-release-obfuscation-check:
     [echo] proguard.config is ${proguard.config}

-pre-build:

-check-env:
 [checkenv] Android SDK Tools Revision 22.3.0
 [checkenv] Installed at /Developer/android-sdk-linux

-setup:
     [echo] Project Name: eNotice
  [gettype] Project Type: Application

-build-setup:
[getbuildtools] Using latest Build Tools: 19.0.0
     [echo] Resolving Build Target for eNotice...
[gettarget] Project Target:   Android 4.4
[gettarget] API level:        19
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: .../eNotice/platforms/android/ant-build
    [mkdir] Created dir: .../eNotice/platforms/android/ant-build/res
    [mkdir] Created dir: .../eNotice/platforms/android/ant-build/rsObj
    [mkdir] Created dir: .../eNotice/platforms/android/ant-build/rsLibs
    [mkdir] Created dir: .../eNotice/platforms/android/ant-gen
    [mkdir] Created dir: .../eNotice/platforms/android/ant-build/classes
    [mkdir] Created dir: .../eNotice/platforms/android/ant-build/dexedLibs
     [echo] ----------
     [echo] Resolving Dependencies for eNotice...
[dependency] Library dependencies:
[dependency] 
[dependency] ------------------
[dependency] Ordered libraries:
[dependency] 
[dependency] ------------------
     [echo] ----------
     [echo] Building Libraries with 'release'...

nodeps:

-set-mode-check:

-set-release-mode:

-release-obfuscation-check:
     [echo] proguard.config is ${proguard.config}

-pre-build:

-check-env:
 [checkenv] Android SDK Tools Revision 22.3.0
 [checkenv] Installed at /Developer/android-sdk-linux

-setup:
     [echo] Project Name: CordovaLib
  [gettype] Project Type: Android Library

-build-setup:
[getbuildtools] Using latest Build Tools: 19.0.0
     [echo] Resolving Build Target for CordovaLib...
[gettarget] Project Target:   Android 4.4
[gettarget] API level:        19
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: .../eNotice/platforms/android/CordovaLib/res
    [mkdir] Created dir: .../eNotice/platforms/android/CordovaLib/libs
    [mkdir] Created dir: .../eNotice/platforms/android/CordovaLib/ant-build
    [mkdir] Created dir: .../eNotice/platforms/android/CordovaLib/ant-build/res
    [mkdir] Created dir: .../eNotice/platforms/android/CordovaLib/ant-build/rsObj
    [mkdir] Created dir: .../eNotice/platforms/android/CordovaLib/ant-build/rsLibs
    [mkdir] Created dir: .../eNotice/platforms/android/CordovaLib/ant-gen
    [mkdir] Created dir: .../eNotice/platforms/android/CordovaLib/ant-build/classes
    [mkdir] Created dir: .../eNotice/platforms/android/CordovaLib/ant-build/dexedLibs
     [echo] ----------
     [echo] Resolving Dependencies for CordovaLib...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency] 
[dependency] ------------------

-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Generating resource IDs...
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.

-pre-compile:

-compile:
    [javac] Compiling 90 source files to .../eNotice/platforms/android/CordovaLib/ant-build/classes
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
     [echo] Creating library output jar file...
      [jar] Building jar: .../eNotice/platforms/android/CordovaLib/ant-build/classes.jar

-post-compile:

-obfuscate:

-dex:
     [echo] Library project: do not convert bytecode...

-crunch:
   [crunch] Crunching PNG Files in source dir: .../eNotice/platforms/android/CordovaLib/res
   [crunch] To destination dir: .../eNotice/platforms/android/CordovaLib/ant-build/res
   [crunch] Crunched 0 PNG files to update cache

-package-resources:
     [echo] Library project: do not package resources...

-package:
     [echo] Library project: do not package apk...

-post-package:

-release-prompt-for-password:

-release-nosign:
     [echo] 
[propertyfile] Creating new property file: .../eNotice/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: .../eNotice/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: .../eNotice/platforms/android/CordovaLib/ant-build/build.prop
[propertyfile] Updating property file: .../eNotice/platforms/android/CordovaLib/ant-build/build.prop

-release-sign:

-post-build:

release:

-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Generating resource IDs...
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.

-pre-compile:
     [echo] Set jars path to: .../eNotice/platforms/android/CordovaLib/ant-build/classes.jar

-compile:
    [javac] Compiling 6 source files to .../eNotice/platforms/android/ant-build/classes

-post-compile:

-obfuscate:

-dex:
      [dex] input: .../eNotice/platforms/android/ant-build/classes
      [dex] input: .../eNotice/platforms/android/CordovaLib/ant-build/classes.jar
      [dex] Pre-Dexing .../eNotice/platforms/android/CordovaLib/ant-build/classes.jar -> classes-7a8cb2c4258d51a75004d6bebdfd1e1f.jar
      [dex] Converting compiled files and external libraries into .../eNotice/platforms/android/ant-build/classes.dex...
       [dx] Merged dex A (27 defs/16.1KiB) with dex B (207 defs/313.8KiB). Result is 234 defs/401.3KiB. Took 0.2s

-crunch:
   [crunch] Crunching PNG Files in source dir: .../eNotice/platforms/android/res
   [crunch] To destination dir: .../eNotice/platforms/android/ant-build/res
   [crunch] Processing image to cache: .../eNotice/platforms/android/res/drawable-hdpi/icon.png => .../eNotice/platforms/android/ant-build/res/drawable-hdpi/icon.png
   [crunch]   (processed image to cache entry .../eNotice/platforms/android/ant-build/res/drawable-hdpi/icon.png: 67% size of source)
   [crunch] Processing image to cache: .../eNotice/platforms/android/res/drawable-ldpi/icon.png => .../eNotice/platforms/android/ant-build/res/drawable-ldpi/icon.png
   [crunch]   (processed image to cache entry .../eNotice/platforms/android/ant-build/res/drawable-ldpi/icon.png: 0% size of source)
   [crunch] Processing image to cache: .../eNotice/platforms/android/res/drawable-mdpi/icon.png => .../eNotice/platforms/android/ant-build/res/drawable-mdpi/icon.png
   [crunch]   (processed image to cache entry .../eNotice/platforms/android/ant-build/res/drawable-mdpi/icon.png: 0% size of source)
   [crunch] Processing image to cache: .../eNotice/platforms/android/res/drawable-xhdpi/icon.png => .../eNotice/platforms/android/ant-build/res/drawable-xhdpi/icon.png
   [crunch]   (processed image to cache entry .../eNotice/platforms/android/ant-build/res/drawable-xhdpi/icon.png: 53% size of source)
   [crunch] Processing image to cache: .../eNotice/platforms/android/res/drawable/icon.png => .../eNotice/platforms/android/ant-build/res/drawable/icon.png
   [crunch]   (processed image to cache entry .../eNotice/platforms/android/ant-build/res/drawable/icon.png: 53% size of source)
   [crunch] Crunched 5 PNG files to update cache

-package-resources:
     [aapt] Creating full resource package...

-package:
[apkbuilder] Current build type is different than previous build: forced apkbuilder run.
[apkbuilder] Creating eNotice-release-unsigned.apk for release...

-post-package:

-release-prompt-for-password:

-release-nosign:
     [echo] No key.store and key.alias properties found in build.properties.
     [echo] Please sign .../eNotice/platforms/android/ant-build/eNotice-release-unsigned.apk manually
     [echo] and run zipalign from the Android SDK tools.
[propertyfile] Creating new property file: .../eNotice/platforms/android/ant-build/build.prop
[propertyfile] Updating property file: .../eNotice/platforms/android/ant-build/build.prop
[propertyfile] Updating property file: .../eNotice/platforms/android/ant-build/build.prop
[propertyfile] Updating property file: .../eNotice/platforms/android/ant-build/build.prop

-release-sign:

-post-build:
     [move] Moving 1 file to .../eNotice/platforms/android/ant-build
     [move] Moving 1 file to .../eNotice/platforms/android/CordovaLib/ant-build

release:

BUILD SUCCESSFUL
Total time: 9 seconds
Command finished with error code 0: .../eNotice/platforms/android/cordova/build --release

 

And here is a screenshot of my settings page :

Capture.JPG

0 Kudos
Rakshith_K_Intel
Employee
802 Views

PM me the zip of your project

0 Kudos
Priyabrata_C_
Beginner
802 Views

Rakshith Krishnappa (Intel) wrote:

PM me the zip of your project

 

Sent!

0 Kudos
Rakshith_K_Intel
Employee
802 Views

I looked at your project and built the android app and also emailed to you.

ajax is working fine, on android 5 device, i get back AOK response.

One change I made was, set the domain list to *

I noticed you are building using regular Android, try using "Crosswalk for Android" to get better backwards compatibility with older version of Android 4.x devices. you can read more about Crosswalk here: https://software.intel.com/en-us/xdk/docs/why-use-crosswalk-for-android-builds

 

 

 

0 Kudos
Priyabrata_C_
Beginner
802 Views

The domain list was set to just my domain and it work'd that way with the regular build.

After building with Crosswalk and with that *, the Ajax is failing again (it was working after setting the domain thing in regular android).

 

0 Kudos
Reply