Null values when using R.* Mechanism for Android ANE (AIR 4.0.0.1240)
So I wanted to try out the new AIR 4.0 implementation of requesting resources in android native extensions using R.* instead of getResourceId. When stepping through the native extension code, anytime the R.* is being used in the native android code it returns an id for the resource, but the resource comes back as null everytime. I assume it is because the resource id is not correct for some reason. I do not know if I am doing something wrong or not. When unpackaging the apk, I could see that the resources are being included correctly in the right folder.
I had to make sure when I exported my jar file from my android project that I did not include the res or gen folders. The gen folder contained the R.java file that is auto-built in the android project, and when packaging the apk would throw an error saying the R.class was already added. So removing the gen folder fixed that.
Here is how I packaged my ANE
extension.xml:
<extension xmlns="http://ns.adobe.com/air/extension/4.0">
<id>com.example.anesample</id>
<versionNumber>1</versionNumber>
<platforms>
<platform name="Android-ARM">
<applicationDeployment>
<nativeLibrary>anesample.jar</nativeLibrary>
<initializer>com.example.aneexample.NativeExtensionSample</initializer>
<finalizer>com.example.aneexample.NativeExtensionSample</finalizer>
</applicationDeployment>
</platform>
</platforms>
</extension>
platform.xml:
<platform xmlns="http://ns.adobe.com/air/extension/4.0">
<packagedResources>
<packagedResource>
<packageName>com.example.anesample</packageName>
<folderName>Android-Resources</folderName>
</packagedResource>
</packagedResources>
</platform>
ane build command:
adt -package -target ane NativeExtensionSample.ane extension.xml -swc NativeExtensionSample.swc -platform Android-ARM -platformoptions platform.xml Android-Resources -C Android .
Folder stucture:
extension.xml
platform.xml
NativeExtensionSample.swc
Android
|__anesample.jar
library.swf
Android-Resources
|__values
layout
drawable
etc.
(rest of the resources from the android project res folder)
Note: I do have other ANE's included in the app that are built with older versions of AIR and do not use the new R.* mechanism. I was wondering if that would cause issues or not as well. (I will be doing tests soon that exclude these ane's)
