1 Reply Latest reply on Oct 22, 2013 1:00 PM by Josh_2013

    Android native extention errors

    frank_aq Level 1

      Hi Everyone,


      I'm currently working on creating an Android ANE for native alert popups. I'm now at the point where I think my both my Java and AS3 code is good to go but I'm getting an error when I try to use it.


      Main Thread (Suspended: TypeError: Error #1009: Cannot access a property or method of a null object reference.)


      My problem is I'm really not sure where this error is coming from. My thinking is that I'm not building the ANE file correctly or something is wrong in my extension.xml file but I'm really not too sure.


      I'm going to try to provide as much information as I can about how this project is set up. Right now I'm trying to use this ANE in a small, testing application.


      First, the folder setup:



           Alert_Java (holding my Java project)

                (Android/Java created assets. Not sure if these are important or now. If so I will list them)
















      I'm not going to bother posting my java code as I think it's correct. but if anyone who is willing to invest some time in helping me with this issue wants to take a look please let me know.


      This is my extensions.xml file


      <extension xmlns="http://ns.adobe.com/air/extension/2.5">
              <platform name="Android-ARM">


      And this is my Alert.as file:



      package {
          import flash.events.EventDispatcher;
          import flash.external.ExtensionContext;
          public class Alert extends EventDispatcher{
              public static var extContext:ExtensionContext = null
              public function Alert(){
                  extContext = ExtensionContext.createExtensionContext("com.fa.alerts", null);
              public static function androidAlert(aTitle:String, aMsg:String, aNeg:String = "Cancel", aPos:String = "Ok"):void{
                  extContext.call("showAlert", aTitle, aMsg, aNeg, aPos);



      And this is my stub app I'm using to test


      <?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">
                  protected function spawnAne(event:MouseEvent):void{
                      var a:Alert = new Alert();
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          <s:Button click="spawnAne(event)" />


      Now clicking on that button is what causes the error.


      I don't have any kind of swc or link between my testing app and the AS3 Alert_AS project. I'm using Flash Builder 4.6 to import the ANE file using the IDE tools.



      To build my ANE I'm using a lightly modified bash script from this post: http://gotoandlearn.com/play.php?id=149 by Lee Brimelow


          # path to YOUR Android SDK

          export AIR_ANDROID_SDK_HOME="my sdk"


          # path to the ADT tool in Flash Builder sdks

          ADT="my adt"


          # native project folder



          # AS lib folder



          # name of ANE file



          # JAR filename




          # cert path



          # cert password





          echo "****** preparing ANE package sources *******"


          rm ${ANE_NAME}

          rm -rf ./build/ane

          mkdir -p ./build/ane

          mkdir -p ./build/ane/Android-ARM

          mkdir -p ./build/ane/Android-ARM/res


          # copy resources

          cp -R ./${NATIVE_FOLDER}/res/* ./build/ane/Android-ARM/res


          # create the JAR file

          jar cf ./build/ane/Android-ARM/${JAR_NAME} -C ./${NATIVE_FOLDER}/bin .


          # grab the extension descriptor and SWC library

          cp ./${LIB_FOLDER}/src/extension.xml ./build/ane/

          cp ./${LIB_FOLDER}/bin/*.swc ./build/ane/

          unzip ./build/ane/*.swc -d ./build/ane

          mv ./build/ane/library.swf ./build/ane/Android-ARM



          echo "****** creating ANE package *******"


          "$ADT" -package -storetype PKCS12 -keystore ./cert.p12 -storepass password -tsa none \

              -target ane \

              ${ANE_NAME} \

              ./build/ane/extension.xml \

              -swc ./build/ane/*.swc \

              -platform Android-ARM \

              -C ./build/ane/Android-ARM/ .


          echo "****** ANE package created *******"



      I know this is a bit long but any help would be greatly appreciated! And feel free to let me know if you need some more elaboration