3 Replies Latest reply on Apr 8, 2013 10:35 AM by Kevin Sherrill

    How to use R.resource in Java from ANE?

    HungryCatMari Level 1

      Hello,everyone,sorry for my poor English..

      I want to ask "What is the appropriate way to manage resource in ANE"??


      I have exported jar-library,and made ANE then called from Air Mobile.

      (I check include-resource-option when I export from eclipse.)

      When I debug on device,it seems that the Java's R.resource is overrided by R.resource air made.


      Forexample,I have added FREFunction returns resource-value.

      If I refer and display string.app_name,It shows string.app_name of Air-Project's.

      After I added string.test to resouce in Java,and display it in Air,there is no value.


      What is the appropriate way to manage resource in ANE.






      public class Native_xxxxxxx implements FREFunction {


          private Resources res;


          public FREObject call(FREContext arg0, FREObject[] arg1) {


              try {


                  Activity activity = arg0.getActivity();


                  res = activity.getResources();


                  return FREObject.newObject(res.getString(arg0.getResourceId("string.app_name ")));


                  //return FREObject.newObject(res.getString(arg0.getResourceId("string.test"))) ;


                  //return FREObject.newObject(res.getString(R.string.test));


              } catch ( Exception ex ) {



              return null;





        • 1. Re: How to use R.resource in Java from ANE?
          HungryCatMari Level 1

          I have realized one thing,

          after unzip .jar,it contains res-folder,

          but after unzip .ane it doesn't contains res-folder.


          I guess,It means adt command fails to include res folder.


          my command:

          adt -package -target ane ANExxx.ane ane.xml -swc ANExxx.swc -platform Android-ARM library.swf res Nativexxx.jar -platform default library.swf Nativexxx.jar

          • 3. Re: How to use R.resource in Java from ANE?
            Kevin Sherrill

            I don't think its a bug with AIR 3.5. I'm using FB 4.7 and the latest Eclipse for the native side and AIR 3.6 overlaid onto Apache Flex 4.9.1. I've created my .ane and my test app runs fine until I request a native side resource. I've unpacked the .ane and it all looks good - my resources are there. I'm making correct calls through context.getResourceId().


            Turns out I wasn't stepping back far enough. I next unpacked my apk, and low and behold, when FB packages it up it strips apart the .ane, throws away its resources, and bundles in new ones.


            Next step is to find out why. Going to see if Flash Pro CS6 builds bad apk's as well. If so, I suppose I'll try and find docs on adt and aapt and see if I can build batch files to build the apk's myself. Also need to clean my path of any adobe folders, and add the ones I need in the batch files to insure I'm not accessing stuff from an older SDK somewhere. And I'll also check against other SDK's - perhaps my overlay isn't working out like I'd first thought.