Search code examples
androidcocos2d-x

Cocos2D-x HelloCpp for Android unable to build apk from Windows due to permission denied on asset file


I was trying to run cocos2dx HelloCpp sample project on Android, building from Windows-7 64 bit with Cygwin 64 bit, however, everytime I try to build and run, it complains that permission was denied on "Marker Felt.fnt" file in assets/font folder.

I checked that there's no permission on that file and chmod to give it proper permission, but everytime I try to run again, that file seems to be regenerated and has no permission again...

Does anyone has the same problem? I have been googling and the nearest problem I've found is this:

Cocos2dx Android: Get data from file(assets/*) failed

However, it is quite different. I've tried disabling UAC on my Windows machine, but the problem doesn't go away

Any help is highly appreciated


Solution

  • Check the proj.android/build_native.sh, every time you run the build, the entire assets/* folder will be re-created, and thus, your chmod is nullified.

    You can chmod after the copy process itself in the build_native.sh, place the chmod somewhere after cp the assets/*

    in my case, put

    chmod 777 -R "$APP_ANDROID_ROOT"/assets 
    

    after copying the assets folder in build_native.sh like this:

    if [ -f "$file" ]; then
        cp "$file" "$APP_ANDROID_ROOT"/assets
    fi
    
    chmod 777 -R "$APP_ANDROID_ROOT"/assets
    done