• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Flex mobile 4.6 app works inside flash builder but not in android emulator

Community Beginner ,
Dec 31, 2011 Dec 31, 2011

Copy link to clipboard

Copied

Originally posted on stackoverflow: http://stackoverflow.com/questions/8663892/flex-mobile-4-6-app-works-inside-flash-builder-but-not-in...

I have a basic flex mobile 4.6 app and it works fully fine in the flash builder built-in emulator using an android device profile like aria...

It also launches fine in the android emulator but one particular view shows blank (and this view works fine in flash builder).

Before I get in to many details of the view are there any categorical gotchas that can be causing this?

I can't seem to get the trace statements from the app to show in 'adb logcat'. It seems I need to compile a debug version of the apk but I don't know how to do this. I use the 'Export Release Build' from the Project menu in flash builder and it doesn't seem to have an option for debug=true.

The problematic/blank view basically uses the stagewebview and iotashan's oauth library to call linkedin rest apis... A different (and working) view can make restful web service calls in the emulator fine, so it doesn't seem to be an internet permission.

The source code contained in the problematic/blank view is almost identical to the tutorial found at:http://www.riagora.com/2011/01/air-and-linkedin/

The differences are: a) The root tag is a View b) I use StageWebView instead of HtmlContainer c) I use my own linkedin key and tokens.

I would appreciate it if someone can provide me with some pointers on how to troubleshoot this situation. Perhaps someone can tell me how to debug the app while running in the emulator (I think I need the correct adt command arguments for this which matches the 'Export Release Build' menu but adds the debug param?)

Thanks for your help in advance.

Comment Added:

I suspect that this has to do with connections to https:// api.linkedin.com and https:// www.linkedin.com. The only reason I can think of that the same code is not having issues inside of Flex Builder but indeed having issues in the Android emulator is something to do with certificates. Any ideas?

TOPICS
Development

Views

10.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 01, 2012 Jan 01, 2012

Copy link to clipboard

Copied

So far I have found that this is an IOErrorEvent #2032.  It only happens in the android emulator and not when running on the desktop in debug or release mode (through Flash Builder). Any ideas what this could be?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 02, 2012 Jan 02, 2012

Copy link to clipboard

Copied

OK - through some Fiddler profiling I am observing that the http tunnel created to api.linkedin.com:443 when debugging inside of FlashBuilder vs inside of the Android emulator is different.  Specifically, the following two lines of code create different HTTP headers:

var request:OAuthRequest = new OAuthRequest("GET", requestTokenUrl,  {oauth_callback:'http://www.xyz123.com'} , consumer, null);

loader.load(urlRequest);

While in Flashbuilder the URLLoader seems to create the request with proper headers like Host:api.linkedin.com:443,Content-Length:0,Connection:Keep-Alive, etc..., inside the Android Emulator there is only one header Host: 216.52.242.83:443.

Why on earth would this happen?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 05, 2012 Jan 05, 2012

Copy link to clipboard

Copied

It seems like 216.52.242.83 is the ip of the address api.linkedin.com. But I think this is the android emulator issue - not flex. You should try to debug this problem on a physical device (try ebay for a used one - they are really cheap, especially low-tier samsung phones ).

I had a similar issue with Dropbox API. I was also getting #2032 errors, but I have used www.charlesproxy.com to debug them (the communication is over https, isn't it same for linked in??)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 05, 2012 Jan 05, 2012

Copy link to clipboard

Copied

Thanks er453r,

I have created a project that clearly reproduces the bug.  Here are the steps:

1) Create a UrlLoader and point it to https://www.google.com (HTTPS is important because http works but HTTPS does not)

2) Load it

3) Run in Flash Builder 4.6/Air 3.1 and then run in Android emulator.  The former works with an http status 200.  The latter gives you an ioerror 2032.  I am assuming what works in Flash Builder is supposed to work in the Android Emulator and what what works in the emulator is supposed to work in a physical device (plus or minus boundary conditions).

I see a certificate exception in adb logcat but not sure if it's related...

Here is the self contained View code which works with a TabbedViewNavigatorApplication:

