Using external cmake executable in Android Studio - android

I would like my Android Studio project to use a different version of cmake than the one installed in Android Studio.
I added a variable
cmake.dir=C\:\\path\\to\\a\\different\\cmake
to my local.properties file, and this location is used for some of the compilation of my project but not all.
In the logs of my project build, I still see references to the cmake version installed in AS, and for example, in build_model.json under apps.cxx\cmake\debug\x86, I see:
"cmakeExecutable":
"C:\\Users\\myname\\AppData\\Local\\Android\\Sdk\\cmake\\3.10.2.4988404\\bin\\cmake.exe",
What other file/setting do I need to change so that AS uses exclusively an external verison of cmake for all compilation?

Related

Unable to select JNI build variant after upgrading Android Studio to version 3.3

I have a Java Android project that includes JNI code written in C.
I often need to debug into the native code and before upgrading Android Studio to version 3.3 it was working.
Now in my project view I don't have any code in my cpp folder. I have confirmed that all of the C libraries are in the folder on my HDD. The CMAKE file is also missing from the project view but is also in the correct place on my HDD.
I have not changed any code from my source control since upgrading.
I am using
'com.android.tools.build:gradle:3.3.0'.
In the Build Variants section next to my JNI module I just have five dashes instead of the debug/production options.
I have uninstalled and reinstalled android studio too.
Is it possible after upgrading I need to add something to my configuration to correct including CMAKE?
I had the same issue, just figured it out. In AndroidStudio 3.3.1, they changed things around a bit I guess. Now you have to link your NDK build to the app you are building it as part of.
This is documented at: https://developer.android.com/studio/projects/gradle-external-native-builds
The section, "Use the Android Studio UI" is what you want.

How make compiler into android studio project with renderscript?

I tried to import multiple android projects with render scripts, but often it does not make me compile with the "Project SDK is not defined" warning.
How should I do? Do I have to include some words?
I was interested in this project:
https://android.googlesource.com/platform/frameworks/rs/+/master/tests/java_api/LivePreview/
Use Android Studio 2.3.3
Those sources are part of the platform build, not a normal app build used by Android Studio (or even Eclipse.) In order to build it in Android Studio, you would need to manually setup your own project structure and pull the code into the correct place. Sources need to follow the Android Studio / gradle layout (app/src/main/java/... for Java sources, app/src/main/rs for Renderscript sources, etc.)
The SDK location is typically stored in the local.properties file at the top level of your project tree and is developer specific (not committed to rev control.)

How to configure a Ninja install on Android Studio

I created a CMake-supporting C++ project in Android Studio and everything works perfectly.
I saw that the native build system is Ninja, and I would like to get a standalone library folder like when you type:
make -j8 install.
which the equivalent could be:
ninja install.
My CMake scripts are supported to do this.
But when I build my project I see there is no Ninja install.
So I tried to configure in:
menu *File → Settings and in the project → opening open-module-settings.
But there is nothing to configure Ninja native build or NDK configuration.
Here the samples:
Just to know where I can configure the Ninja options in the Android Studio or in Gradle files.
My configuration:
Android Studio 2.3.1
build-tools: 25.0.2
CMake 3.6.5
Gradle 3.3
By default, ninja.build files are generated in </path/to/your/app>/Application/.externalNativeBuild/cmake/<build-type>/<arch-name>.
There you can run ninja. If you have set up an install target, you can call it so. The default folders of the compiled libraries will be something like </path/to/your/app>/Application/build/intermediates/cmake/<build-type>/obj/<arch-name>.

Do Android build tools require to download Gradle for every new project?

I have a couple of Android project samples I am going to build via the commandline using ./gradlew build on Linux. Whenever I enter this command a message says "Downloading https://services.gradle.org/distributions/gradle-3.3-all.zip". I think I already have the latest gradle under my Android Studio installation path. Why does this have to download gradle every time? Can I specify gradle as an environment variable e.g. GRADLE_HOME so that all projects can use it?
What you have in your Android Studio installation path is not significant when using the Gradle Wrapper (gradlew). It downloads the exact version of Gradle that the current build is designed for and tested with if no other build downloaded it already. The downloaded distributions are stored under ~/.gradle/wrapper/dists/. So as long as you don't delete that folder and you have multiple builds that use the same gradle distribution in the wrapper configuration, that distribution will only be downloaded by the first build you execute. The others will use the already present distribution.

Set Android NDK globally in Android Studio

The current version (1.2.1.1) of Android Studio allows me to build sample apps using the NDK, but I have noticed that each time I load a new project, I must set ndk.dir=/path/to/ndk/install in my local.properties file for Gradle to detect the NDK, whereas the sdk path is auto-populated.
Is there a way to set this globally via a preference or ENV variable? I could not find any indication that there is
in the latest release of android studio 1.3 you can set NDK path directly
in windows press ctrl+shift+alt+s which will open project properties where you can find first option named SDK Location click on it and there you can see space where you can add NDK location
If you set the environment variable ANDROID_HOME to the location of your SDK and ANDROID_NDK_HOME to the location of your NDK, and delete any local.properties file, this builds projects with native code as expected on my Android Studio 1.2. I don't know why gradle clears other property setting mechanisms when a local.properties file is present.
An alternative to this would be to replace the local.properties file with a link to a master properties file.
Note that this may all be changing when the new native code support arrives in Android Studio 1.3.

Categories

Resources