Anthony D. Anthony D. - 2 months ago 17
Bash Question

Adobe AIR: Error #3500

I'm currently making a "Hello, World!" Native Extension for Adobe AIR with FlashDevelop. My Native Extension is thus meant to be used by Windows-x86 platforms, which I'm programming on.

I've built the ANE via a (custom) batch file. The test AIR Application which uses that ANE compiles fine, but, like so many other people I've seen the posts of, I'm getting

Error #3500: The extension context does not have a method with the name helloWorld.


I've been trying to understand what was going on for three days now, and, despite fixing several causes, I'm still getting the same error.

It seems the application runtime never actually gets to call the
initializeExtension
function, since DebugView doesn't trace anything, even though my initializer uses
OutputDebugString(L"Extension initialized");
.

I feel a bit bad for posting a lot of code, but after three days and dozens of webpages read, I'm just not sure where my problem is coming from.

Anyway, application building is done in 3 steps :

1) Building the DLL in Visual Studio with the Release flag. I'm posting that code as a response to Michael's comment below, however, I'm not sure the error is coming from there.

My native side is mainly made up of a header and a C++ file :

// -------------------------
// | NativeExtensionTest.h |
// -------------------------

#pragma once

#include "FlashRuntimeExtensions.h"

#ifdef __cplusplus
EXTERN_C
{
#endif

__declspec(dllexport) void initializeExtension(
void** dataToSet,
FREContextInitializer* contextInitializer,
FREContextFinalizer* contextFinalizer
);


__declspec(dllexport) void finalizeExtension(
void* extData
);


__declspec(dllexport) void initializeContext(
void* contextData,
const uint8_t* contextType,
FREContext context,
uint32_t* nFunctionsToSet,
const FRENamedFunction** functionsToSet
);


__declspec(dllexport) void finalizeContext(
FREContext context
);


__declspec(dllexport) FREObject helloWorld(
FREContext context,
void* functionData,
uint32_t argc,
FREObject argv[]
);

#ifdef __cplusplus
}
#endif


And here is the implementation of the functions:

// ------------------
// | HelloWorld.cpp |
// ------------------

#pragma once

#include "stdafx.h" // precompiled header ; includes cstdlib, cstring and windows.h
#include "FlashRuntimeExtensions.h"
#include "NativeExtensionTest.h"


using namespace std;


void initializeExtension(
void** dataToSet,
FREContextInitializer* contextInitializer,
FREContextFinalizer* contextFinalizer
)
{
dataToSet = NULL;
*contextInitializer = &initializeContext;
*contextFinalizer = &finalizeExtension;
}



void finalizeExtension(
void* extData
)
{ }



void initializeContext(
void* contextData,
const uint8_t* contextType,
FREContext context,
uint32_t* nFunctionsToSet,
const FRENamedFunction** functionsToSet
)
{
*nFunctionsToSet = 1;
FRENamedFunction* functions = (FRENamedFunction*)malloc(sizeof(FRENamedFunction)* (*nFunctionsToSet));

functions[0].name = (const uint8_t*)"helloWorld";
functions[0].function = &helloWorld;
functions[0].functionData = NULL;

*functionsToSet = functions;
}


void finalizeContext(
FREContext context
)
{ }


FREObject helloWorld(
FREContext context,
void* functionData,
uint32_t argc,
FREObject argv[]
)
{
char* hello = "Hello, World!";
unsigned int helloLength = strlen(hello) + 1;
FREObject ret;

FRENewObjectFromUTF8(helloLength, (const uint8_t*)hello, &ret);

return ret;
}


As alebianco requested, here is the build log when building the DLL. Note that I have an error at the very end of the log, at the end of the execution of a custom build batch file. I don't know where this error is coming from ; I didn't have that error last time I built that project. Besides, it's probably internal to FlashDevelop.

2) Building the ANE. I'm using a batch file to run the following commands:

To build the SWC, I invoke compc. After variable expansion, it looks like this:

compc -include-sources"C:\Users\Anthony Dentinger\Desktop\Native Extension Test\src" -output "C:\Users\Anthony Dentinger\Desktop\Native Extension Test\ANE Build Files\NativeExtHelloWorld.swc" -load-config "C:\Users\Anthony Dentinger\AppData\Local\FlashDevelop\Apps\flexsdk\4.6.0\frameworks\air-config.xml" -swf-version 14