<?xml version="1.0" encoding="utf-8"?>

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"

                    xmlns:s="library://ns.adobe.com/flex/spark"

                    xmlns:mx="library://ns.adobe.com/flex/mx"

                    xmlns:ns1="*"

                    xmlns:local="*"

                    creationComplete="windowedapplication1_creationCompleteHandler(event) "

                    actionBarVisible="true" tabBarVisible="true">

          <fx:Script>

                    <![CDATA[

                              import mx.events.FlexEvent;

                              protected var requestTokenUrl:String = "https://www.google.com";

                              protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void

                              {

                                        var loader:URLLoader = new URLLoader();

                                        loader.addEventListener(ErrorEvent.ERROR, onError);

                                        loader.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError);

                                        loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);

                                        loader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, httpResponseStatusHandler);

                                        loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);

                                        var urlRequest:URLRequest = new URLRequest(requestTokenUrl);

                                        loader.load(urlRequest);

                              }

                              protected function requestTokenHandler(event:Event):void

                              {

                              }

                              protected function httpResponse(event:HTTPStatusEvent):void

                              {

                                        label.text += event.status;

                                        // TODO Auto-generated method stub

                              }

                              private function completeHandler(event:Event):void {

                                        label.text += event.toString();

                                        trace("completeHandler data: " + event.currentTarget.data);

                              }

                              private function openHandler(event:Event):void {

                                        label.text +=  event.toString();

                                        trace("openHandler: " + event);

                              }

                              private function onError(event:ErrorEvent):void {

                                        label.text +=  event.toString();

                                        trace("onError: " + event.type);

                              }

                              private function onAsyncError(event:AsyncErrorEvent):void {

                                        label.text += event.toString();

                                        trace("onAsyncError: " + event);

                              }

                              private function onNetStatus(event:NetStatusEvent):void {

                                        label.text += event.toString();

                                        trace("onNetStatus: " + event);

                              }

                              private function progressHandler(event:ProgressEvent):void {

                                        label.text += event.toString();

                                        trace("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);

                              }

                              private function securityErrorHandler(event:SecurityErrorEvent):void {

                                        label.text +=  event.toString();

                                        trace("securityErrorHandler: " + event);

                              }

                              private function httpStatusHandler(event:HTTPStatusEvent):void {

                                        label.text += event.toString();

                                        //label.text += event.responseHeaders.toString();

                                        trace("httpStatusHandler: " + event);

                              }

                              private function httpResponseStatusHandler(event:HTTPStatusEvent):void {

                                        label.text +=  event.toString();

                                        trace("httpStatusHandler: " + event);

                              }

                              private function ioErrorHandler(event:IOErrorEvent):void {

                                        label.text +=  event.toString();

                                        label.text += event.text;

                                        trace("ioErrorHandler: " + event);

                              }

                    ]]>

          </fx:Script>

          <fx:Declarations>

                    <!-- Place non-visual elements (e.g., services, value objects) here -->

          </fx:Declarations>

          <s:Label id="label" y="185" width="100%" color="#0A0909" horizontalCenter="0" text=""/>

</s:View>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 05, 2012 Jan 05, 2012

Copy link to clipboard

Copied

I've tested the code you provided in the "Doom" thread and it is interesting...

On my Galaxy Tab 10.1, Android 3.2 it works!

On my Nexus S, Android 4.03 it does not... #2032 error.

It only proves, that this is a platform specific bug, this code works.

UPDATE: I'm now 100% sure. My Nexus S does not load this url in the system browser (because of the ssl exception), the GTab does. Check if you can view this address in the emulators browser - this will close the topic, I hope.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 05, 2012 Jan 05, 2012

Copy link to clipboard

Copied

Er453r,

thanks for trying this out for me (I really appreciate it) - I have been indeed deploying this to an Android 4.X virtual device, and my experience matches your report.  I had also been testing an earlier version of this app on an Android 2.3.3 virtual device and it was not working there either (though I am having a hard time confirming that right now as the app is crashing in a 2.3.3 AVD).

I don't have an AVD set up for 3.2 and please excuse my ignorance - it's not available in my 'dropdown' and I don't know how to manually set this up yet - I have been on a steep learning pace here

However, in http://forums.adobe.com/message/3345972#3345972, there are some references to a similar bug being fixed a while back and then there are reports that it may have regressed.  Perhaps 3.2 coencides with that fix and then 4.X regressed???

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 06, 2012 Jan 06, 2012

Copy link to clipboard

Copied

I've got it running on my Nexus S. It seems it won't work over 3G (for some reason), but on WiFi it works I'm sure this is a device bug, not flex.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 06, 2012 Jan 06, 2012

Copy link to clipboard

Copied

I can successfully load https://www.google.com in the 2.2, 2.3.3 and 4.0 AVD browsers.  So, URLLoader is encountering some different problem - possibly the inability to deal with root certs or something.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 09, 2012 Jan 09, 2012

Copy link to clipboard

Copied

Hi All,

I am using Flash Builder 4.6/AIR 3.1.0. I am using RESTful web service to get XML results and to display on my mobile application. I am getting the same below error when accessing the webservice from mobile app (Android - Galaxy Tab 7 inch).

Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error # 2032"] URL: http://adfdevp.alshaya.com:7013/RESTEmployeeDetails-EmployeeDetails-context-root/jersey/restlabhttp://adfdevp.alshaya.com:7013/RESTEmployeeDetails-http://adfdevp.alshaya.com:7013/RESTEmployeeDetails-EmployeeDetails-context-root/jersey/restlabEmployeeDetails-context-root/jersey/restlab

