1 Reply Latest reply on Apr 7, 2014 10:00 AM by Jared Thigpen

    How do you include Android Assets in a Native Extension?

    Jared Thigpen

      I am building a native extension that uses the Assets folder to access a variety of different file types. I am attempting to get my assets added to the primary RhoRhunner application's assets folder, and am not having any luck. I tried copying them manually to both bin/tmp/assets and bin/RhoBundle and it doesn't work for a couple different reasons.


      1. Copying to tmp/assets doesn't work because it is deleted and recreated from RhoBundle after the native extension is compiled.

      2. Copying to Rhubundle doesn't work because the rake file copies specific folders and files out of RhuBundle and into the new temp/assets directory. So even if my asset files are present it ignores them.


      My next step is to modify my Android build Rake file to allow the copying of my assets into the assets folder, but this is not a long term solution as that rakefile is part of the framework and not something that can be placed in source control with our project.


      Is there some sort of hook as part of the native extension to accomplish this in a more supported manner that I have simply missed? And if not, is this planned in the future?





        • Re: How do you include Android Assets in a Native Extension?
          Jared Thigpen

          After looking through some of Rho's own native extensions and perusing their source and rake files, I have discovered a supported (but apparently not documented) way to accomplish this.


          In the ext.yml file under <Your extension>/ext add the following line under android: "adds: ext/platform/android/adds".


          The "adds" folder can be any folder name you wish, just update the line in ext.yml accordingly.


          Anything placed in the adds folder should follow the file structure you would expect in a standard android .apk (assets folder, libs folder, res folder, etc). Any files placed in any of these folders will be copied to the appropriate folder in the final APK.


          ***One word of caution: If you are using lib files, the Android build does not seem to play nice with multiple architectures. I had folders for armeabi, mips, x86 and all contents of all folders were copied to the armeabi folder in the final apk.


          Hope this helps someone in the future.