Met problem "Task :app:buildJni FAILED" when compling TVM RPC apk for Andriod

I met this error when using

gradle clean build

The error is

:app:buildJni (Thread[Task worker for ':',5,main]) started.

> Task :app:buildJni FAILED
Task ':app:buildJni' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
Starting process 'command 'sh''. Working directory: /workspace/apps/android_rpc/app Command: sh src/main/jni/build.sh
Successfully started process 'command 'sh''
/jvm/core/src/main/java/org/apache/tvm/LibInfo.javaapp/src/main/jni

I have tried several ways to solve this problem, such as:

  1. modify apps/android_rpc/app/src/main/jni/Android.mk: Line 36 from
LOCAL_SRC_FILES := org_apache_tvm_native_c_api.cc

to

LOCAL_SRC_FILES := org_apache_tvm_native_c_api.cc \
					$(ROOT_PATH)/src/runtime/rpc/rpc_channel.cc \
					$(ROOT_PATH)/src/runtime/rpc/rpc_endpoint.cc \
					$(ROOT_PATH)/src/runtime/rpc/rpc_local_session.cc

  1. in tvm/apps/android_rpc/app/src/main/jni/make/config.mk modify : APP_ABI = all to APP_ABI = armeabi-v7a #choose your android abi in (armeabi-v7a arm64-v8a x86 x86_64 mips) and at the last line: ADD_LDLIBS = /home/tvm/apps/android_rpc/app/src/main/jni/libtvm_runtime.so (I didn’t do cross compile, maybe this is the problem??)

Eagerly looking forward to reply.

the whole error log is listed below.

root@tvm:/workspace/apps/android_rpc# gradle clean build --info
Initialized native services in: /root/.gradle/native
The client will now receive all logging from the daemon (pid: 24417). The daemon log file: /root/.gradle/daemon/4.10-rc-2/daemon-24417.out.log
Starting 21st build in daemon [uptime: 3 hrs 11 mins 49.925 secs, performance: 100%]
Using 16 worker leases.
Starting Build
Settings evaluated using settings file '/workspace/apps/android_rpc/settings.gradle'.
Projects loaded. Root project using build file '/workspace/apps/android_rpc/build.gradle'.
Included projects: [root project 'android_rpc', project ':app']

> Configure project :
Evaluating root project 'android_rpc' using build file '/workspace/apps/android_rpc/build.gradle'.

