首页 > 代码库 > [Android Studio][NDK]Execution failed for task ':app:compileDebugNdk'. Error Code:2

[Android Studio][NDK]Execution failed for task ':app:compileDebugNdk'. Error Code:2

Execution failed for task ‘:app:compileDebugNdk‘.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
 C:\Users\sodinochen\AppData\Local\Android\ndk-r10b\ndk-build.cmd NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=C:\Users\sodinochen\AndroidstudioProjects\HelloJni\app\build\intermediates\ndk\debug\Android.mk APP_PLATFORM=android-21 NDK_OUT=C:\Users\sodinochen\AndroidstudioProjects\HelloJni\app\build\intermediates\ndk\debug\obj NDK_LIBS_OUT=C:\Users\sodinochen\AndroidstudioProjects\HelloJni\app\build\intermediates\ndk\debug\lib APP_ABI=all
Error Code:
 2
Output:
 make.exe: *** No rule to make target `C:\Users\sodinochen\AndroidstudioProjects\HelloJni\app\build\intermediates\ndk\debug\obj/local/armeabi-v7a/objs/HelloJni/C_\Users\sodinochen\AndroidstudioProjects\HelloJni\app\src\main\jni‘, needed by `C:\Users\sodinochen\AndroidstudioProjects\HelloJni\app\build\intermediates\ndk\debug\obj/local/armeabi-v7a/objs/HelloJni/C_\Users\sodinochen\AndroidstudioProjects\HelloJni\app\src\main\jni\main.o‘. Stop.


出现这个错误很莫名其妙..几番折腾下,找到一个视频出来了大概原因及解决方式:
出处见Youtube视频 02:50分开始:https://www.youtube.com/watch?v=okLKfxfbz40#t=362
在Windows下NDK一个bug,当仅仅编译一个文件时出现会出现此问题,解决方法就是再加入一个空util.c文件即可。



[Android Studio][NDK]Execution failed for task ':app:compileDebugNdk'. Error Code:2