DX Application Performance Management

Expand all | Collapse all

Tech Tip - CA MAA: MAA Tooling of Hybrid Mobile Applications

  • 1.  Tech Tip - CA MAA: MAA Tooling of Hybrid Mobile Applications

    Broadcom Employee
    Posted 06-24-2015 06:34 PM

    CA Mobile Application Analytics (MAA) Tuesday Tip by Bryan Whitmarsh, Sr Principal Technical Consultant for Tuesday, June 23, 2015


    In this Tuesday tip we will walk you through how to properly equip hybrid based mobile applications with the CA MAA SDK. Hybrid mobile applications are becoming increasingly popular in today’s Application Economy. The concept of a Hybrid mobile application is to be able to leverage web development skills, such as HTML, CSS, and JavaScript programing, to build mobile applications that can be run natively on multiple mobile platforms. Cordova (formerly known as PhoneGap) and Appcelerator’s Titanium solutions are two such solutions. Both hybrid solutions allow you to build native iOS (.ipa) and Android (.apk) mobile applications from device agnostic coding. Both hybrid mobile application development approaches are supported by CA MAA but can require some modifications during the MAA SDK tooling process.


    Wrapping of Android Hybrid Apps


    Step 1

    In some cases the console wrapping method will work for Hybrid mobile apps just as it does for native Android apps. To do this, simply take the .apk file generated by the hybrid platform and upload it in the CA MAA Console using the “APPS->ANDROID->UPLOAD A VAILD ANDROID APP” automated wrapping process. If you are returned a wrapped .apk file that will load, run, and report analytics to your CA MAA Console, you are done. If you receive any errors during this process, your app crashes on load, or you are not receiving analytics from the app, proceed to step 2.

    Image_01.jpg

     

    Step 2

    DOWNLOAD THE WRAPPER UTILITY by clicking on the download link on the “APPS->ANDROID screen. Additionally you will need to DOWNLOAD THE PROPERTIES (PLIST) FILE. Complete the Wrapper Utility steps 1 & 2 to unzip the utility files. Note: This wrapper utility needs to be run on a UNIX/Linux or MacOS operating system running Java 7.0.

    Image_02.jpg

     

    Step 3

    Rename the “android.xml” file in the wrapper_dir\emm\conf directory to “android.xml.original”, and rename the “android-cordova.xml” to “android.xml”

    Image_03.jpg

    Image_04.jpg

     

    Step 4

    Complete step 3 of the Wrapper Utility instructions to wrap the .apk file

    Image_05.jpg

     

    Step 5

    Load app (.apk) on a simulator/device and test

     

    Wrapping of iOS Hybrid Apps

    The hybrid application platform should build a native Xcode project. Once you have the Xcode project, open it in Xcode and follow the standard iOS Instructions on the “APPS->iOS” screen.

    Image_06.jpg



  • 2.  Re: Tech Tip - CA MAA: MAA Tooling of Hybrid Mobile Applications

    Posted 09-14-2015 08:04 AM

    Hi,

    I tried to wrapping of Android Hybrid Apps, but in the step 4, i have the next text (in bold type the error message):

     

    sh wrap.sh -a /home/tdi/Downloads/app.apk -p /home/tdi/Downloads/app.plist -v

    checking for /usr/java/jdk1.7.0_79/bin/jarsigner ...

    checking for /home/tdi/Downloads/app.apk ...

    checking for /home/tdi/Downloads/app.plist ...

    checking for emm/conf/mdo.keystore ...

    /home/tdi/Downloads/ca-maa-android-sdk-wrapper-15.2/emm

    Using JAVA_HOME=/usr/java/jdk1.7.0_79

    APK File: /home/tdi/Downloads/app.apk

    Plist: /home/tdi/Downloads/app.plist

    Keystore: emm/conf/mdo.keystore

    Wrapper: ca-maa-android-sdk-wrapper-15.2.jar

    Certificate Password: *******

    Keystore Password: *******

    Alias: mdo

    /usr/java/jdk1.7.0_79/bin/java -jar ca-maa-android-sdk-wrapper-15.2.jar -verbose -apk /home/tdi/Downloads/app.apk -plist /home/tdi/Downloads/app.plist -rules emm/conf/android.xml -keystore emm/conf/mdo.keystore -storepass mobiledevops -keypass mobiledevops -buildtype release -alias mdo

    INFO: Using container file:/home/tdi/Downloads/ca-maa-android-sdk-wrapper-15.2/emm/lib/android/container-release.apk

    INFO: [java, -jar, /home/tdi/Downloads/ca-maa-android-sdk-wrapper-15.2/emm/bin/android/apktool.jar, -q, d, /home/tdi/Downloads/ca-maa-android-sdk-wrapper-15.2/emm/lib/android/container-release.apk, -o, /tmp/AndroidWrapper_47812646712620946709019235677065___9035942/sdk]

    INFO: SDK APK Extraction Completed!

    Step 1 of 4: Extracting Target APK: app.apk

    INFO: [java, -jar, /home/tdi/Downloads/ca-maa-android-sdk-wrapper-15.2/emm/bin/android/apktool.jar, -q, d, /home/tdi/Downloads/app.apk, -o, /tmp/AndroidWrapper_47812646712620946709019235677065___9035942/apktoolExtract]

    INFO: APK Extraction Completed!

    Step 2 of 4: Instrumenting ......

    DEBUG: Replacing .super Landroid/app/Activity; with .super Lcom/ca/android/app/CaMDOActivity; in PreviewActivity.smali

    DEBUG: Replacing .super Landroid/app/Activity; with .super Lcom/ca/android/app/CaMDOActivity; in FragmentActivity.smali

    DEBUG: Replacing Landroid/webkit/WebView;->loadUrl(Ljava/lang/String;)V with Lcom/ca/android/app/CaMDOWebView;->loadUrl(Landroid/webkit/WebView;Ljava/lang/String;)V in CordovaWebView.smali

    DEBUG: Replacing invoke-super with invoke-static in CordovaWebView.smali

    DEBUG: Replacing .method public setWebViewClient(Landroid/webkit/WebViewClient;)V with .method public setWebViewClient2(Landroid/webkit/WebViewClient;)V in CordovaWebView.smali

    DEBUG: Replacing Landroid/webkit/WebView;->setWebViewClient(Landroid/webkit/WebViewClient;)V with Lcom/ca/android/app/CaMDOWebView;->setWebViewClient(Landroid/webkit/WebView;Landroid/webkit/WebViewClient;)V in CordovaWebView.smali

    DEBUG: Replacing invoke-super with invoke-static in CordovaWebView.smali

    DEBUG: Replacing Landroid/webkit/WebView;->setWebViewClient(Landroid/webkit/WebViewClient;)V with Lcom/ca/android/app/CaMDOWebView;->setWebViewClient(Landroid/webkit/WebView;Landroid/webkit/WebViewClient;)V in CordovaWebView.smali

    DEBUG: Replacing invoke-super with invoke-static in CordovaWebView.smali

    DEBUG: Replacing Ljava/net/HttpURLConnection;->connect()V with Lcom/ca/android/app/CaMDOHTTPClient;->connect(Ljava/net/HttpURLConnection;)V in FileTransfer$3.smali

    DEBUG: Replacing invoke-virtual with invoke-static in FileTransfer$3.smali

    DEBUG: Replacing Ljava/net/HttpURLConnection;->getResponseCode()I with Lcom/ca/android/app/CaMDOHTTPClient;->getResponseCode(Ljava/net/HttpURLConnection;)I in FileTransfer$3.smali

    DEBUG: Replacing invoke-virtual with invoke-static in FileTransfer$3.smali

    DEBUG: Replacing Ljava/net/HttpURLConnection;->connect()V with Lcom/ca/android/app/CaMDOHTTPClient;->connect(Ljava/net/HttpURLConnection;)V in HttpUrlConnectionNetworkClient.smali

    DEBUG: Replacing invoke-virtual with invoke-static in HttpUrlConnectionNetworkClient.smali

    DEBUG: Replacing Ljava/net/URL;->openConnection()Ljava/net/URLConnection; with Lcom/ca/android/app/CaMDOHTTPClient;->openConnection(Ljava/net/URL;)Ljava/net/URLConnection; in HttpUrlConnectionNetworkClient.smali

    DEBUG: Replacing invoke-virtual with invoke-static in HttpUrlConnectionNetworkClient.smali

    DEBUG: Replacing Ljava/net/HttpURLConnection;->getResponseCode()I with Lcom/ca/android/app/CaMDOHTTPClient;->getResponseCode(Ljava/net/HttpURLConnection;)I in HttpUrlConnectionNetworkClient.smali

    DEBUG: Replacing invoke-virtual with invoke-static in HttpUrlConnectionNetworkClient.smali

    DEBUG: Replacing Lorg/apache/http/client/HttpClient;->execute(Lorg/apache/http/HttpHost;Lorg/apache/http/HttpRequest;)Lorg/apache/http/HttpResponse; with Lcom/ca/android/app/CaMDOHTTPClient;->execute(Lorg/apache/http/client/HttpClient;Lorg/apache/http/HttpHost;Lorg/apache/http/HttpRequest;)Lorg/apache/http/HttpResponse; in SimpleNetworkDispatcher.smali

    DEBUG: Replacing invoke-interface with invoke-static in SimpleNetworkDispatcher.smali

    DEBUG: Replacing Ljava/net/HttpURLConnection;->getResponseCode()I with Lcom/ca/android/app/CaMDOHTTPClient;->getResponseCode(Ljava/net/HttpURLConnection;)I in FileTransfer.smali

    DEBUG: Replacing invoke-virtual with invoke-static in FileTransfer.smali

    DEBUG: Replacing Ljava/net/HttpURLConnection;->connect()V with Lcom/ca/android/app/CaMDOHTTPClient;->connect(Ljava/net/HttpURLConnection;)V in FileTransfer$4.smali

    DEBUG: Replacing invoke-virtual with invoke-static in FileTransfer$4.smali

    DEBUG: Replacing .super Landroid/app/Activity; with .super Lcom/ca/android/app/CaMDOActivity; in CordovaActivity.smali

    DEBUG: Replacing Lorg/apache/http/client/HttpClient;->execute(Lorg/apache/http/client/methods/HttpUriRequest;)Lorg/apache/http/HttpResponse; with Lcom/ca/android/app/CaMDOHTTPClient;->execute(Lorg/apache/http/client/HttpClient;Lorg/apache/http/client/methods/HttpUriRequest;)Lorg/apache/http/HttpResponse; in HttpNetworkClient.smali

    DEBUG: Replacing invoke-interface with invoke-static in HttpNetworkClient.smali

    DEBUG: Replacing Lorg/apache/http/client/HttpClient;->execute(Lorg/apache/http/client/methods/HttpUriRequest;)Lorg/apache/http/HttpResponse; with Lcom/ca/android/app/CaMDOHTTPClient;->execute(Lorg/apache/http/client/HttpClient;Lorg/apache/http/client/methods/HttpUriRequest;)Lorg/apache/http/HttpResponse; in HttpNetworkClient.smali

    DEBUG: Replacing invoke-interface with invoke-static in HttpNetworkClient.smali

    DEBUG: Replacing Lorg/apache/http/client/HttpClient;->execute(Lorg/apache/http/HttpHost;Lorg/apache/http/HttpRequest;)Lorg/apache/http/HttpResponse; with Lcom/ca/android/app/CaMDOHTTPClient;->execute(Lorg/apache/http/client/HttpClient;Lorg/apache/http/HttpHost;Lorg/apache/http/HttpRequest;)Lorg/apache/http/HttpResponse; in SimpleNetworkDispatcher.smali

    DEBUG: Replacing invoke-interface with invoke-static in SimpleNetworkDispatcher.smali

    DEBUG: Replacing .super Landroid/app/Activity; with .super Lcom/ca/android/app/CaMDOActivity; in SplashScreenActivity.smali

    ..........Done Instrumenting.

    INFO: Smali manipulation Completed!

    INFO: SDK Integration Completed!

    INFO: AndroidManifest.xml permission modification Completed!

    Step 3 of 4: Packaging instrumented APK.

    INFO: [java, -jar, /home/tdi/Downloads/ca-maa-android-sdk-wrapper-15.2/emm/bin/android/apktool.jar, -q, b, -a, aapt, /tmp/AndroidWrapper_47812646712620946709019235677065___9035942/apktoolExtract, -o, /tmp/AndroidWrapper_47812646712620946709019235677065___9035942/manifest_modded_app.apk]

    Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [/tmp/brut_util_Jar_3932222511666891560.tmp, p, --forced-package-id, 127, --min-sdk-version, 10, --target-sdk-version, 17, --max-sdk-version, 21, --max-res-version, 21, --version-code, 24, --version-name, 4.0.6, -F, /tmp/APKTOOL7317367416411626094.tmp, -0, arsc, -I, /root/apktool/framework/1.apk, -S, /tmp/AndroidWrapper_47812646712620946709019235677065___9035942/apktoolExtract/res, -M, /tmp/AndroidWrapper_47812646712620946709019235677065___9035942/apktoolExtract/AndroidManifest.xml]

      at brut.androlib.Androlib.buildResourcesFull(Androlib.java:442)

      at brut.androlib.Androlib.buildResources(Androlib.java:379)

      at brut.androlib.Androlib.build(Androlib.java:282)

      at brut.androlib.Androlib.build(Androlib.java:255)

      at brut.apktool.Main.cmdBuild(Main.java:225)

      at brut.apktool.Main.main(Main.java:84)

    Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [/tmp/brut_util_Jar_3932222511666891560.tmp, p, --forced-package-id, 127, --min-sdk-version, 10, --target-sdk-version, 17, --max-sdk-version, 21, --max-res-version, 21, --version-code, 24, --version-name, 4.0.6, -F, /tmp/APKTOOL7317367416411626094.tmp, -0, arsc, -I, /root/apktool/framework/1.apk, -S, /tmp/AndroidWrapper_47812646712620946709019235677065___9035942/apktoolExtract/res, -M, /tmp/AndroidWrapper_47812646712620946709019235677065___9035942/apktoolExtract/AndroidManifest.xml]

      at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:504)

      at brut.androlib.Androlib.buildResourcesFull(Androlib.java:428)

      ... 5 more

    Caused by: brut.common.BrutException: could not exec command: [/tmp/brut_util_Jar_3932222511666891560.tmp, p, --forced-package-id, 127, --min-sdk-version, 10, --target-sdk-version, 17, --max-sdk-version, 21, --max-res-version, 21, --version-code, 24, --version-name, 4.0.6, -F, /tmp/APKTOOL7317367416411626094.tmp, -0, arsc, -I, /root/apktool/framework/1.apk, -S, /tmp/AndroidWrapper_47812646712620946709019235677065___9035942/apktoolExtract/res, -M, /tmp/AndroidWrapper_47812646712620946709019235677065___9035942/apktoolExtract/AndroidManifest.xml]

      at brut.util.OS.exec(OS.java:94)

      at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:498)

      ... 6 more

    Caused by: java.io.IOException: Cannot run program "/tmp/brut_util_Jar_3932222511666891560.tmp": error=2, No such file or directory

      at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)

      at java.lang.Runtime.exec(Runtime.java:617)

      at java.lang.Runtime.exec(Runtime.java:485)

      at brut.util.OS.exec(OS.java:84)

      ... 7 more

    Caused by: java.io.IOException: error=2, No such file or directory

      at java.lang.UNIXProcess.forkAndExec(Native Method)

      at java.lang.UNIXProcess.<init>(UNIXProcess.java:186)

      at java.lang.ProcessImpl.start(ProcessImpl.java:130)

      at java.lang.ProcessBuilder.start(ProcessBuilder.java:1028)

      ... 10 more

    INFO: Completed repackaging target APK files

    INFO: Packing with apktool Completed!

    Step 4 of 4: Signing APK with dummy certificate.

    INFO: APK Signing Started

    DEBUG: Running command:jarsigner -tsa http://timestamp.digicert.com -sigalg MD5withRSA -digestalg SHA1 -keystore emm/conf/mdo.keystore -storepass welcome1 /tmp/AndroidWrapper_47812646712620946709019235677065___9035942/manifest_modded_app.apk mdo -keypass mobiledevops -storepass mobiledevops

    DEBUG: Current  dir using System:/home/tdi/Downloads/ca-maa-android-sdk-wrapper-15.2

    jarsigner: unable to open jar file: /tmp/AndroidWrapper_47812646712620946709019235677065___9035942/manifest_modded_app.apk

    ERROR: jar signing failed...

    ERROR: Exiting, Signing APK failed!

    Exception: Exiting, Signing APK failed!

    java.lang.Exception: Exiting, Signing APK failed!

      at com.ca.android.wrapper.Wrapper.startWrapping(Wrapper.java:183)

      at com.ca.android.wrapper.Wrapper.doWrap(Wrapper.java:63)

      at com.ca.android.wrapper.Wrapper.doWrap(Wrapper.java:37)

      at com.ca.android.wrapper.CAAPKWrapper.runWrapper(CAAPKWrapper.java:165)

      at com.ca.android.wrapper.CAAPKWrapper.main(CAAPKWrapper.java:156)

    Total time: 25 secs

     

    Please, can you help me?



  • 3.  Re: Tech Tip - CA MAA: MAA Tooling of Hybrid Mobile Applications

    Posted 10-07-2015 12:57 PM

    This TIP can function in windows, use:

    GIT Bash.png

    And modifies wrap.sh file, comment the next lines:

    if [[ -z "$JAVA_HOME" ]]

    then

    echo "JAVA_HOME not set."

    exit -1;

    fi

    And add the path of the Java JDK:

    JAVA_HOME="C:\Progra~1\Java\jdk1.8.0_60"



  • 4.  Re: Tech Tip - CA MAA: MAA Tooling of Hybrid Mobile Applications

    Broadcom Employee
    Posted 10-14-2015 08:01 AM

    Hi Martin,

     

    It looks as there is a problem while recompiling the apk's file resources.

     

    Request you to take a backup of your 1.apk( Location on RHEL:- /root/apktool/framework/1.apk; orlook in  ~/Library/apktool/framework/1.apk) file in any backup folder and post backup delete the 1.apk file .

    and try wrapping again using the wrap.sh