[SOLVED] Replace executable JS code on the fly (on Runtime)

Im building a cross platform Cocos2d-x project that uses JSB.

So I would like to Improve the Development cycle time by only replacing the Executable JS (main.js) file and then restarting the App. Instead of Repackaging and installing the App on the Emulator/Device each time i make a JS code change.

Have you tried loading updated JS files “on the fly” without re-installing the whole Cocos2dx App on your device?

(also added the same Question on Stack Overflow here: http://stackoverflow.com/questions/21383682/cocos2dx-replace-executable-js-code-on-the-fly-on-runtime)

On-The-Fly Code/Resource Replacing

Purpose

To reduce testing cycle time while developing Android Applications

Facts

  • Android APK Assets/Resources cannot be replaced (requires repack)
  • ADB allows files to be pushed to the device (to any location)

Solution

  • Package the Native Code only as An Application
  • Load the Resources separately into an Accessible folder (on the device using ADB)

Technical

  • Android app package must include assets folder without the JS scripts (and potentially without the Resources)
  • Use ADB to manually Load/Copy the Resources onto the device: adb push main.js /data/user/0/your.android.package.name/files/main.js
  • Ensure the AppDelegate.cpp has the included searchPaths added to the CCFileUtils:

searchPath.push_back("/data/user/0/your.android.package.name/files");
// set searching path(s) - which are iterated through to find any file
CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath);