Cocos2d-x 2.x Android Libpng Vulnerability fix

If you receive the following error on Google Play Developer console:

Please migrate your app(s) to libpng v1.0.66, v.1.2.56, v.1.4.19, v1.5.26 or higher as soon as possible and increment the version number of the upgraded APK. Beginning Sep 17, 2016, Google Play will block publishing of any new apps or updates that use vulnerable versions of libpng. Your published app version will remain unaffected, however any updates to the app will be blocked unless they address this vulnerability.

https://support.google.com/faqs/answer/7011127

A simple fix is to extract the following zip file into your “cocos2dx\platform\third_party\android\prebuilt” folder:

Download the fix from here:
libpng_fix.zip for Cocos2d-x 2.x

And change “Android.mk” file under “cocos2dx” folder:

Change:
LOCAL_WHOLE_STATIC_LIBRARIES := cocos_libpng_static

to
LOCAL_WHOLE_STATIC_LIBRARIES := cocos_libzlib_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libpng_static

Change:
$(call import-module,libpng)

to:
$(call import-module,libzlib)
$(call import-module,libpng)

You are also invited to checkout our games and apps:
Bengigi Apps and Games

 
Add a comment

Comments (12)

  1. Pooja, June 17, 2016
    Did you try this ? Did this worked ? Reply
    • Obg1, June 19, 2016
      Should work, I got it to compile but didn't have time to run my app Reply
  2. Florian CHAUX, June 20, 2016
    It doesn't work for me : cocos2dx/platform/third_party/android/prebuilt/libpng/libs/armeabi/libpng.a(pngrutil.o):pngrutil.c:function png_inflate_claim: error: undefined reference to 'inflateReset2' cocos2dx/platform/third_party/android/prebuilt/libpng/libs/armeabi/libpng.a(pngrutil.o):pngrutil.c:function png_decompress_chunk.constprop.5: error: undefined reference to 'inflateReset2' It seems to be an incompatibility between zlib and libpng provided Reply
    • Obg1, June 21, 2016
      Please follow the instructions and add the zlib library Reply
  3. Ricardo, June 21, 2016
    I followed all instructions, including adding zlib. It compiled for x86, but failed for armeabi and armeabi-v7a. For both architectures the error was "undefined reference to 'inflateReset2'". Reply
  4. itzo, June 22, 2016
    Your libpng_fix does not work! I am using cocos2dx 2.1.5, NDK r8e. Android app compiles without errors, but when I extract the APK and run on device, app's graphics "go background" and do not display properly. I cannot publish this to Google Play to see if the warning would disappear, but clearly something is off! Note: Added libzlib as well and followed the instructions for the Android.mk file inside cocos2dx folder. Reply
  5. Cory Trese, June 27, 2016
    Where did these files come from? Can you share the build settings you use, or the original source? Did they come from a later cocos2d-x package? Reply
    • Obg1, June 27, 2016
      I copy the one usd in the latest Cocos2d-x version. It works with my game "Run Cow Run". No more png warning Reply
  6. Redzal, August 31, 2016
    Hi.... I dont have Android.mk inside the cocos2dx. but I have one in folder jni/ which is I set like this (see below) is it possible to do it like this? and I dont know how to check if this will solve my problem or not.. thanks in advance LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := player_shared LOCAL_MODULE_FILENAME := libplayer LOCAL_SRC_FILES := main.cpp LOCAL_WHOLE_STATIC_LIBRARIES := core_static cocos2dx_static box2d_static cocos_libzlib_static cocos_libpng_static GOOGLE_PLAY_STORE := true include $(BUILD_SHARED_LIBRARY) $(call import-module, box2D) $(call import-module, core) $(call import-module, cocos2dx) $(call import-module,libzlib) $(call import-module,libpng) Reply
    • Redzal, August 31, 2016
      Or am I supposed to create the Android.mk inside cocos2dx? Reply
  7. ihaa, September 6, 2016
    Hi I didn't found this folder “cocos2dx\platform\third_party\android\prebuilt” i put the fill in this folder android\bin\classes\org\cocos2dx is it working !! Reply
  8. lam, October 2, 2016
    how can solve this issue for project use cocos2dx 1.0.1-x-0.13.0 beta? i used your solution but it did not work Reply

Add a comment

Top
(it will not be shared)