Error on Android compile

Error on Android compile
0.0 0

#1

hello there,

I created a cocos project, when I try to compile it with android studio I get the error :
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':Tribs:externalNativeBuildDebug'.
> Build command failed.
  Error while executing process D:\Cocos_install\android-ndk-r15c\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=D:\git\Madjoh\clash_front\frameworks\runtime-src\proj.android-studio\app\jni\Android.mk NDK_APPLICATION_MK=D:\git\Madjoh\clash_front\frameworks\runtime-src\proj.android-studio\app\jni\Application.mk APP_ABI=armeabi NDK_ALL_ABIS=armeabi NDK_DEBUG=1 APP_PLATFORM=android-16 NDK_OUT=D:/git/Madjoh/clash_front/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=D:\git\Madjoh\clash_front\frameworks\runtime-src\proj.android-studio\app\build\intermediates\ndkBuild\debug\lib NDK_TOOLCHAIN_VERSION=4.9 APP_PLATFORM=android-16 -j8 NDK_DEBUG=1 D:/git/Madjoh/clash_front/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/debug/obj/local/armeabi/libcocos2djs.so}
  Android NDK: WARNING: Unsupported source file extensions in D:\git\Madjoh\clash_front\frameworks\runtime-src\proj.android-studio\app\jni\Android.mk for module cocos2djs_shared    
  Android NDK:   ../../../Classes/PluginFacebookJS.hpp ../../../Classes/PluginFacebookJSHelper.h ../../../Classes/SDKBoxJSHelper.h ../../../Classes/PluginGoogleAnalyticsJS.hpp ../../../Classes/PluginSdkboxAdsJS.hpp ../../../Classes/PluginSdkboxAdsJSHelper.h ../../../Classes/PluginChartboostJS.hpp ../../../Classes/PluginChartboostJSHelper.h    
  [armeabi] Compile++ arm  : cocos2d_js_static <= jsb_cocos2dx_physics3d_auto.cpp
  [armeabi] Compile++ arm  : cocos2d_js_static <= cocos2d_specifics.cpp
  [armeabi] Compile++ arm  : cocos2d_js_static <= jsb_event_dispatcher_manual.cpp
  [armeabi] Compile++ arm  : cocos2d_js_static <= js_module_register.cpp
  [armeabi] Compile++ arm  : cocos2d_js_static <= CCComponentJS.cpp
  [armeabi] Compile++ arm  : cocos2d_js_static <= jsb_cocos2dx_3d_manual.cpp
  [armeabi] Compile++ arm  : cocos2d_js_static <= jsb_cocos2dx_experimental_video_manual.cpp
  [armeabi] Compile++ arm  : cocos2d_js_static <= jsb_cocos2dx_experimental_webView_manual.cpp
  In file included from D:/git/Madjoh/clash_front/frameworks/runtime-src/proj.android-studio/app/jni/../../../../cocos2d-x/cocos/scripting/js-bindings/proj.android/../../../../external/bullet/prebuilt/android/../../include/bullet/btBulletCollisionCommon.h:22:0,
                   from D:/git/Madjoh/clash_front/frameworks/runtime-src/proj.android-studio/app/jni/../../../../cocos2d-x/cocos/3d/../physics3d/CCPhysics3D.h:54,
                   from D:/git/Madjoh/clash_front/frameworks/runtime-src/proj.android-studio/app/jni/../../../../cocos2d-x/cocos/scripting/js-bindings/proj.android/../manual/cocos2d_specifics.cpp:5331:
  D:/git/Madjoh/clash_front/frameworks/runtime-src/proj.android-studio/app/jni/../../../../cocos2d-x/cocos/scripting/js-bindings/proj.android/../../../../external/bullet/prebuilt/android/../../include/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.h:83:35: fatal error: btCollisionDispatcher.h: No such file or directory
   #include "btCollisionDispatcher.h"
                                     ^
  compilation terminated.
  make: *** [D:/git/Madjoh/clash_front/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/debug/obj/local/armeabi/objs-debug/cocos2d_js_static/__/manual/cocos2d_specifics.o] Error 1
  make: *** Waiting for unfinished jobs....
  In file included from D:/git/Madjoh/clash_front/frameworks/runtime-src/proj.android-studio/app/jni/../../../../cocos2d-x/cocos/scripting/js-bindings/proj.android/../../../../external/bullet/prebuilt/android/../../include/bullet/btBulletCollisionCommon.h:22:0,
                   from D:/git/Madjoh/clash_front/frameworks/runtime-src/proj.android-studio/app/jni/../../../../cocos2d-x/cocos/3d/../physics3d/CCPhysics3D.h:54,
                   from D:/git/Madjoh/clash_front/frameworks/runtime-src/proj.android-studio/app/jni/../../../../cocos2d-x/cocos/scripting/js-bindings/proj.android/../auto/jsb_cocos2dx_physics3d_auto.cpp:4:
  D:/git/Madjoh/clash_front/frameworks/runtime-src/proj.android-studio/app/jni/../../../../cocos2d-x/cocos/scripting/js-bindings/proj.android/../../../../external/bullet/prebuilt/android/../../include/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.h:83:35: fatal error: btCollisionDispatcher.h: No such file or directory
   #include "btCollisionDispatcher.h"
                                     ^
  compilation terminated.
  make: *** [D:/git/Madjoh/clash_front/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/debug/obj/local/armeabi/objs-debug/cocos2d_js_static/__/auto/jsb_cocos2dx_physics3d_auto.o] Error 1