The same code is working in Flash Builder 4.6. I have checked Network Monitor to "Disabled" before deploying to mobile. What am i doing wrong here? I am pasting my code below-

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
  xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView" xmlns:dao="dao.*"
  xmlns:mx="library://ns.adobe.com/flex/mx">

<fx:Script>
  <![CDATA[
   import mx.collections.ArrayCollection;
   import mx.collections.IList;
   import mx.collections.XMLListCollection;
   import mx.events.FlexEvent;
   import mx.rpc.events.FaultEvent;
   import mx.rpc.events.ResultEvent;
   import mx.rpc.xml.SimpleXMLDecoder;
   import mx.utils.ArrayUtil;
  
   import valueObjects.EmployeeDetail;
   [Bindable]
   private var myXml:XML;
  
   [Bindable]
   public var resultCollection:IList;
   public function handleXml(event:ResultEvent):void
   {
    var xmlListCollection:XMLListCollection = new XMLListCollection(event.result.children());
    var xmlListCollectionValues:XMLListCollection = new XMLListCollection(event.result.emp.children());
    var resultArray:Array = xmlListCollection.toArray();
    var resultArrayValues:Array = xmlListCollectionValues.toArray();
   
   
    var objEmployeeDetails:EmployeeDetail;
    var resultCollection:ArrayCollection = new ArrayCollection();
   
    var j:int = 0;
    for(var i:int=0;i<resultArray.length;i++){
    
     objEmployeeDetails = new EmployeeDetail();
     objEmployeeDetails.brand = resultArrayValues;
     objEmployeeDetails.division = resultArrayValues[j+1];
     objEmployeeDetails.email = resultArrayValues[j+2];
     objEmployeeDetails.employee_name = resultArrayValues[j+3];
     objEmployeeDetails.employee_number = resultArrayValues[j+4];
     objEmployeeDetails.grade = resultArrayValues[j+5];
     objEmployeeDetails.mobile = resultArrayValues[j+6];
     objEmployeeDetails.position = resultArrayValues[j+7];
    
     j = j + 8;
     resultCollection.addItem(objEmployeeDetails);
    
    }
    list.dataProvider = resultCollection;
    //return resultCollection;
   }
  
   public function handleFault(event:FaultEvent):void
   {
    //Alert.show(event.fault.faultDetail, "Error");             
   }
  
   protected function sesrchEmployee():void
   {
    xmlRpc.send();
   }

  
  ]]>
</fx:Script>


<fx:Declarations>
  <dao:EmployeeDAO id="srv"/>
 
  <mx:HTTPService id="xmlRpc"
      url="http://adfdevp.alshaya.com:7013/RESTEmployeeDetails-EmployeeDetails-context-root/jersey/restlab"
      result="handleXml(event)"
      fault="handleFault(event)"
      resultFormat="e4x" showBusyCursor="true">
   <mx:request xmlns="">
    <data>{key.text}</data>
    <data>{key1.text}</data>
   </mx:request>
  </mx:HTTPService>
 
 
</fx:Declarations>

<s:navigationContent/>

<s:titleContent>
  <s:VGroup width="100%">
  <s:HGroup width="100%">
   <s:Label top="40" paddingTop="10" paddingRight="13" height="29" text="Employee Name:"/>
   <s:TextInput id="key" width="559"/>
  </s:HGroup>
  <s:HGroup width="100%">
   <s:Label height="30" paddingTop="10" text="Employee Number:"/>
   <s:TextInput id="key1" width="100%"/>
  </s:HGroup>
 
  </s:VGroup>
</s:titleContent>

<s:actionContent>
  <s:Button icon="@Embed('assets/search.png')" click="sesrchEmployee()"/> 
</s:actionContent>

<s:List id="list" top="0" bottom="0" left="0" right="0" 
   change="navigator.pushView(EmployeeDetails, list.selectedItem)">
  <s:itemRenderer>
   <fx:Component>
    <s:IconItemRenderer label="{data.employee_name}"
         messageField="position">
    </s:IconItemRenderer>
   </fx:Component>
  </s:itemRenderer>
</s:List>

</s:View>

Appreciate your quick response in this regard.

Thanks,

Murtaza Ghodawala

Mobile: +965 97180549

murtaza.ghodawala@alshaya.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 09, 2012 Apr 09, 2012

Copy link to clipboard

Copied

@Murtaza: Just venturing a guess mate, as I'm not sure how similar HTTPService is to URLLoader in this regard, but when I was seeing a similar issue with URLLoader (works on desktop, breaks on mobile/AIR) it was due to a missing HTTPStatusEvent.HTTP_RESPONSE_STATUS event handler. Apparently the lack of that event-type-handler will cause a 2032 stream error on AIR.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 10, 2012 Apr 10, 2012

Copy link to clipboard

Copied

LATEST

I have noticed being unabe to access HTTPS services when debugging on device unless I enable network monitor. Could this be related?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines