Why won't my apk build when I use the release flag?

If I do:

cocos compile -p android --android-studio

My app builds without problem.

If I do:

cocos compile -p android --android-studio -m release

I get the error:

*** No rule to make target /pathtomyproject/proj.android-studio/…/cocos2d/cocos/editor-support/cocostudio/CCActionFrame.cpp’, needed byobj/local/armeabi/objs/cocostudio_static/CCActionFrame.o’. Stop.

Why is this happening ? I am using cocos2d-x v 3.7
I already submitted my app to Google Play and its on sale. But now I am trying to build an update on a new machine (I don’t have access to the old machine anymore), and this error has appeared.

hi @chumbyfuzz

That’s because release mode make changes to ant.properties file.
which doesn’t seem to be present in proj.android-studio

not sure, but may be gradle doesn’t support ant or something.

I built my apk the same way when I submitted it to Google Play. I am working on my project after a gap of a couple of weeks, and trying to build an update on a new machine, so perhaps something in the environment is different. I don’t know what it could be though.

please check whether that ActionFrame.cpp is added in your Android.mk file

This is my Android.mk file:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d)
$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/external)
$(call import-add-path,$(LOCAL_PATH)/../../../cocos2d/cocos)

LOCAL_MODULE := cocos2dcpp_shared

LOCAL_MODULE_FILENAME := libcocos2dcpp

LOCAL_SRC_FILES := hellocpp/main.cpp \
                   ../../../Classes/AppDelegate.cpp \
                   ../../../Classes/JNIBridge.cpp \
                   ../../../Classes/HelloWorldScene.cpp

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../Classes

# _COCOS_HEADER_ANDROID_BEGIN
# _COCOS_HEADER_ANDROID_END


LOCAL_STATIC_LIBRARIES := cocos2dx_static

# _COCOS_LIB_ANDROID_BEGIN
# _COCOS_LIB_ANDROID_END

include $(BUILD_SHARED_LIBRARY)

$(call import-module,.)

# _COCOS_LIB_IMPORT_ANDROID_BEGIN
# _COCOS_LIB_IMPORT_ANDROID_END

I believe you are building your scene in Cocos Studio
Looking at your Android.mk file it seems that you have moved your classes folder one step inside.

Usually it is
/…/…/Classes

could you please verify this… ?

No - I am not using cocos studio. I am building from the terminal for android-studio, based on the instructions from this video:

http://www.sonarlearning.co.uk/questions.php?question-topic=300

Which was mentioned in this post:

It is supposed to be …/…/…/ because the android-studio project structure is different.

To further clarify - I have no problem with the debug build. It is only when I use the release flag:

cocos compile -p android --android-studio -m release

That i get the error. I am sure it is something very simple, but I cannot figure it out.

Does a fresh project work?

Yes. It seems to work. But why won’t my old project work ? How can I fix it ? It would be a lot of work to copy over all the files, etc…

well, I guess
some changes came into the game after you changed your old system.

The best way would be by comparing and checking.
I believe, all these are path issues.

The project may be containing old or absolute paths, thus seeking those path in your new system might be creating errors.

if paths are relative to the project root folder, there would not be any errors.