Status Update
Comments
xa...@android.com <xa...@android.com>
ch...@gmail.com <ch...@gmail.com> #2
The last backslash in the source filenames is being interpreted as escaping the trailing newline in generate-file-dir in definitions.mk .
define ev-generate-file-dir
__ndk_file_dir := $$(call parent-dir,$1) <-- Backslash here escapes new line.
$$(call generate-dir,$$(__ndk_file_dir))
$1:| $$(__ndk_file_dir)
endef
The generate-dir variable is still evaluated but this happens before the __ndk_file_dir variable is assigned its new value (because the new line that separates the assignment from the call has been escaped). Evaluation happens with __ndk_file_dir having its previous value which is why this works if you have two files in the same directory; the first file generates a directory for whatever generated a directory before it and the second file generates a directory for the first file which was in the same directory.
Using forward slashes to specify paths in your Android.mk avoids the problem.
A small snippet of makefile to illustrate the problem:
----
define ev-generate-file-directory
directory := $(dir $1)
$$(info '$$(directory)')
$$(info '$$(directory)')
endef
$(eval $(call ev-generate-file-directory,Box2D\Box2D\Dynamics\b2World.o))
----
define ev-generate-file-dir
__ndk_file_dir := $$(call parent-dir,$1) <-- Backslash here escapes new line.
$$(call generate-dir,$$(__ndk_file_dir))
$1:| $$(__ndk_file_dir)
endef
The generate-dir variable is still evaluated but this happens before the __ndk_file_dir variable is assigned its new value (because the new line that separates the assignment from the call has been escaped). Evaluation happens with __ndk_file_dir having its previous value which is why this works if you have two files in the same directory; the first file generates a directory for whatever generated a directory before it and the second file generates a directory for the first file which was in the same directory.
Using forward slashes to specify paths in your Android.mk avoids the problem.
A small snippet of makefile to illustrate the problem:
----
define ev-generate-file-directory
directory := $(dir $1)
$$(info '$$(directory)')
$$(info '$$(directory)')
endef
$(eval $(call ev-generate-file-directory,Box2D\Box2D\Dynamics\b2World.o))
----
dm...@gmail.com <dm...@gmail.com> #3
I struggled with the similiar issue, workaround helped to solve this. Add a little bit different logs.
Error:Execution failed for task ':app:compileDebugNdk'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
D:\Programs\android-ndk-r9c-windows-x86_64\android-ndk-r9c\ndk-build.cmd NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=D:\hello-jni\app\build\intermediates\ndk\debug\Android.mk APP_PLATFORM=android-19 NDK_OUT=D:\hello-jni\app\build\intermediates\ndk\debug\obj NDK_LIBS_OUT=D:\hello-jni\app\build\intermediates\ndk\debug\lib APP_ABI=all
Error Code:
2Output:
make.exe: *** No rule to make target `D:\hello-jni\app\build\intermediates\ndk\debug\obj/local/armeabi-v7a/objs/hello-jni/D_\hello-jni\app\src\main\jni', needed by `D:\hello-jni\app\build\intermediates\ndk\debug\obj/local/armeabi-v7a/objs/hello-jni/D_\hello-jni\app\src\main\jni\hello-jni.o'. Stop.
Error:Execution failed for task ':app:compileDebugNdk'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
D:\Programs\android-ndk-r9c-windows-x86_64\android-ndk-r9c\ndk-build.cmd NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=D:\hello-jni\app\build\intermediates\ndk\debug\Android.mk APP_PLATFORM=android-19 NDK_OUT=D:\hello-jni\app\build\intermediates\ndk\debug\obj NDK_LIBS_OUT=D:\hello-jni\app\build\intermediates\ndk\debug\lib APP_ABI=all
Error Code:
2Output:
make.exe: *** No rule to make target `D:\hello-jni\app\build\intermediates\ndk\debug\obj/local/armeabi-v7a/objs/hello-jni/D_\hello-jni\app\src\main\jni', needed by `D:\hello-jni\app\build\intermediates\ndk\debug\obj/local/armeabi-v7a/objs/hello-jni/D_\hello-jni\app\src\main\jni\hello-jni.o'. Stop.
pa...@gmail.com <pa...@gmail.com> #4
I Have same trouble with hello-jni sample/example.
Workaround, create second *.c file (empty.c), and all builds fine.
I am not sure, but "NDK_PROJECT_PATH=null" can be cause of it.
I have android-ndk-r10d(x64),
gradle-2.2.1,
Android Studio 1.1.0(x64),
cygwin64(v2.870).
...
:app:generateDebugSources
:app:compileDebugJava
:app:compileDebugNdk
AGPBI: {"kind":"SIMPLE","text":"make.exe: *** No rule to make target `C:\\Android\\AndroidStudioProjects\\hello-jni\\app\\build\\intermediates\\ndk\\debug\\obj/local/arm64-v8a/objs/hello-jni/C_\\Android\\AndroidStudioProjects\\hello-jni\\app\\src\\main\\jni\u0027, needed by `C:\\Android\\AndroidStudioProjects\\hello-jni\\app\\build\\intermediates\\ndk\\debug\\obj/local/arm64-v8a/objs/hello-jni/C_\\Android\\AndroidStudioProjects\\hello-jni\\app\\src\\main\\jni\\hello-jni.o\u0027. Stop.","position":{},"original":"make.exe: *** No rule to make target `C:\\Android\\AndroidStudioProjects\\hello-jni\\app\\build\\intermediates\\ndk\\debug\\obj/local/arm64-v8a/objs/hello-jni/C_\\Android\\AndroidStudioProjects\\hello-jni\\app\\src\\main\\jni\u0027, needed by `C:\\Android\\AndroidStudioProjects\\hello-jni\\app\\build\\intermediates\\ndk\\debug\\obj/local/arm64-v8a/objs/hello-jni/C_\\Android\\AndroidStudioProjects\\hello-jni\\app\\src\\main\\jni\\hello-jni.o\u0027. Stop."}
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugNdk'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Android\android-ndk-r10d\ndk-build.cmd'' finished with non-zero exit value 2
Workaround, create second *.c file (empty.c), and all builds fine.
I am not sure, but "NDK_PROJECT_PATH=null" can be cause of it.
I have android-ndk-r10d(x64),
gradle-2.2.1,
Android Studio 1.1.0(x64),
cygwin64(v2.870).
...
:app:generateDebugSources
:app:compileDebugJava
:app:compileDebugNdk
AGPBI: {"kind":"SIMPLE","text":"make.exe: *** No rule to make target `C:\\Android\\AndroidStudioProjects\\hello-jni\\app\\build\\intermediates\\ndk\\debug\\obj/local/arm64-v8a/objs/hello-jni/C_\\Android\\AndroidStudioProjects\\hello-jni\\app\\src\\main\\jni\u0027, needed by `C:\\Android\\AndroidStudioProjects\\hello-jni\\app\\build\\intermediates\\ndk\\debug\\obj/local/arm64-v8a/objs/hello-jni/C_\\Android\\AndroidStudioProjects\\hello-jni\\app\\src\\main\\jni\\hello-jni.o\u0027. Stop.","position":{},"original":"make.exe: *** No rule to make target `C:\\Android\\AndroidStudioProjects\\hello-jni\\app\\build\\intermediates\\ndk\\debug\\obj/local/arm64-v8a/objs/hello-jni/C_\\Android\\AndroidStudioProjects\\hello-jni\\app\\src\\main\\jni\u0027, needed by `C:\\Android\\AndroidStudioProjects\\hello-jni\\app\\build\\intermediates\\ndk\\debug\\obj/local/arm64-v8a/objs/hello-jni/C_\\Android\\AndroidStudioProjects\\hello-jni\\app\\src\\main\\jni\\hello-jni.o\u0027. Stop."}
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugNdk'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Android\android-ndk-r10d\ndk-build.cmd'' finished with non-zero exit value 2
xa...@android.com <xa...@android.com> #5
This bug was filed for a very early pre-1.0 version of Studio. If this is still an issue in 1.0 or later, please file a new issue. thanks!
Description
OS version: Windows 8.1
Java JRE/JDK version: 1.7.0_51 64bits
gradle version: 1.11
android-plugin version: 0.9.0
NDK version: r9d 64bits
When building ndkJniLib sample from the gradle-samples-0.9 on windows I get this error:
make.exe: *** No rule to make target `C:\Users\xhallade\Desktop\ndkJniLib\lib\build\ndk\release\obj/local/armeabi-v7a/objs/hellojni/C_\Users\xhallade\Desktop\ndkJniLib\lib\src\main\jni', needed by `C:\Users\xhallade\Desktop\ndkJniLib\lib\build\ndk\release\obj/local/armeabi-v7a/objs/hellojni/C_\Users\xhallade\Desktop\ndkJniLib\lib\src\main\jni\hello-jni.o'.
Stop.
If I create a new empty .c file aside hello-jni.c and run gradle again, the .so files are getting generated correctly.
In fact instead of calling gradle again, I can edit myself the generated Android.mk and add the second file to fix this.
When I re-run the ndk-build command line issue by gradle everything compiles fine, so the root cause seem to come from the NDK and not from the build system.
The command issued by gradle:
C:\Android\ndk\ndk-build.cmd NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=C:\Users\xhallade\Desktop\ndkJniLib\lib\build\ndk\release\Android.mk APP_PLATFORM=android-19 NDK_OUT=C:\Users\xhallade\Desktop\ndkJniLib\lib\build\ndk\release\obj NDK_LIBS_OUT=C:\Users\xhallade\Desktop\ndkJniLib\lib\build\ndk\release\lib APP_ABI=all
The generated Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hellojni
LOCAL_SRC_FILES := \
C:\Users\xhallade\Desktop\ndkJniLib\lib\src\main\jni\hello-jni.c \
LOCAL_C_INCLUDES += C:\Users\xhallade\Desktop\ndkJniLib\lib\src\main\jni
LOCAL_C_INCLUDES += C:\Users\xhallade\Desktop\ndkJniLib\lib\src\release\jni
include $(BUILD_SHARED_LIBRARY)
They are the same in both cases - only the reference to the other .c file is added in Android.mk when it's there.
The sample is attached.