2

I'm using Adobe Flash Professional CS5.5 with ANE Distriqt Compass, I've created a simple .fla project and written a few lines of AS3 script. The compilation was successful, but when I executed the .swf file on my PC, at the beginning it always says

"The native extension context could not be created"

I thought the problem is caused by my PC's lack of magnetometer, but when I packaged my code into a .apk file and installed it on my Android device, it said the same thing. After checking through the code, I found out that Compass.init never executes successfully.

Here is my project, can someone tell me what causes the problem?
I tried to...

  • Extract the file com.distriqt.Compass.ane as .zip file.

  • Then linked the file distriqt.extension.compass.default.swc
    under META-INF/ANE/default directory.

I also tried the solution from this link, but that doesn't work either. I've searched through the Google inside-out, but it seems to be have no solution.

VC.One
  • 14,790
  • 4
  • 25
  • 57
Cro
  • 338
  • 4
  • 18

1 Answers1

2

That error indicates you aren't correctly packaging the ANE with your application.

With CS5.5 you'll need to package your application from the command line in order to correctly package ANEs. CS5.5 didn't include the ability to package applications using ANEs.

Firstly make sure you have added the extension ID to your application descriptor:

<extensions>
    <extension>com.distriqt.Compass</extension>
</extensions>

To add the extension:

  • Change the filename extension of the ANE file from .ane to .swc. This step is necessary so that Flash Professional can find the file
  • Select File > ActionScript Settings on your FLA file
  • Select the Library Path tab in the Advanced ActionScript 3.0 Settings dialog box
  • Select the Browse To SWC File button
  • Browse to the SWC file and select Open. The SWC file now appears in the Library Path tab in the Advanced ActionScript 3.0 Settings dialog box
  • With the SWC file selected, select the button Select Linkage Options For A Library (this looks like a small i in a circle above the panel).
  • In the Library Path Item Options dialog box, change the Link Type to External.

Next you’ll need to open up a command line in the directory of your built application. The directory should contain:

  • application swf: myApp.swf
  • application descriptor: myApp-app.xml
  • any required files such as icons, Default.png
  • the ANE(s) (in a subdirectory we’ll assume extensionsDir in the following)

The details on this command is dependent on the application you are developing and the platform you are targeting. You should review the documentation at the following url to determine the details of what the command should contain for your environment.

http://help.adobe.com/en_US/air/build/WS597e5dadb9cc1e0253f7d2fc1311b491071-8000.html

For example the following command will create an APK for Android:

adt -package
    -target apk
    -storetype pkcs12 -keystore YOUR_SIGNING_KEY.p12
    myApp.apk
    myApp-app.xml
    myApp.swf icons
    -extdir extensionsDir

For more information see the tutorial here: https://airnativeextensions.com/knowledgebase/tutorial/1

Michael
  • 3,776
  • 1
  • 16
  • 27
  • Okay, I tried to use ADT to package up my Android app, but the error ''Unable to load a certificate in this file" appears, here's my packaging.bat : adt -package -target apk -storetype pkcs12 -keystore cro.p12 -storepass [P12_FILE_PASSWORD] camera_air_accelerometer_and_compass.apk camera_air-app.xml camera_air.swf -extdir C:\Users\Administrator\Documents\air – Cro Feb 05 '17 at 06:55
  • I used another machine and ran the packaging again. This time, the .p12 file passed through it, but there's another error : "An implementation for native extension "com.distriqt.Compass" required by the application was not found for the target platform.". – Cro Feb 05 '17 at 08:32
  • Are you sure the com.distriqt.Compass.ane file is in your extdir? – Michael Feb 05 '17 at 09:37
  • Wait, .ane file but not renamed .swc file? – Cro Feb 05 '17 at 09:39
  • No.. You need to rename the ANE and use it in flash to get your swf building. But you need to package with the ane – Michael Feb 05 '17 at 09:40
  • Now , the following error appears:"Included native extension 'com.distriqt.Compass' specifies namespace ......4.0, which is greater than the application namespace ......3.0" – Cro Feb 05 '17 at 09:43
  • Ah I suggest you use a more recent version of AIR. Version 24 is available currently.. – Michael Feb 05 '17 at 10:19
  • Do I need to upgrade other applications such as Flash Builder or Flash Professional? The .swf file is generated from Flash Professional's GUI instead of pure ActionScript. – Cro Feb 05 '17 at 10:22
  • You just need to upgrade the AIR SDK you are using. – Michael Feb 05 '17 at 10:24
  • When I'm answering you, I just upgraded my Air SDK Compiler to latest version, but the same thing happened. – Cro Feb 05 '17 at 10:26
  • Did you change the version in the namespace of your application descriptor? – Michael Feb 05 '17 at 10:30
  • Yes, I did. Currently it's 4.0. – Cro Feb 05 '17 at 10:31
  • Did you upgrade to air 24 though? – Michael Feb 05 '17 at 10:54
  • Yes, I did. I'm using Air 24 currently. But the .swf file is generated by Air from a older version. – Cro Feb 05 '17 at 10:56
  • You should use the same version in your application descriptor then I.e. 24 not 4 – Michael Feb 05 '17 at 10:59
  • Upgraded to the latest version. Everything happened the same way. After I finished dinner I'll start a new, completely same project and tell you how it goes. – Cro Feb 05 '17 at 11:22
  • Finally, everything worked after starting a brand new Android project and use the previous script and settings! Thanx for today's hard work! – Cro Feb 05 '17 at 15:04