Search code examples
androidcocos2d-xcocos2d-x-3.0cocos2d-x-2.x

Can I refactor name libcocos2dcpp.so?


libcocos2dcpp.so is located at path proj.android\libs\armeabi

1) I want to learn to modify how it looks after changing the name "libcocos2dcpp.so" to some "randomname.so"

(Intention being, not sure but it might help in protecting my game's source code if people won't know in which thing it is made, I mean cpp because libcocos2dcpp.so has cpp in its end)

2) Also, is this libcocos2dcpp.so created newly every time I build my code or does it remains same through its entire life time?


Solution

  • You can change your lib name by using LOCAL_MODULE_FILENAME in the Android.mk file . According to ANDROID-MK document under Android-NDK folder:

    LOCAL_MODULE_FILENAME
        This variable is optional, and allows you to redefine the name of
        generated files. By default, module <foo> will always generate a
        static library named lib<foo>.a or a shared library named lib<foo>.so,
        which are standard Unix conventions.
    
        You can override this by defining LOCAL_MODULE_FILENAME, For example:
    
            LOCAL_MODULE := foo-version-1
            LOCAL_MODULE_FILENAME := libfoo
    
        NOTE: You should not put a path or file extension in your
        LOCAL_MODULE_FILENAME, these will be handled automatically by the
        build system.
    

    You can just rename your lib file name as

    LOCAL_MODULE := randomname
    LOCAL_MODULE_FILENAME := librandomname
    

    so the build system will automatically build the lib as librandomname.so.

    And don't forget to change the code in Android Activity:

    static {
        System.loadLibrary("randomname");
    }