Android Air App using AdMob "NULL Object" Error?!?

Hi,
I am currently developing an app using adobe air flashbuilder and I have incorporated AdMob type html adverts into it. The Adverts do come up nicely however if I run the app in debug mode I get this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at model::AdMob/createAd()[C:\Users\Jack\Documents\Dropbox\Projects\App\App Final\src\model\AdMob.as:37]
The Ads do still work regardless of this however this is then affecting other elements within the app so I would like to get rid of the error that is happening. Below is my code in the "AdMob.as" file where I believe the issue to be occuring, can someone please help me with this?
package model
    import flash.display.Stage;
    import flash.events.Event;
    import flash.events.LocationChangeEvent;
    import flash.events.MouseEvent;
    import flash.geom.Rectangle;
    import flash.media.StageWebView;
    import flash.net.URLRequest;
    import flash.net.navigateToURL;
    public class AdMob
        // setup variables
        private var _stageWebView:StageWebView;
        private var myAdvertURL:String = "http://www.test.co.uk/AdMob/test.html";
        //private var myAdvertURL:String;
        private var adWidth:Number=480;
        private var adHeight:Number=85;
        private var stage:Stage;
        public function AdMob(adURL:String,_stage:Stage)
            myAdvertURL=adURL;
            stage=_stage;
            createAd();
        public function createAd():void {
            // check that _stageWebView doersn't exist
            if (! _stageWebView) {
                _stageWebView = new StageWebView () ;
                // set the size of the html 'window'
                _stageWebView.viewPort = new Rectangle(0,stage.stageHeight-adHeight, 800, adHeight);
                //_stageWebView.viewPort = new Rectangle((stage.stageWidth-adWidth)/2,stage.stageHeight-adHeight,adWidth,adHeight);
                // add a listener for when the content of the StageWebView changes
                _stageWebView.addEventListener(LocationChangeEvent.LOCATION_CHANGE,onLocationChange);
                //add a listener for when the ad is loaded
                _stageWebView.addEventListener(Event.COMPLETE,onComplete);
                // start loading the URL;
                _stageWebView.loadURL(myAdvertURL);
            // show the ad by setting it's stage property;
            //showAd();
        public function destroyAd():void {
            // check that the instace of StageWebView exists
            if (_stageWebView) {
                trace("removing advert");
                // destroys the ad
                _stageWebView.stage = null;
                _stageWebView = null;
        public function toggleAd():void {
            trace("toggling advert",_stageWebView);
            // check that StageWebView instance exists
            if (_stageWebView) {
                trace("_stageWebView.stage:"+_stageWebView.stage);
                if (_stageWebView.stage == null) {
                    //show the ad by setting the stage parameter
                    _stageWebView.stage = stage;
                } else {
                    // hide the ad by nulling the stage parameter
                    _stageWebView.stage = null;
            } else {
                // ad StageWebView doesn't exist - show create it
                createAd();
        public function onLocationChange(event:LocationChangeEvent):void {
            // check that it's not our ad URL loading
            if (_stageWebView.location != myAdvertURL) {
                // destroy the ad as the user has kindly clicked on my ad
                destroyAd();
                // Launch a normal browser window with the captured  URL;
                navigateToURL( new URLRequest( event.location ) );
        public function onComplete(event:Event):void{
            //add the ad when it is loaded. If not it will apear a white rectangle until the load is complete.
            showAd();
        public function updateAd(adURL:String=null):void{
            if (adURL!=null){
                myAdvertURL = adURL;
            destroyAd();
            createAd();
        public function showAd():void{
            if (_stageWebView)
                _stageWebView.stage = stage;
        public function hideAd():void{
            if (_stageWebView)
                _stageWebView.stage = null;

@zhenya1919 - since you're currently going through this, could you please open a new bug report on this over at https://bugbase.adobe.com?  When adding the bug, please include some sample code or a sample application so we can quickly test this out internally.  If you'd like to keep this private, feel free to email the attachment to me directly ([email protected]). 
Once added, please post back with the URL so that others effected can add their comments and votes.
Thanks,
Chris

Similar Messages

  • AIR app :: Channel.Call.Failed faultString:'error' faultDetail:'NetConnection.Call.Failed:

    I have built an AIR app using ColdFusion 8.01 as the backend.  I am getting this error occasionally on Remote Object calls. My suspicion is that the Channel being used by the RemoteObject is timing out.  I'm not bothering to configure the Channel separately, I'm just going with the default that is part of the RemoteObject.
    I'm using Cairngorm, with a ServiceLocator and my thought is that I could separately define my channel from the RemoteObject declaration and listen for timeout events on the Channel and refresh the Channel if it times out. 
    I'd be really interested in anyone's feedback on this issue.
    Jeff

    Hi,
    Can you please try tracing the FaultEvent.fault.rootCause
    object and see if there is any error message. Usually exceptions
    thrown from the server is available in this rootCause object.
    Hope this helps.

  • Needed. Android Air app to watch live FMS video stream.

    Does anyone have an Android Air app that can be used to watch a live video stream from Flash Media Server?
    I've been trying to get our live stream viewable on Android devices and can't find any solutions.
    Thanks,
    Dave

    Hey, I am having the same issue.  Did you find a solution?

  • Can I update my Android AIR app with a non-AIR app?

    A few years ago I published an Android app using Adobe AIR. Now I've created a new version of the app with a different technology (HaxeFlixel / OpenFL) which uses native C++ code.
    The certificate I used for the AIR version is in "p12" format, and it seems that I need to use "jks" format. I tried using a p12 to jks converter I found online, which seemed to work, but when I try to submit the app I get an error saying that the certificates don't match.
    Any suggestions on how I can update the app with a non-AIR app? Is it possible? Thanks in advance.

    I'm still having trouble with this, I asked in the OpenFL forums but nobody responded.
    I converted the p12 file to JKS from the site you suggested (I think I've actually tried it before), and the file was created successfully, the apk compiled fine with the JKS file, but when I try to update the app for Google Play it says "Upload failed
    You uploaded an APK that is signed with a different certificate to your previous APKs. You must use the same certificate. Your existing APKs are signed with the certificate(s) with fingerprint(s):"
    When I try to sign with the original p12 file, I get the error "Invalid keystore format"
    I noticed that for the AIR app, I also had a file called SelfSigned.pfx, which I think was used to create the p12 certificate? Can this have something to do with the problem? I even tried using this pfx file to sign the app, which didn't work either.

  • How to read http cookies from adobe desktop Air app using flex/flash builder in AS 3.0 ??

    Im developing Adobe desktop air app where i need to read the session id from the cookie of a http request.
    I have found a property called URLRequest.manageCookies supported by AIR so i Hope there should be a way to read the cookies as well. Im Using Flash Builder 4.5
    Please provide any reference code or guide me for this research;
    searched a lot regarding on this web.
    Most results lead to local shared object or reading cookies fr a webpage using javascript and ExternalInterface.
    I want to read http cookies not Local shared Object and in a desktop AIR application.
    Im using Flash builder 4.5
    Thanks
    Hari

    Sorry, but you are at the wrong forum; this one is only for discussions on the forums themselves. The Air forums are here:
    http://forums.adobe.com/community/air

  • Displaying PDF content in Android Air app - how?

    Hi, I'm fairly new to developing Air apps for mobile devices. I'm looking to have my app display PDF files and can't find a dfinitive way of doing it. I've read that using the StageWebView would be the way to do it.
    Here's the relevant part of my code (PDF path changed):
    if (StageWebView.isSupported)
    currentState = "normal";
    webView.stage = stage;
    webView.viewPort = new Rectangle(20, 100, 450, 450);
    webView.addEventListener(LocationChangeEvent.LOCATION_CHANGE,onURLChange);
    webView.loadURL("http://path.to.my.pdf");
    addEventListener(ViewNavigatorEvent.REMOVING,onRemove);
    else {
    currentState = "unsupported";
    lblSupport.text = "StageWebView feature not supported";
    Its working up until the point of actually displaying the PDF content, I get nothing (blank screen).
    I'm using Flash Builder 4.5 / Air 2.6 and debugging on a Motorola Xoom tablet. Adobe Reader is installed on the device.
    Any help with this would be greatly appreciated.

    Solved.
    For some reason I couldn't access the HTMLLoader object outside of the function that initialised it, despite the fact that I was listening for EVENT_COMPLETE.
    Basically, to get round this bug, just put all the initialise and load code in the same function and you should be laughing.

  • 3D Android Air Apps

    Hi everyone I am currently part of a group of students which is creating an Android Air Application.
    We have been doing pretty well so far (we are creating a game which is a periscope simulator) but getting 3d models in the app has been a bit troubling.
    We have been using 3dsMax for the models and using Swift3D in order to convert the file to swf. We then rendered the ship and exported to .swf and then added it to the project in flashbuilder and then used SWFLoader to add it to the app. When we use the emulator the ship which we rendered appears perfectly but when we create the apk and put it on our phone (HTC EVO 4G) the only thing that appears is an old school image not able to be shown image.
    First off we have been doing lots of research on what we could do with the 3d models and everyone has told us that we have to convert them to an .swf in order get in the 3d model because their is no other way to get it in. Is this true or do we really have to use swift3d? Others have suggested that we use some of flashes game engines but would any of these even be compatible with adobe air?
    All we really need to do is import the 3d model then be able to randomly generate its location on the screen as well as its viewing angle. Our application is never actually moving its just providing a still image which is randomly chosen from the 360 degree view of the ship.
    If anyone has any advice we would really appreciate it. At this point we are not really sure what we should do.

    I've not tried any Swift3D but have run some Papervision3D stuff in AIR on Android.  Seems fairly happy but I'm only pushing around simple planes (card game) so the load isn't particularly heavy - more complex models might start to grind it.   Seems to benefit well from GPU acceleration so keep that in mind.  From your description though it sounds as though you're not going to be rendering high fps, which is the real killer, so this may be perfect for your app.
    On PV3D against Alternativa, (broad statement warning) I think it's generally agreed that PV3D is fast, Alternativa is more precise.  PV3D being optimised for speed may be key on Android devices - depends what you're trying to do, but with PV3D you will probably sacrifice some more accurate z-sorting that Alternativa can provide.  Personally I'd test both to see pros and cons - it's going to be on a case by case basis.
    If you've got a more recent version of Swift3D, I believe you can export to a PV3D scene quickly and easily with no knowledge of that engine.  Think it's one of the publish options (v6+ ?).  So presumably you can run a PV3D test on your app with little effort and you can take it from there.  If it's all z-fighting issues on your models, give it a go with Alternativa.
    hth

  • AIR apps using Stratus - protecting developer key

    How do we deploy an AIR app that uses Stratus and protect our developer key, since AIR is not encrypted?

    Except that the "somehow" is really not going to happen, because the code can be decompiled, and Adobe has not provided any way to keep some protected data on the client side OR even uniquely identify a particular instance of an AIR app. Unless I am wrong and someone can explain how...

  • Flash CC - Publish iOS/Android AIR App stuck at 5 seconds

    I have a few Flash made apps, I've published them to my devices before, but now I can't. Flash get's stuck at 5 seconds. Flash freezes, I can't cancel.
    Any suggestions?

    I would recommend to use "Captive".
    Difference is pretty simple...
    Shared Basically means that it compiles the "apk" without the Adobe AIR runtime, resulting in a smaller file size apk but REQUIRES users to have the "Adobe AIR App" installed.
    Captive means that it compiles the "apk" with the Adobe AIR runtime, resulting in a larger file size apk but DOES NOT REQUIRE users to have the "Adobe AIR App" installed.
    If you want to Guarantee everyone can run your app, use captive. If you want to rely on users to hope the have the correct version of AIR installed to view your app, use Shared.

  • Iphone apps using flex remote objects with CF???

    I am used to making web applications that use flex remote objects to interact with CF.
    Is it possible to use remoting from an iphone app cross compiled using flash builder to interact with Cf remoting on a remote server?

    Interseting, config files always seem to me like a strange way to do things.
    I'm not exactly sure what you mean by this, but by default, that's how remoting works in Flex - you have channels and destinations defined on your server, and your compiler points to your config files and reads those values. So it's a little extra work to define them in AS instead.
    Can you give me any tips on authenticating requests to cfc's from mobiles and how to protect my servers once I exposes cfc's to apps not hosted on the same server as CF?
    There isn't really anything mobile-specific you need to do here. Exposing CFCs isn't any different than exposing CFM files that are accessed via a browser. You can use the standard CF session management and CF authentication (cflogin) - there are some examples available by Googling "coldfusion cflogin flex remoting".
    Dave Watts, CTO, Fig Leaf Software

  • Installing Adobe AIR Apps using Microsoft SMS

    I am a developer working on an AIR application which will be
    pushed out using Microsoft's SMS. According to Adobe's "AIR Admin
    Guide" documentation, it is possible to "Silently install the Adobe
    AIR runtime using tools such as Microsoft SMS, IBM Tivoli, or any
    deployment tool that allows silent installations that use a
    bootstrapper". The IT admin overseeing the installation says that
    he has examined SMS 2003 and SES 2007 and there are only options
    for MSI’s and EXE. How can .AIR applications be pushed out
    for installation through SMS?
    Thanks!

    Via an .exe that we provide when you sign for a
    redistribution license. (The license is free but required for this
    scenario.) See
    http://www.adobe.com/products/air/runtime_distribution1.html

  • How to use GooglePlayServices libs in Native Extension of Android AIR app?

    I am trying to use some features of Google Play Services lib but I could not make it work. I have added the reference to the google play service libs to the manifest file (from Flash Builder)
    <application android:enabled="true">
    <meta-data  android:name="com.google.android.gms.version"
                    android:value="@integer/google_play_services_version" />
    <activity android:excludeFromRecents="false">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    </application>
    In my ANE, I have added the reference to the source of google-play-services_lib, but when I tried to call the FREFunction to check the availability of Google Play Service
    @Override
    public FREObject call(FREContext context, FREObject[] args){
         boolean result = false;
         try{
          Activity activitiy = context.getActivity();
          activityContext = activitiy.getBaseContext();
              result = isGooglePlayServiceExists();
         }catch(IllegalStateException e){
          Log.e(AneUtils.TAG, "Failed to get AIR current activity", e);
         FREObject obj = null;
        try{
            obj = FREObject.newObject(result);
        }catch(FREWrongThreadException e){
            Log.e(AneUtils.TAG, "Failed to create FREObject from [" + result + "]");
        return obj;
    private boolean isGooglePlayServiceExists(Context activityContext){
        int googlePlayServicesCheck = -1;
        try{
            googlePlayServicesCheck = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activityContext);
        }catch(Exception e){
            Log.e(AneUtils.TAG, "Error getting googlePlayService state",e);
        if(googlePlayServicesCheck == ConnectionResult.SUCCESS){
             return true;
        return false;
    The ANE crashed at the line GooglePlayServicesUtil.isGooglePlayServicesAvailable(activityContext) so I really doubted the Google Play Service libs was not added.
    Has anyone successfully imported the Google Play Serivce libs into Adobe AIR Android app?
    Any advice or help will be appreciated. Thank you.

    hey sshk5,
    I have managed to make it work. The solution is quite simple, i will explain the steps below
    1. Download the latest Android SDK from ADT (including the latest version of GooglePlay lib)
    2. Check the version number of Google Play lib ( for example 412312....) something and in your FlashBuilder project, make sure you use the  exact number like
    <meta-data  android:name="com.google.android.gms.version" android:value="412312" />
    3. Use tool to merge the googlelib jar file with your native extension before importing the native extension to FlashBuilder. If you do not want to use any other tool, you can use the AIR 4.0 which will allow you to use commandline to merge jars (and even dependency resources)
    Hope it helps

  • Android AIR App Random Error #2032: Stream Error (HTTPStatusEvent = 0)

    Hello
    I am investigating an issue with failed requests and it's been difficult to narrow it down. When I put the URL into a browser I get a valid / expected response. However when I try to access the same URL using Actionscript 3 on my Android Devices (Nexus S and Xoom), I get stream error #2032 at random.
    I am using URLRequest with a custom RequestListener class:
    var loader:URLLoader = new URLLoader();                 
    if(action == "zip") loader.dataFormat = URLLoaderDataFormat.BINARY;
    var listener:RequestListener = new RequestListener(action, loader, endFunction, extra);
    loader.addEventListener(Event.COMPLETE, listener.requestSuccessful);
    loader.addEventListener(IOErrorEvent.IO_ERROR, listener.requestFailed);
    loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHTTPStatusChange);
    var req:URLRequest = new URLRequest(Global.apiURL);
    req.method = URLRequestMethod.POST;
    req.data = new URLVariables(paramString);
    loader.load(req);
    return loader;
    Note that it works on one of my routers but not the access point:
    onHTTPStatusChange: 0
    requestFailed: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: { ... }" errorID=2032]
    Since it works on one router but not the other, I can't say that it's an issue with the app, phone, or our request URL.
    Note that I am using SSL / https.
    Is it a timeout issue?? This is really frustrating.
    Thanks.

    @zhenya1919 - since you're currently going through this, could you please open a new bug report on this over at https://bugbase.adobe.com?  When adding the bug, please include some sample code or a sample application so we can quickly test this out internally.  If you'd like to keep this private, feel free to email the attachment to me directly ([email protected]). 
    Once added, please post back with the URL so that others effected can add their comments and votes.
    Thanks,
    Chris

  • Android AIR app stops unexpectedly during debugging/running on device

    FlashBuilder 4.5.1, AIR 2.6, device: HTC Wildfire S. The problem occurs everytime I try run a mobile app- just the Android error view. Please help

    Hi,
    go first here and do check-list:
    http://help.adobe.com/en_US/air/build/WS144092a96ffef7cc16ddeea2126bb46b82f-8000.html
    it lists supported/non-supported/check-at-runtime features - as you could use a feature that is not supported at your device (application could work in Air/Flash Builder device emulator though)
    What is happening in your application when it starts? Does it load video/audio or does request to local or remote content?
    regards,
    Peter

  • Is there any sample Android Native App using MBOs?

    We are building a native android application using MBOs (SUP 2.1 ESD#2).
    We are able to register the user but not able to synchronize. We are following the "Developer Guide: Android Object API Applications"
    Is there any sample android native application for this scenario?  Only sample available now uses OData SDK.
    Thank you
    Regards
    Jeyaram

    Transaction examples for IIOP are in the works for the next release.
    "Dan Cimpoesu" <[email protected]> wrote:
    Hi,
    Based on the links below:
    http://e-docs.bea.com/wls/docs61/jta/trxrmi.html#1018506
    http://e-docs.bea.com/wls/docs61/jta/gstrx.html#1067532
    It appears that is possible to have distributed transactions across RMI-IIOP
    clients and RMI-IIOP applications (servers).
    I am surprised by the note:
    Note: These code fragments do not derive from any of the sample applications
    that ship with WebLogic Server. They merely illustrate the use of the
    UserTransaction object within an RMI application.
    The above note suggests that there is no sample code available.
    Is there any sample code that illustrates RMI-IIOP applications (servers)
    participating in distributed transactions?
    Regards,
    Dan Cimpoesu

Maybe you are looking for