My
src
folder contains a simple class:

package
{
import flash.events.EventDispatcher;
import flash.external.ExtensionContext;


public class NativeExtHelloWorld extends EventDispatcher {

private var extContext:ExtensionContext;

public function NativeExtHelloWorld()
{
extContext = ExtensionContext.createExtensionContext("NativeExtHelloWorld", "helloWorldContext");
}

public function helloWorld() : String
{
return String(extContext.call("helloWorld"));
}

}

}


In turn, after copying both the DLL from my Visual Studio folder and
library.swf
(which I extract from the SWC) to
ANE Build Files\platforms\Windows-x86
, I build the ANE with adt. After variable expansion, the command looks like this:

call adt -package -target ane "C:\Users\Anthony Dentinger\Desktop\Native Extension Test\ANE Build Files\HelloExtension.ane" "C:\Users\Anthony Dentinger\Desktop\Native Extension Test\ANE Build Files\descriptor.xml" -swc "C:\Users\Anthony Dentinger\Desktop\Native Extension Test\ANE Build Files\NativeExtHelloWorld.swc" -platform "Windows-x86" -C "C:\Users\Anthony Dentinger\Desktop\Native Extension Test\ANE Build Files\platforms\Windows-x86" .


Here is the extension descriptor that I provide adt:

<?xml version="1.0" encoding="utf-8"?>
<extension xmlns="http://ns.adobe.com/air/extension/3.1">

<id>NativeExtHelloWorld</id> <!--I'll later change that ID to something like com.example.myExt.HelloWorld-->
<name>Exension Name</name>
<description>Description of the Extension</description>
<versionNumber>0.0.1</versionNumber>
<copyright>© 2010, Examples, Inc. All rights reserved.</copyright>

<platforms>
<platform name="Windows-x86">
<applicationDeployment>
<nativeLibrary>HelloWorld.dll</nativeLibrary>
<initializer>initializeExtension</initializer>
<finalizer>finalizeExtension</finalizer>
</applicationDeployment>
</platform>
</platforms>

</extension>


3) Building the actual application. I'm using the default batch files made by FlashDevelop (with two modifications to include the ANE) for building AIR AS3 Projectors.

Note that, if I'm getting error #3500, it means (I suppose) that my application has successfully included my class from the ANE, since the constructor is working.

This is the application descriptor I'm using, in case that's helpful.

<?xml version="1.0" encoding="utf-8" ?>
<application xmlns="http://ns.adobe.com/air/application/15.0">

<id>TEST</id>
<versionNumber>1.0</versionNumber>
<filename>TEST</filename>
<name>TEST</name>

<initialWindow>
<title>TEST</title>
<content>TEST.swf</content>
<systemChrome>standard</systemChrome>
<transparent>false</transparent>
<visible>true</visible>
<minimizable>true</minimizable>
<maximizable>true</maximizable>
<resizable>true</resizable>
</initialWindow>

<supportedProfiles>extendedDesktop</supportedProfiles>

<extensions>
<extensionID>NativeExtHelloWorld</extensionID>
</extensions>
</application>


I'm using Flex (4.6.0) merged with the AIR SDK (22.0.0).

Have I done something wrong? What will help me fix this issue?

Once again, I'm sorry I posted quite a bit of code ; I've tried trimming down to what was most relevant.

Thanks in advance!

Answer

I've somehow solved the problem, and everything works now. I tried going back to see what I was doing wrong, but I can't quite figure it out. My guess is one of the batch files that copies and unzips the ANE was using the wrong target, so I ended up using the same old ANE, rather than using the ANE I was building (silly me).

Following Colonize.bat's request, here is a working Hello, World! example. I used VisualStudio 2013 and FlashDevelop to make this.

You can find several Error #3500 causes in the following files:

  • 1_Build_DLL/Hello World/main.cpp
  • 2_Build_ANE/lib/descriptor.xml
  • 2_Build_ANE/src/HelloWorldExtension.as

Causes of some other errors I've read about (or encountered!) as also indicated in other files. In fact, the custom batch files indicate the procedure to follow in order to make and use your own ANE.

NOTE : Don't try to build directly from these files. I'm using batch files in order not to have to run commands and copy/paste/unzip files by hand, so the targets and environment variables will not be valid on your computer.