> Configure project :app
Evaluating project ':app' using build file '/workspace/apps/android_rpc/app/build.gradle'.
Creating configuration androidTestUtil
Creating configuration compile
Creating configuration apk
Creating configuration provided
Creating configuration api
Creating configuration implementation
Creating configuration runtimeOnly
Creating configuration compileOnly
Creating configuration wearApp
Creating configuration annotationProcessor
Creating configuration androidTestCompile
Creating configuration androidTestApk
Creating configuration androidTestProvided
Creating configuration androidTestApi
Creating configuration androidTestImplementation
Creating configuration androidTestRuntimeOnly
Creating configuration androidTestCompileOnly
Creating configuration androidTestWearApp
Creating configuration androidTestAnnotationProcessor
Creating configuration testCompile
Creating configuration testApk
Creating configuration testProvided
Creating configuration testApi
Creating configuration testImplementation
Creating configuration testRuntimeOnly
Creating configuration testCompileOnly
Creating configuration testWearApp
Creating configuration testAnnotationProcessor
Creating configuration debugCompile
Creating configuration debugApk
Creating configuration debugProvided
Creating configuration debugApi
Creating configuration debugImplementation
Creating configuration debugRuntimeOnly
Creating configuration debugCompileOnly
Creating configuration debugWearApp
Creating configuration debugAnnotationProcessor
Creating configuration androidTestDebugCompile
Creating configuration androidTestDebugApk
Creating configuration androidTestDebugProvided
Creating configuration androidTestDebugApi
Creating configuration androidTestDebugImplementation
Creating configuration androidTestDebugRuntimeOnly
Creating configuration androidTestDebugCompileOnly
Creating configuration androidTestDebugWearApp
Creating configuration androidTestDebugAnnotationProcessor
Creating configuration testDebugCompile
Creating configuration testDebugApk
Creating configuration testDebugProvided
Creating configuration testDebugApi
Creating configuration testDebugImplementation
Creating configuration testDebugRuntimeOnly
Creating configuration testDebugCompileOnly
Creating configuration testDebugWearApp
Creating configuration testDebugAnnotationProcessor
Creating configuration releaseCompile
Creating configuration releaseApk
Creating configuration releaseProvided
Creating configuration releaseApi
Creating configuration releaseImplementation
Creating configuration releaseRuntimeOnly
Creating configuration releaseCompileOnly
Creating configuration releaseWearApp
Creating configuration releaseAnnotationProcessor
Creating configuration testReleaseCompile
Creating configuration testReleaseApk
Creating configuration testReleaseProvided
Creating configuration testReleaseApi
Creating configuration testReleaseImplementation
Creating configuration testReleaseRuntimeOnly
Creating configuration testReleaseCompileOnly
Creating configuration testReleaseWearApp
Creating configuration testReleaseAnnotationProcessor
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation'.
It will be removed at the end of 2018
WARNING: Configuration 'androidTestCompile' is obsolete and has been replaced with 'androidTestImplementation'.
It will be removed at the end of 2018
WARNING: Configuration 'androidTestApi' is obsolete and has been replaced with 'androidTestImplementation'.
It will be removed at the end of 2018
WARNING: Configuration 'testCompile' is obsolete and has been replaced with 'testImplementation'.
It will be removed at the end of 2018
WARNING: Configuration 'testApi' is obsolete and has been replaced with 'testImplementation'.
It will be removed at the end of 2018
Parsing the SDK, no caching allowed
WARNING: The specified Android SDK Build Tools version (26.0.1) is ignored, as it is below the minimum supported version (27.0.3) for Android Gradle Plugin 3.1.0.
Android SDK Build Tools 27.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '26.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
SDK initialized in 1 ms
Using incremental javac compilation for :app debug.
Using incremental javac compilation for :app debugUnitTest.
Using incremental javac compilation for :app release.
Using incremental javac compilation for :app releaseUnitTest.
Using incremental javac compilation for :app debugAndroidTest.
All projects evaluated.
Selected primary task 'clean' from project :
Selected primary task 'build' from project :
Tasks to be executed: [task ':clean', task ':app:clean', task ':app:buildJni', task ':app:preBuild', task ':app:preDebugBuild', task ':app:compileDebugAidl', task ':app:compileDebugRenderscript', task ':app:checkDebugManifest', task ':app:generateDebugBuildConfig', task ':app:prepareLintJar', task ':app:mainApkListPersistenceDebug', task ':app:generateDebugResValues', task ':app:generateDebugResources', task ':app:mergeDebugResources', task ':app:createDebugCompatibleScreenManifests', task ':app:processDebugManifest', task ':app:splitsDiscoveryTaskDebug', task ':app:processDebugResources', task ':app:generateDebugSources', task ':app:javaPreCompileDebug', task ':app:compileDebugJavaWithJavac', task ':app:compileDebugNdk', task ':app:compileDebugSources', task ':app:mergeDebugShaders', task ':app:compileDebugShaders', task ':app:generateDebugAssets', task ':app:mergeDebugAssets', task ':app:transformClassesWithDexBuilderForDebug', task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug', task ':app:transformDexArchiveWithDexMergerForDebug', task ':app:mergeDebugJniLibFolders', task ':app:transformNativeLibsWithMergeJniLibsForDebug', task ':app:transformNativeLibsWithStripDebugSymbolForDebug', task ':app:processDebugJavaRes', task ':app:transformResourcesWithMergeJavaResForDebug', task ':app:validateSigningDebug', task ':app:packageDebug', task ':app:assembleDebug', task ':app:preReleaseBuild', task ':app:compileReleaseAidl', task ':app:compileReleaseRenderscript', task ':app:checkReleaseManifest', task ':app:generateReleaseBuildConfig', task ':app:mainApkListPersistenceRelease', task ':app:generateReleaseResValues', task ':app:generateReleaseResources', task ':app:mergeReleaseResources', task ':app:createReleaseCompatibleScreenManifests', task ':app:processReleaseManifest', task ':app:splitsDiscoveryTaskRelease', task ':app:processReleaseResources', task ':app:generateReleaseSources', task ':app:javaPreCompileRelease', task ':app:compileReleaseJavaWithJavac', task ':app:compileReleaseNdk', task ':app:compileReleaseSources', task ':app:lintVitalRelease', task ':app:mergeReleaseShaders', task ':app:compileReleaseShaders', task ':app:generateReleaseAssets', task ':app:mergeReleaseAssets', task ':app:transformClassesWithDexBuilderForRelease', task ':app:transformDexArchiveWithExternalLibsDexMergerForRelease', task ':app:transformDexArchiveWithDexMergerForRelease', task ':app:mergeReleaseJniLibFolders', task ':app:transformNativeLibsWithMergeJniLibsForRelease', task ':app:transformNativeLibsWithStripDebugSymbolForRelease', task ':app:processReleaseJavaRes', task ':app:transformResourcesWithMergeJavaResForRelease', task ':app:packageRelease', task ':app:assembleRelease', task ':app:assemble', task ':app:lint', task ':app:preDebugUnitTestBuild', task ':app:javaPreCompileDebugUnitTest', task ':app:compileDebugUnitTestJavaWithJavac', task ':app:mockableAndroidJar', task ':app:processDebugUnitTestJavaRes', task ':app:testDebugUnitTest', task ':app:preReleaseUnitTestBuild', task ':app:javaPreCompileReleaseUnitTest', task ':app:compileReleaseUnitTestJavaWithJavac', task ':app:processReleaseUnitTestJavaRes', task ':app:testReleaseUnitTest', task ':app:test', task ':app:check', task ':app:build']
:clean (Thread[Task worker for ':',5,main]) started.

> Task :clean UP-TO-DATE
Task ':clean' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
:clean (Thread[Task worker for ':',5,main]) completed. Took 0.006 secs.
:app:clean (Thread[Task worker for ':',5,main]) started.

> Task :app:clean UP-TO-DATE
Task ':app:clean' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
:app:clean (Thread[Task worker for ':',5,main]) completed. Took 0.0 secs.
:app:buildJni (Thread[Task worker for ':',5,main]) started.

> Task :app:buildJni FAILED
Task ':app:buildJni' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
Starting process 'command 'sh''. Working directory: /workspace/apps/android_rpc/app Command: sh src/main/jni/build.sh
Successfully started process 'command 'sh''
/jvm/core/src/main/java/org/apache/tvm/LibInfo.javaapp/src/main/jni
Usage: javac <options> <source files>
use -help for a list of possible options
src/main/jni/build.sh: 21: exit: Illegal number: -1
:app:buildJni (Thread[Task worker for ':',5,main]) completed. Took 0.074 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:buildJni'.
> Process 'command 'sh'' finished with non-zero exit value 2

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
3 actionable tasks: 1 executed, 2 up-to-date
root@tvm:/workspace/apps/android_rpc#