-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Execution failed for task ':app:externalNativeBuildDebug' #310
Comments
check bitmap-plasma's CMakeLists.txt file, the lib needed is jniGraphics, add it into your CMakeLists.txt's target_link_libraries() would be fine. you might check for null pointer: you did send down a null pointer from Java to native code right now. Also for the generated prototype, you need add two modifiers to it, otherwise release build would be in trouble ( you native code would optimized away ): later when you add more functions into Java side, right click to generate corresponding native prototype, the generated prototype need to add: to all generated native code prototypes because you are using CPP file, not C file. Just bring it up ahead of the time, you will see it. Later android studio versions ( NOT the next release one ) should fix them someday. |
@ggfan thank you so much 💯 my program now run again. eagerly waiting the generate extern soon :) Thank you and best regards |
I am developing NDK Sample. I have created fresh Project using android studio with C++ support also check for "-frtti -fexceptions". It is compile properly but while running it gives below error which makes build fail. Another thing is that if I change file extendsions from .CPP to .C it will works properly. I don't know why it gives error while I change file extension. native-lib.cpp
Build.gradle
Got below error for more you can check my question on stakoverflow from here please help, Thanks in advance. |
upload your code to somewhere please, including everything?. between c and C++ is the 'extern "C"' there for in your function prototype. also what version is your android studio ( anyhow use the latest one: even the older one has bug, it is not going to be fixed in those old versions )? |
the latest Android Studio version, 3.1.2 seems ok with it. probably you could try menu: or remove build and .externalNativeBuild manually and re-try. It is a guess, nothing I could see through |
@ggfan Thanks for quick reply. As per your suggestion I have updated studio version to 3.1.3 and also follow steps given by you but still its not able to run it successfully. Even, I have tried to create .SO file from command Line by given set of commands
I find these from here Do you think that Any chance of Windows version effect it? why I am asking is because It is works fine on my home laptop windows 7 version using Android Studio and Command Line but It is not working on Windows 10 which I have in my office. I got same error while create so file from command line. It says CMAKE is not able to generate any obj file native-lib.o as below. I can see Can you look into these and give me proper solution for these if possible. |
I tried on my windows 10, it is ok with it. Got to be with something else: you do not have cmake installed on your own system, do you? Please upload your whole project to somewhere, I will download it to try. something to do with environment setting, could not see it right now BTW, the CXX_FLAGS is to be set inside CMakeLists.txt, not on command line; standard could be -std=c++11 or c++14. |
@ggfan Yes, I have installed cmake its already there within my sdk folder along with lldb. I am just building sample project with C++ support nothing else still for you I have uploaded my code here. I found something in app/.externalNativeBuild/cmake/debug/arm64-v8a/cmake_build_output.txt Detecting CXX compiler ABI info - failed. Does it mean its not able to find Compiler for C++ file becuase I see in that file it gets compile for C file. Do I need to have some changes in toolchain file? Is android studio toolchain and cmake chain files are different? Some people say clang is still not proper so I need to compile it with GCC. Is that true? |
this problem is more related to the build machine setting, unlikely to be anything related to compiler type ( gcc or clang ). Unfortunately I could not spot it: your program could build on my system of windows 10. I am not sure how to debug it either: could only guess. If you go to command line ( NOT under your sdk's cmake directory, type cmake.exe, you could not find the program, correct?) If you do find your own cmake.exe ( not sdk's ), remove it from your PATH( you could add it later after you get this simple one working ) Then, go to your project directory, remove your local.properties file;
if this could not get you through, just uninstall Android Studio, SDK and do it over from the fresh ( it saves time that way ): the re-install Android Studio, let it manage all SDK and NDK download etc. if you have lots of env variables set up for android previously, remove them all before you try. do not use external CMake ( your separate installation yet ). something simple, I just do not know what it is. |
okay. Thanks for support. I will check and let you know the result. Hope it works ,if not then I will come back to you..;) |
the build command is
that what android does. gradle will call cmake. If you have to use cmake directly and not using gradle, you would need to look at the command line parameters that gradle uses, it is in file cmake_build_command.txt file in your %project-dir%/app/.externalNativeBuild/cmake/... hope that helps. |
Yeah. I know build command. I don't want to use cmake directly that was just testing whether its working directly or not.I taught if gradle is not able to build it lets try to build using cmake.exe nothing else. While I Run(app) on my device or on emulator it gets failed with above error and that is build command fail. I don't know what is the problem? I have deleted everything and re-installed but android studio gives same error. |
while once gradlew could build, your environment is not of a problem. you could do the full cycle to the end on the command line:
that should clear up any doubt of your system. If that works and your Android Studio IDE does not work, I would check for android studio's SDK settings and make sure it is pointing to the same one you are using for command line. you experience a unique problem unfortunately I could not see what the problem is. |
I think simple gradlew.bat make build successful but gradlew.bat clean assembleDebug gives same error. I am not able to complete commands given by you because only build gradle build is successful after that going to Run(app) it gives me Build command fail above error from android studio as well as command line. Will gradlew.bat generate app.apk? No right? So how can I perfrom SDK is same while I am doing gradlew.bat from command line. Even I am also thinking that this is a unique problem for me after lot of search but I need to have solve these or try any other simple way but that I don't know to generate SO file from c++ file. Do you know any other way guide me so I can try and generate SO file? |
Oh, ok. if |
Thanks you so much Gerry for your help. After lot of try and error we are able to solve. To resolve problem I have follow below steps.
@ggfan I appreciate all the effort given buy you. Thanks again. |
Hi, I'm learning to use NDK,
The generated project run fine and show the "hello from c++".
Then I tried to change the code at native-lib.cpp from sample code of bitmap plasma:
and change MainActivity.java :
Got error:
please help, thank you
The text was updated successfully, but these errors were encountered: