Skip navigation
Currently Being Moderated

Build an App for Android not working.What is wrong?

Nov 16, 2013 4:45 PM

Hi!

 

I am trying to create an android app with this code that is suposed to show a video player from justin.tv but it is not showing nothing.If I use the code in a regular AS3 fla file it works but If I choose New - Air for Android it doesnt work.

 

flash.system.Security.allowDomain("*");

 

 

stage.scaleMode = flash.display.StageScaleMode.NO_SCALE;

stage.align = flash.display.StageAlign.TOP_LEFT;

 

 

 

 

var loader = new flash.display.Loader();

 

 

function loaded(e){

 

          addChild(loader);

 

          loader.content.api.play_live("HERE I ENTER MY CHANNEL NAME");

}

 

 

loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, loaded);

 

 

loader.load(new flash.net.URLRequest("http://www.justin.tv/widgets/live_api_player.swf?video_height=650&vide o_width=380&consumer_key=HERE I ENTER MY CONSUMER ID"));

 
Replies
  • Currently Being Moderated
    Nov 18, 2013 2:29 AM   in reply to TavaresEd

    Just to be sure:

     

    Are you aware that you have to substitute the underlined words with your credentials?

     

    loader.content.api.play_live("HERE I ENTER MY CHANNEL NAME");

    ...

    loader.load(new flash.net.URLRequest("http://www.justin.tv/widgets/live_api_player.swf?video_height=650&vide o_width=380&consumer_key=HERE_I_ENTER_MY_CONSUMER_ID"));

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 19, 2013 3:28 AM   in reply to TavaresEd

    Try to test the app first with a static video.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 20, 2013 4:12 AM   in reply to TavaresEd

    Might have sth. to do how the api handles details.

    You might get more helpo on specialized forum:

    http://community.justin.tv/forums/showthread.php?t=11304

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 20, 2013 4:25 AM   in reply to TavaresEd
     
    |
    Mark as:
  • Currently Being Moderated
    Nov 21, 2013 10:07 AM   in reply to TavaresEd

    What render mode are you using? You should set it to direct in your apps XML settings if you haven't:

     

    <renderMode>direct</renderMode>

     

    Try adding hardwareAccelerated to your <application> directive in the manifest in the same XML file (not sure what tech you're using to play the video):

     

    e.g.

    <manifestAdditions><![CDATA[

         <manifest android:installLocation="auto">

              <application android:hardwareAccelerated="true"/>

     

    Also add in:

     

    <containsVideo>true</containsVideo>

     

    before the </application> closing tag. This is typically just for stored app video, worth a quick check however.

     

    Of course give yourself permission to use the internet for the video:

     

    <uses-permission android:name="android.permission.INTERNET"/>

     

    See if any of that helps you. Do one thing at a time to see which works if it does so you know which are actually responsible for enabling it.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 21, 2013 12:56 PM   in reply to TavaresEd

    There's an issue right there, you should update to the latest version of AIR (3.9). You should also keep your Flash Player updated to 11.9 as well.

     

    AIR SDK download:

    http://www.adobe.com/devnet/air/air-sdk-download.html

     

    Flash Player download:

    http://www.adobe.com/support/flashplayer/downloads.html

     

    After that it should not remove those entries. Make sure you target AIR for Android 3.9.

     

    For now just updating AIR should do. If you're using CS6 or CC you should just need to unzip the folders contents (I put mine in my Flash folder) named AIR3.9 and then inside Flash go to Help->Manage AIR SDK->[ + ]->Browse to the location you unpacked your AIR files. Then Flash will allow you to target that AIR.

     

    managesdk.png

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 25, 2013 9:32 AM   in reply to TavaresEd

    The tag must be in the correct spot. For example here's an example using hardwareAccelerated and containsVideo along with internet, network state, phone state and writable storage:

     

    <android>

              <manifestAdditions><![CDATA[

                        <manifest android:installLocation="auto">

                                  <application android:hardwareAccelerated="true"/>

                                  <uses-permission android:name="android.permission.INTERNET"/>

                                  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

                                  <uses-permission android:name="android.permission.READ_PHONE_STATE"/>

                            <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

                            <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

                        </manifest>

              ]]></manifestAdditions>

              <containsVideo>true</containsVideo>

    </android>

     

    You probably have that tag inside the manifestAdditions which would give you that error.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 26, 2013 8:48 AM   in reply to TavaresEd

    I don't get this behavior in Flash Builder when I add that to my XML.

     

    To be clear, an example of what <application android:hardwareAccelerated="true"/> will do is things like allow video to be played inside a StageWebView. Otherwise you won't see it (albeit it doesn't work well at all on Android).

     

    To keep it in the mix you can always compile on the command line using ADT to avoid Flash Pro removing your XML settings. Here's some adt command line examples (this is just what Flash Pro is doing for you when you hit publish):

     

    http://help.adobe.com/en_US/air/build/WS901d38e593cd1bac1e63e3d128cdca 935b-8000.html

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 26, 2013 10:44 AM   in reply to TavaresEd

    If others have installed your app and say they see the video just fine I don't think this particular XML attribute is your issue.

     

    To answer you however, Flash will completely re-write your XML file every time you open the AIR publish settings. Anything it doesn't understand it has the habit of sticking strictly to the AIR XML Schema and is known to remove items it doesn't understand. This is why I use Flash Builder, it doesn't have this behavior but I must manually configure most of my XML file. In Flash Pro I used to be able to publish with extra settings after I edited the XML file using an external editor and published in flash with the shortcut (alt+shift+f12). The idea being, I know if I open the publish panel the XML will be re-written, so don't open it.

     

    The XML file is easy enough to configure yourself and with the ADT commands above you can compile without this hassle.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 26, 2013 12:24 PM   in reply to TavaresEd

    You just need to get the path to the adt which is in the AIR SDK you downloaded from above. The path to adt is AIRSDK/bin/adt. Once you know that you can easily compile.

     

    You open terminal (use spotlight to find it quick or it's just in your Applications folder). Add the full path to adt (unless you make it a global var in launchd.conf, that's another story), then the commands ADT needs to compile.

     

    In terminal, change directory (cd) to the path you're compiling in. It should contain your application SWF, .xml, icons etc etc. I'll call it MyProject for example (which makes MyProject.swf):

     

    cd /path/to/my/MyProject

     

    Then run adt on it:

     

    /Volumes/YOURVOLUME/Applications/Adobe Flash CS6/AIRSDK/bin/adt -package -target apk -storetype pkcs12 -keystore MyProjectCert.p12 MyProject.apk MyProject-app.xml MyProject.swf icons

    Any extra files or folders can be named at the end of the command, like I did by including the folder 'icons'. That simple command should prompt you for your certificates password and then compile MyProject.apk in the same folder. There's your app.

     

    Flash is just doing this for you but you can do more advanced things if you learn adt itself.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 26, 2013 1:07 PM   in reply to TavaresEd

    Did you place the .p12 cert in the same folder as everything else? It's merely telling you it cannot find your .p12 file. Make sure you set a path to it if it's not in the same folder and that you spelled the file name correctly.

     

    Just for ease, you can type a partial filename in terminal and then hit [TAB] to have the OS complete the filename for you. If you go to type MySigningCert.p12 and type "MySi" then hit [TAB] and it doesn't complete the filename then the file is not in the same folder.

     

    The password can be included in the command line but I kept it as easy as possible. If it finds your .p12 file successfully as soon as you hit enter to invoke the ADT command it will prompt you for your password.

     

    password:

    Make sure you type your certs password correctly as well.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 26, 2013 1:14 PM   in reply to TavaresEd

    Are you getting a prompt for a password? If so you're entering the password incorrectly. If not then it's not finding a valid .p12 file.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 26, 2013 1:49 PM   in reply to TavaresEd

    Well you've learned adt if nothing else. The rest really just comes down to the device and possibility it's Adobe has not matured enough to properly handle 4.3. I have enough issues with 4.2.x, that's about all I can think of at the moment. Perhaps a lightbulb will go off tomorrow.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 27, 2013 7:36 AM   in reply to TavaresEd

    I'd assume inside Flash you're embedding a captive runtime. Your app gets much smaller if you exclude it and have the user install Adobe AIR for Android from Google Play. It puts a dependency on the user but as you see, your apps do get much smaller .

     

    If you want to keep the captive runtime in there (self sufficient app) then change the -target apk to -target apk-captive-runtime.

     

    More ADT Android-specific commands here:

    http://help.adobe.com/en_US/air/build/WS901d38e593cd1bac-4f1413de12cd4 5ccc23-8000.html

     

    It's good to get used to ADT. There have been uncountable occasions I couldn't compile with Flash Pro (and even 1 time in Flash Builder) where command line compile completely fixed it. This is simply because the AIR SDK and Flash Player are updated far more frequently (which is a good thing) than the software that uses it. Using the SDK directly assures proper use of new features.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points