my app/build.gradle :

import org.apache.tools.ant.taskdefs.condition.Os

apply plugin: 'com.android.application'

android {
    compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId "com.madjoh.tribs.io"
        minSdkVersion PROP_MIN_SDK_VERSION
        targetSdkVersion PROP_TARGET_SDK_VERSION
        versionCode 1
        versionName "1.0"

        externalNativeBuild {
            ndkBuild {
                if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) {
                    // skip the NDK Build step if PROP_NDK_MODE is none
                    targets 'cocos2djs'
                    arguments 'NDK_TOOLCHAIN_VERSION=4.9'
                    arguments 'APP_PLATFORM=android-'+PROP_APP_PLATFORM
                    arguments '-j' + Runtime.runtime.availableProcessors()
                    abiFilters.addAll(PROP_APP_ABI.split(':').collect{it as String})
                }
            }
        }
    }

    sourceSets.main {
        java.srcDir "src"
        res.srcDir "res"
        jniLibs.srcDir "libs"
        manifest.srcFile "AndroidManifest.xml"
    }

    externalNativeBuild {
        ndkBuild {
            if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) {
                // skip the NDK Build step if PROP_NDK_MODE is none
                path "jni/Android.mk"
            }
        }
    }

    signingConfigs {

       release {
            if (project.hasProperty("RELEASE_STORE_FILE")) {
                storeFile file(RELEASE_STORE_FILE)
                storePassword RELEASE_STORE_PASSWORD
                keyAlias RELEASE_KEY_ALIAS
                keyPassword RELEASE_KEY_PASSWORD
            }
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            if (project.hasProperty("RELEASE_STORE_FILE")) {
                signingConfig signingConfigs.release
            }

            externalNativeBuild {
                ndkBuild {
                    arguments 'NDK_DEBUG=0'
                }
            }
        }

        debug {
            externalNativeBuild {
                ndkBuild {
                    arguments 'NDK_DEBUG=1'
                }
            }
        }
    }
}

def getCocosCommandPath() {
    if (Os.isFamily(Os.FAMILY_WINDOWS)) {
        return 'cocos.bat'
    }
    else {
        // on unix like system, can not get environments variables easily
        // so run a shell script to get environment variable sets by cocos2d-x setup.py
        new ByteArrayOutputStream().withStream { os ->
            def result = exec {
                executable = project.file('get_environment.sh')
                standardOutput = os
            }
            ext.console_path = os.toString().trim()
        }
        return new File(console_path + '/cocos').absolutePath;
    }
}


// a method used to invoke the cocos jscompile command
def compileJS(srcDir, dstDir) {
    def compileArgs = ['jscompile', '-s', srcDir, '-d', dstDir]

    println 'running command : ' + 'cocos ' + compileArgs.join(' ')
    exec {
        // if you meet problem, just replace `getCocosCommandPath()` to the path of cocos command
        executable getCocosCommandPath()
        args compileArgs
    }

    // remove the js files in dstDir
    delete fileTree(dstDir) {
        include '**/*.js'
    }
}

