Android studio ndk build hangs with clang running? - android-studio

I have an Android Studio NDK module with about 200 small C files I'm trying to build as a native library. When I do a build either from within Android Studio or from the command line with gradlew, the build process hangs part way thru compiling one of the files. Which file it hangs on is random from build to build. When the build hangs the only recourse is to kill the clang process(es) and try again. On rare occasions it will actually complete.
One guess I have is that there is some windows issue with multiple simultaneous compiles for the module. Is there a way to force make to use -j1 to test this?
Are there other reasons the build would hang?
Environment - Windows 10, Android Studio 2.3.3, Gradle 3.4.1

Related

Run a shell script before a gradle build in Android Studio?

Is it possible to run a unix shell script in Android Studio before every (gradle) build?
I'm having some trouble with gradle builds taking forever and one (admittedly bad) solution that works is to kill all java processes if they hold more than say 6Mb memory.
What I would like to do is run a shell script that does that before every build in Android Studio.
I'm not looking to add a gradle task to run before my build. That won't work because if I kill all java processes, gradle will also be killed.
So again:
Can I set up Android Studio (or gradlew) to run a script before building?
Instruction for Intellij Idea, but I hope it works for Android Studio
Edit configirations...
Select\create run configuration for gradle build. Add "before launch" option
Select ptoper option. For example - "Run external tool"

How to use the kotlin compiler in command line which comes with Android Studio?

I have Android studio version 3.4.1. I am able to build Android apps with the Kotlin language. I have heard that we can use Kotlin for creating standalone programs other than building android apps.
So, I want to know how to run the Kotlin compiler of Android studio to compile and run Kotlin programs in the command line, without downloading anything else?. I am using Windows 10 Pro.
I'm on Lubuntu 16.04 LTS, not Windows. But maybe this can still help you.
In my Lubuntu, Android Studio put the Kotlin compiler in directory
$HOME/.AndroidStudio3.4/config/plugins/Kotlin/kotlinc/bin .
So on Windows, make your file manager show hidden files and directories - because on Lubuntu, the "." in ".AndroidStudio3.4" means "hidden".
Go to your home or user directory and find a directory named "AndroidStudio3.4" or similar. Then just follow the path given above.
On Lubuntu, kotlinc (the compiler) isn't executable. If it's the same on Windows, give it execution permission.
I can't imagine that giving this permission affects how Kotlin works in Android Studio. But if you want to be on the safe side, install a separate command line compiler or IntelliJ.
By the way, the Kotlin 1.3.40 REPL crashes (s. issue KT-32085). If you need it, use Kotlin 1.3.31 .

Android NDK - building native libraries without Android Studio

I'm working on a c/c++ cross-platform project, constructed of 2 main libraries (with a few external dependencies: ssl, yajl, fribidi).
The android solution will include Java files and a JNI layer, all bundled in a AAR file (including assets and the native libs).
I managed to build the whole project, but in a very awkward way:
I created a 'hello world' Android app', with native support, from within Android Studio, and added all native dependencies to the CMAkeList.txt. I added my Java code + JNI and managed to create the AAR (only for ARM, for now).
Now I need to separate the build of the different libraries, to their separate projects, respectively: libA, libB and C.aar.
How is it done without the IDE (and via command-line)?
There's the stand-alone NDK, the make_standalone_toolchain.py script, android.toolchain.cmake and other options, but none are documented or up-to-date. Most documentation still talks about the outdated Android.mk methodology.
I'd presume including android.toolchain.cmake in my CMakeList.txt, which will set all needed environment...
I'm using the newest Android Studio 3.0.1 and NDK r16b (installed via SDK Manager)
Alex - thanks, exactly what I was looking for. Just had to add a few flags and a call to make:
> cmake -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK%\build\cmake\android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=android-19 -DCMAKE_MAKE_PROGRAM=%ANDROID_NDK%\prebuilt\windows-x86_64\bin\make.exe -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI="armeabi-v7a with NEON" ..
> cmake --build .
Android Studio (the standard Android gradle plugin, that is) does not support native-only modules, but you can split your CMake script and work with libA and libB separately. You can run cmake from command line (but better use the version that is shipped with Android SDK).
sdk/cmake/3.6.4111459/bin/cmake -DCMAKE_TOOLCHAIN_FILE=sdk/ndk-bundle/build/cmake/android.toolchain.cmake ...
The easiest way to build the AAR file that includes a compiled Java wrapper and the two native libraries would be with Android Studio, but you can run the gradle task from command line. This is what we typically do on a build server.

Open cocos2d-x-3.7 in Android Studio

What is the proper way to open cocos2d-x-3.7 in Android Studio?
I tried:
Open existing project in Android Studio project > Choose proj.android-studio directory (In another attempt, I also tried to choose the base directory MyGame)
Run
Error: couldn't find "libcocos2dcpp.so.
Moreover, it also does Classes directory in the Project.
Android Studio is only partially supported in cocos2d-x 3.7 and 3.8. With the default project you will only be able to run your app without debugging using Android Studio.
Prior to running your app in Android Studio you will have to compile using the Android Studio flag:
cocos compile -p android --android-studio
You will have to run this command after any changes to your app are made, since the default Android Studio currently doesn't compile your project.
Furthermore the default Android Studio project does not include the Classes directory.
Suggestion: Use Eclipse or Xcode to develop your cocos2d-x projects for now. Hopefully future versions of cocos2d-x will have better support for Android Studio out of the box, this is critical considering Google is dropping support for Eclipse.
When you try to run the application on Android Studio, you get the error couldn't find "libcocos2dcpp.so" because it doesn't have the NDK for building your game.
I recommend you to compile proj.android and import that, cocos2d-x 3.7 doesn't support full Android Studio yet. Do this:
cocos compile -p android
Then import your proj.android to Android Studio.
Now you can run your application but you won't able to debug it, bad news (it will just install the APK on your device or virtual device).
Hope it helps.
Error: couldn't find "libcocos2dcpp.so.
For this you need to compile android studio project first so .so files and classes folder will be generated.
Open your command line and enter the following command to compile your android studio project:
cocos compile -p android --android-studio --ap android-24 --app-abi x86
This will create required files in your proj.android-studio directory.
Now import this project into Android Studio and try to run it.

Debug version of vc++ project compains of missing msvcr80d.dll

I have a native c++ program exe which builds successfully and runs successfully in the release version. However when i try to run debug exe, it throws an exception "This application has failed to start because MSVCP80D.dll was not found. RE-installing the application may fix the proble,
Try statically linking the runtime libraries if you need to run a debug build on a PC that does not have Visual Studio installed.
http://msdn.microsoft.com/en-us/library/abx4dbyh(v=VS.100).aspx
That is because you don't have the DEBUG version of the C/C++ runtime on that machine, only the RELEASE builds. Debug builds are meant only for development and debugging. You should not install/distribute them, only Release builds. And you should install the appropriate redistributable with the VC++ runtimes.

Resources