[Solved] Android project build error

Hi folks, can someone explain why i cant build Android project?

All files exists at folders, but anyway error happens.

Used:

  • cocos2dx 3.6
  • NDK 10e
  • Ant 1.9.5

Here is Log:

Mac-mini-Aleksandr:proj.android camkadev$ cocos compile -p android
Running command: compile
Building mode: debug
Android platform not specified, searching a default one…
running: ‘/Volumes/ehddmac/Distrib/dev/android-sdk-macosx/tools/android update project -t android-16 -p /Volumes/ehddmac/YandexDisk/brr_ios/brr_client_cpp/proj.android’

Updated project.properties
Updated local.properties
Updated file /Volumes/ehddmac/YandexDisk/brr_ios/brr_client_cpp/proj.android/proguard-project.txt
Android platform not specified, searching a default one…
running: ‘/Volumes/ehddmac/Distrib/dev/android-sdk-macosx/tools/android update lib-project -p /Volumes/ehddmac/Distrib/dev/cocos2d-x-3.6/cocos/platform/android/java -t android-16’

Updated project.properties
Updated local.properties
Updated file /Volumes/ehddmac/Distrib/dev/cocos2d-x-3.6/cocos/platform/android/java/proguard-project.txt
building native
NDK build mode: debug
NDK_TOOLCHAIN_VERSION: 4.9
running: ‘/Volumes/ehddmac/Distrib/dev/android-ndk-r10e/ndk-build -C /Volumes/ehddmac/YandexDisk/brr_ios/brr_client_cpp/proj.android -j4 NDK_MODULE_PATH=/Volumes/ehddmac/Distrib/dev/cocos2d-x-3.6:/Volumes/ehddmac/Distrib/dev/cocos2d-x-3.6/cocos:/Volumes/ehddmac/Distrib/dev/cocos2d-x-3.6/external NDK_TOOLCHAIN_VERSION=4.9 NDK_DEBUG=1’

Android NDK: WARNING: APP_PLATFORM android-16 is larger than android:minSdkVersion 10 in ./AndroidManifest.xml
make: Entering directory /Volumes/ehddmac/YandexDisk/brr_ios/brr_client_cpp/proj.android' [armeabi] StaticLibrary : libcocos2d.a [armeabi] StaticLibrary : libcocostudio.a [armeabi] StaticLibrary : libcocosbuilder.a [armeabi] StaticLibrary : libcocos3d.a [armeabi] StaticLibrary : libspine.a [armeabi] StaticLibrary : libnetwork.a [armeabi] StaticLibrary : libaudioengine.a [armeabi] StaticLibrary : libui.a [armeabi] StaticLibrary : libcocosdenshion.a [armeabi] StaticLibrary : flatbuffers.a [armeabi] StaticLibrary : libextension.a [armeabi] StaticLibrary : libcocos2dxinternal.a [armeabi] StaticLibrary : libbox2d.a [armeabi] StaticLibrary : libcocos2dandroid.a [armeabi] StaticLibrary : libcpufeatures.a [armeabi] Gdbserver : [arm-linux-androideabi-4.9] libs/armeabi/gdbserver [armeabi] Gdbsetup : libs/armeabi/gdb.setup [armeabi] SharedLibrary : libcocos2dcpp.so [armeabi] Install : libcocos2dcpp.so => libs/armeabi/libcocos2dcpp.so make: Leaving directory /Volumes/ehddmac/YandexDisk/brr_ios/brr_client_cpp/proj.android’
building apk
running: ‘/opt/apache-ant/bin/ant clean debug -f /Volumes/ehddmac/YandexDisk/brr_ios/brr_client_cpp/proj.android/build.xml -Dsdk.dir=/Volumes/ehddmac/Distrib/dev/android-sdk-macosx’

Buildfile: /Volumes/ehddmac/YandexDisk/brr_ios/brr_client_cpp/proj.android/build.xml

-check-env:
[checkenv] Android SDK Tools Revision 24.3.3
[checkenv] Installed at /Volumes/ehddmac/Distrib/dev/android-sdk-macosx

-setup:
[echo] Project Name: BrrClient
[gettype] Project Type: Application

-pre-clean:

clean:

BUILD FAILED
/Volumes/ehddmac/Distrib/dev/android-sdk-macosx/tools/ant/build.xml:459: /Volumes/ehddmac/Distrib/dev/cocos2d-x-3.6/cocos/platform/android/java resolve to a path with no project.properties file for project /Volumes/ehddmac/YandexDisk/brr_ios/brr_client_cpp/proj.android

Total time: 0 seconds
Error running command, return code: 1
Mac-mini-Aleksandr:proj.android camkadev$

hi @camkadev

Could you cross-check whether you have a project.properties file inside your proj.android folder

check whether this line is there inside that file

android.library.reference.1=../cocos2d/cocos/platform/android/java

If you do not have this add.
If you do not have project.properties file then copy it from the the templates folder inside cocos2d-x SDK and place it in your project, clean and run again.

It should work.

Happy Coding :smile:

hi thanks for reply.
project file is inside proj.android folder and it is contains full path to cocos

android.library.reference.1=/Volumes/ehddmac/Distrib/dev/cocos2d-x-3.6/cocos/platform/android/java

Now, is your problem solved ?
or it is still there ?

no it is not solved.

i think it is something wrong with my Android.mk

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)
$(call import-add-path,/Volumes/ehddmac/Distrib/dev/cocos2d-x-3.6/)
$(call import-add-path,/Volumes/ehddmac/Distrib/dev/cocos2d-x-3.6/external)
$(call import-add-path,/Volumes/ehddmac/Distrib/dev/cocos2d-x-3.6/cocos)

LOCAL_MODULE := cocos2dcpp_shared

LOCAL_MODULE_FILENAME := libcocos2dcpp

CC_LITE_SRC_FILES := \
        /opt/protobuf/src/google/protobuf/stubs/common.cc                              \
        /opt/protobuf/src/google/protobuf/stubs/once.cc                                \
        /opt/protobuf/src/google/protobuf/stubs/strutil.cc                                \
        /opt/protobuf/src/google/protobuf/stubs/status.cc                                \
        /opt/protobuf/src/google/protobuf/stubs/stringpiece.cc                                \
        /opt/protobuf/src/google/protobuf/stubs/stringprintf.cc                                \
        /opt/protobuf/src/google/protobuf/stubs/int128.cc                                \
        /opt/protobuf/src/google/protobuf/stubs/structurally_valid.cc                                \
        /opt/protobuf/src/google/protobuf/extension_set.cc                             \
        /opt/protobuf/src/google/protobuf/generated_message_util.cc                    \
        /opt/protobuf/src/google/protobuf/message_lite.cc                              \
        /opt/protobuf/src/google/protobuf/repeated_field.cc                            \
        /opt/protobuf/src/google/protobuf/arenastring.cc                            \
        /opt/protobuf/src/google/protobuf/arena.cc                            \
        /opt/protobuf/src/google/protobuf/wire_format_lite.cc                          \
        /opt/protobuf/src/google/protobuf/io/coded_stream.cc                           \
        /opt/protobuf/src/google/protobuf/io/zero_copy_stream.cc                       \
        /opt/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc

LOCAL_CFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI

FILE_LIST = $(wildcard $(LOCAL_PATH)/../../Classes/*.c*) 
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/*/*.c*) 
FILE_LIST += $(wildcard $(LOCAL_PATH)/../../Classes/*/*/*.c*) 

LOCAL_SRC_FILES := brrcpp/main.cpp \
                   $(FILE_LIST:$(LOCAL_PATH)/%=%) \
                   $(CC_LITE_SRC_FILES)

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \
                   $(LOCAL_PATH)/../../Classes/Dialog \
                   $(LOCAL_PATH)/../../Classes/Libs \
                   $(LOCAL_PATH)/../../Classes/MessageSerializer \
                   $(LOCAL_PATH)/../../Classes/Network \
                   $(LOCAL_PATH)/../../Classes/ProtoMessages \
                   /opt/protobuf/src

# _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 solved it by copying cocos2d folder from new created project and changed the path to cocos as you suggest.

i do not understand why it worked, what is different.

did you know what happens?

There is answer… in proj.android folder project.properties file contains wrong reference to cocos:

/Volumes/ehddmac/Distrib/dev/cocos2d-x-3.6/cocos/platform/android/java

in my case usually it is:
android.library.reference.1=…/cocos2d/cocos/platform/android/java

but you probably using prebuilts libraries and this line not needed?

** mm didnt noticed there is already answers for your post :slight_smile:
I would recommend you to use symlinks for cocos2d folder instead of changing all the time config files.

symlinks doesn’t work well for windows pc
it works well with linux and mac os but not with windows trust me… :smile:`

Symlinks works ok on Windows if it’s not virtual machine. Optionally can be using submodules thru git.

some experiments gives me solution, looks like i understand what is wrong, build scripts does not like Absolute path for cocos2d, i changed it to relative and then compilation completed good.

I had the same issue. Changed to relative path and it works. Thanks!