android.applicationVariants.all { variant ->
    // delete previous files first
    delete "${buildDir}/intermediates/assets/${variant.dirName}"

    variant.mergeAssets.doLast {
        copy {
           from "${buildDir}/../../../../../res"
           into "${buildDir}/intermediates/assets/${variant.dirName}/res"
        }

        copy {
            from "${buildDir}/../../../../../src"
            into "${buildDir}/intermediates/assets/${variant.dirName}/src"
        }

        copy {
            from "${buildDir}/../../../../cocos2d-x/cocos/scripting/js-bindings/script"
            into  "${buildDir}/intermediates/assets/${variant.dirName}/script"
        }

        copy {
            from "${buildDir}/../../../../../main.js"
            from "${buildDir}/../../../../../project.json"
            into "${buildDir}/intermediates/assets/${variant.dirName}"
        }

        // compile the scripts if necessary
        def compileScript = (variant.name.compareTo('release') == 0)
        if (project.hasProperty('PROP_COMPILE_SCRIPT')) {
            compileScript = (PROP_COMPILE_SCRIPT.compareTo('1') == 0)
        }

        if (compileScript) {
            compileJS("${buildDir}/intermediates/assets/${variant.dirName}",
                      "${buildDir}/intermediates/assets/${variant.dirName}")
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':libcocos2dx')
}

then my Android.mk is :

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := cocos2djs_shared

LOCAL_MODULE_FILENAME := libcocos2djs

LOCAL_SRC_FILES := hellojavascript/main.cpp \
../../../Classes/AppDelegate.cpp \
../../../Classes/PluginFacebookJS.cpp \
../../../Classes/PluginFacebookJS.hpp \
../../../Classes/PluginFacebookJSHelper.cpp \
../../../Classes/PluginFacebookJSHelper.h \
../../../Classes/SDKBoxJSHelper.cpp \
../../../Classes/SDKBoxJSHelper.h \
../../../Classes/PluginIAPJS.cpp \
../../../Classes/PluginIAPJSHelper.cpp \
../../../Classes/PluginGoogleAnalyticsJS.cpp \
../../../Classes/PluginGoogleAnalyticsJS.hpp \
../../../Classes/PluginReviewJS.cpp \
../../../Classes/PluginReviewJSHelper.cpp \
../../../Classes/PluginSdkboxAdsJS.cpp \
../../../Classes/PluginSdkboxAdsJS.hpp \
../../../Classes/PluginSdkboxAdsJSHelper.cpp \
../../../Classes/PluginSdkboxAdsJSHelper.h \
../../../Classes/PluginOneSignalJS.cpp \
../../../Classes/PluginOneSignalJSHelper.cpp \
../../../Classes/PluginAdMobJS.cpp \
../../../Classes/PluginAdMobJSHelper.cpp \
../../../Classes/PluginChartboostJS.cpp \
../../../Classes/PluginChartboostJS.hpp \
../../../Classes/PluginChartboostJSHelper.cpp \
../../../Classes/PluginChartboostJSHelper.h

LOCAL_CPPFLAGS := -DSDKBOX_ENABLED
LOCAL_LDLIBS := -landroid \
-llog
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../Classes
LOCAL_WHOLE_STATIC_LIBRARIES := PluginFacebook \
sdkbox
LOCAL_WHOLE_STATIC_LIBRARIES += PluginIAP
LOCAL_WHOLE_STATIC_LIBRARIES += sdkbox
LOCAL_WHOLE_STATIC_LIBRARIES += PluginGoogleAnalytics
LOCAL_WHOLE_STATIC_LIBRARIES += PluginReview
LOCAL_WHOLE_STATIC_LIBRARIES += PluginSdkboxAds
LOCAL_WHOLE_STATIC_LIBRARIES += PluginOneSignal
LOCAL_WHOLE_STATIC_LIBRARIES += PluginFacebook
LOCAL_WHOLE_STATIC_LIBRARIES += PluginAdMob
LOCAL_WHOLE_STATIC_LIBRARIES += PluginChartboost

LOCAL_STATIC_LIBRARIES := cocos2d_js_static

LOCAL_EXPORT_CFLAGS := -DCOCOS2D_DEBUG=2 \
-DCOCOS2D_JAVASCRIPT

include $(BUILD_SHARED_LIBRARY)

$(call import-add-path, $(LOCAL_PATH)/../../../../cocos2d-x)
$(call import-add-path, $(LOCAL_PATH))
$(call import-module, cocos/scripting/js-bindings/proj.android)
$(call import-module, ./sdkbox)
$(call import-module, ./pluginfacebook)
$(call import-module, ./pluginiap)
$(call import-module, ./plugingoogleanalytics)
$(call import-module, ./pluginreview)
$(call import-module, ./pluginsdkboxads)
$(call import-module, ./pluginonesignal)
$(call import-module, ./pluginadmob)
$(call import-module, ./pluginchartboost)

how to solve this issues ? thanks for your replies