Android compile error - return code: 2

When i compile project for android i get this error-

make: *** No rule to make target `jni/../../../Classes/HelloWorldScene.cpp', needed by `obj/local/armeabi/objs-    debug/cocos2dcpp_shared/__/__/__/Classes/HelloWorldScene.o'.  Stop.
make: *** Waiting for unfinished jobs....
make: Leaving directory `/Users/mihir/Desktop/finaltest/proj.android'
Error running command, return code: 2.

i compile like this -

cocos compile -p android

i am using cocos2d-x 3.8.1

How to debug or solve this error?

And now i am getting -

make: *** No rule to make target jni/../../../Classes/HelloWorldScene.cpp', needed byobj/local/armeabi/objs-debug/cocos2dcpp_shared////Classes/HelloWorldScene.oā€™. Stop.
make: *** Waiting for unfinished jobsā€¦
[armeabi] Compile++ thumb: cocos2dcpp_shared <= AppDelegate.cpp
jni/ā€¦/ā€¦/ā€¦/Classes/AppDelegate.cpp: In member function ā€˜virtual bool AppDelegate::applicationDidFinishLaunching()ā€™:
jni/ā€¦/ā€¦/ā€¦/Classes/AppDelegate.cpp:22:18: error: ā€˜createā€™ is not a member of ā€˜cocos2d::GLViewā€™
glview = GLView::create(ā€œMy Gameā€);
^
At global scope:
cc1plus: warning: unrecognized command line option ā€œ-Wno-extern-c-compatā€
cc1plus: warning: unrecognized command line option ā€œ-Wno-extern-c-compatā€
make: *** [obj/local/armeabi/objs-debug/cocos2dcpp_shared/
///Classes/AppDelegate.o] Error 1
make: Leaving directory `/Users/mihir/Desktop/finaltest/proj.androidā€™
Error running command, return code: 2.

And my android.mk file is - 

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

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

I added ā€¦/ as mentioned here - Android Compile Error return code 2

Please helpā€¦

Is your file still named HelloWorldScene.cpp?

Yesā€¦ :stuck_out_tongue_winking_eye: , but other files are named as required.

Do we need to add all the cpp files here? I already did, just in case but got the same error.

How to solve this error?

@mihir77 Try this, it will automatically include all your classes files. No need to edit your Android.mk all the time

LOCAL_PATH := $(call my-dir)
CLASSES_PATH := $(LOCAL_PATH)/../../Classes

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 \
					$(subst $(LOCAL_PATH)/,,$(wildcard $(CLASSES_PATH)/*/*.cpp)) \
					$(subst $(LOCAL_PATH)/,,$(wildcard $(CLASSES_PATH)/*.cpp)) \

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

Thanks manā€¦forgot to reply then as got busy into testingā€¦ :wink:

Hi, I am getting this error, using NDK r9d:

5 errors generated.
make: *** [obj/local/armeabi/objs-debug/cocos2dcpp_shared/__/__/Classes/AppDelegate.o] Error 1
make: Leaving directory `/Users/itzo/Documents/Android_Apps/DiamondSlots/DiamondSlot1.2/TEST/proj.android'
Traceback (most recent call last):
  File "./build_native.py", line 159, in <module>
    build(opts.ndk_build_param,opts.android_platform,opts.build_mode)
  File "./build_native.py", line 146, in build
    do_build(cocos_root, ndk_root, app_android_root,ndk_build_param,sdk_root,android_platform,build_mode)
  File "./build_native.py", line 82, in do_build
    raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!")
Exception: Build dynamic library for project [ /Users/itzo/Documents/Android_Apps/DiamondSlots/DiamondSlot1.2/TEST/proj.android ] fails!

Please advice!

where this android.mk file is located.
i found more then 1 android.mk file
please reply as soon as possible

@jdboss if youā€™re using Eclipse itā€™s inside proj.android/jni, otherwise for Android Studio itā€™s inside proj.android-studio/app/jni

I have tried sdk tool 26.0.2 and 25.0.0 ndk r10e r14b r15b and literally every new version of cocos apache ant 10 but this is the error message i get every time! Please help me! I am new to cocos