Android Studio: Native build fails after and upgrade

Android Studio: Native build fails after and upgrade
0

Hi all. I just foolishly upgraded Android Studio and gradle, and now I cannot build my game. The error message is:

Build command failed.
Error while executing process /home/pfedor/Android/Sdk/ndk-bundle/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/home/pfedor/hervor/Hervor/proj.android/app/jni/Android.mk NDK_APPLICATION_MK=/home/pfedor/hervor/Hervor/proj.android/app/jni/Application.mk APP_ABI=armeabi-v7a NDK_ALL_ABIS=armeabi-v7a NDK_DEBUG=1 APP_PLATFORM=android-16 NDK_OUT=/home/pfedor/hervor/Hervor/proj.android/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/home/pfedor/hervor/Hervor/proj.android/app/build/intermediates/ndkBuild/debug/lib NDK_TOOLCHAIN_VERSION=clang -j8 NDK_MODULE_PATH=/home/pfedor/hervor/Hervor/cocos2d:/home/pfedor/hervor/Hervor/cocos2d/cocos:/home/pfedor/hervor/Hervor/cocos2d/external NDK_DEBUG=1 MyGame}

make: *** No rule to make target `MyGame'.  Stop.

My Android.mk file (which worked perfectly before the upgrade):

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := MyGame_shared

LOCAL_MODULE_FILENAME := libMyGame

FILE_LIST := $(wildcard $(LOCAL_PATH)/../../../../source/*.cc)
SHAPES_CODEGEN := $(wildcard $(LOCAL_PATH)/../../../../shapes/codegen/*.cc)
LOCAL_SRC_FILES := $(LOCAL_PATH)/hellocpp/main.cpp \
                   $(LOCAL_PATH)/../../../Classes/AppDelegate.cpp \
                   $(LOCAL_PATH)/../../../Classes/HelloWorldScene.cpp \
                   $(FILE_LIST:$(LOCAL_PATH)/%=%) \
                   $(SHAPES_CODEGEN:$(LOCAL_PATH)/%=%)

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

# _COCOS_HEADER_ANDROID_BEGIN
# _COCOS_HEADER_ANDROID_END


LOCAL_STATIC_LIBRARIES := cc_static

# _COCOS_LIB_ANDROID_BEGIN
# _COCOS_LIB_ANDROID_END

include $(BUILD_SHARED_LIBRARY)

$(call import-module, cocos)

# _COCOS_LIB_IMPORT_ANDROID_BEGIN
# _COCOS_LIB_IMPORT_ANDROID_END

(in /proj.android/gradle.properties, I’m setting PROP_BUILD_TYPE=ndk-build)

The project is based off of the default cocos2d-x template. My Android Studio version now is 3.5, Android Gradle Plugin version 3.5.0, Gradle version 5.4.1.

I realize the way go to about it is going to be a lot of poking and trial and error, but posting this in the hope that someone has had the same problem. Thank you!

Aleksander

1 Like

From experience, that error is almost expected every time we upgrade Android Studio. First thing to try is to do a clean, then go into the proj.android folder, and manually delete all the generated build files. You can easily tell which ones they are if you compare it to a newly generated project.

If the error persists, enable more verbose output from the gradle build process, and it should help you track down the cause of the error.

I also tried updating Android Studio 3.5.
I tried to build the project cleanly,
The build will fail just like you.

I don’t want to spend time on this issue, so I’ll uninstall 3.5.
Download and install 3.4 from the archive.

I’m expirienced same troubles. Swithing to cmake instead of ndk-build solved compiling error. But yes, ndk-build dont work anymore after last android studio upgrade.

1 Like

No need downgrade android studio itself. Temporary solution is downgrade gradle plugin to 5.1.1

Go to build.gradle on your proj.android-studio (or proj.android) find line

dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'

and change it to

dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'

then go to gradle/wrapper find line

distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

and change it to

distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

Sync project and try build again.

8 Likes

Thanks, fix works great.

Thanks @CAPONE It’s worked for me.

I only now got the chance to try it out and I want to join in with the thanks–@CAPONE it worked for me too thank you!

you can just mark my reply as solution

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.