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.
Related
I am trying to run the sample project of the following project: https://github.com/Shopify/react-native-skia
When I try to start it it gives me the following error message, it says ANDROID_NDK not set.
As you can see from the image android ndk is installed.
Where am I doing wrong?
From the README.md in this GitHub-project:
If you have Android Studio installed, make sure $ANDROID_NDK is available. ANDROID_NDK=/Users/username/Library/Android/sdk/ndk-bundle for instance.
If the NDK is not installed, you can install it via Android Studio by going to the menu File > Project Structure And then the SDK Location section. It will show you the NDK path, or the option to Download it if you don't have it installed.
So it seems that you need to create a environment variable called ANDROID_NDK which points to your NDK-installation.
Since I use Android NDK for my current project, I know this isn't setup automatically.
Environment variables on MacOS: https://support.apple.com/guide/terminal/use-environment-variables-apd382cc5fa-4f58-4449-b20a-41c53c006f8f/mac
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?
I am a little confused why I am getting this message when the ANDROID_HOME environment variable is actually set.
It is also set in project defaults:
I am probably missing something trivial here, but not sure what. Thanks
Faced the same issue with Intellij IDEA 2017.2 on MacOS Sierra.
I have two projects with different Build targets (26 and 25).
Both projects were created on Win and committed to Git.
The First cloned project was with Build target 26. All needed SDK platforms and tools were downloaded with SDK Manager. The project compiled and built without any errors.
I didn't set up ANDROID_HOME variable or create local.properties file. I just set up the "Android SDK home path" within IDEA.
The Second cloned project was with Build target 25. I downloaded all needed SDK platforms and tools for this target. Then I configured new SDK for the Android API 25 platform. On Build APK got the error "SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable". I tried many solutions (created ANDROID_HOME, re-installed SDK, changed settings many times) except local.properties creation - nothing works for me. As I use the same project on different platforms the creation of the local.properties file is not a good choice.
Today I made a strange thing. I clicked the Edit link near the Android SDK Location field in the SDK Manager. Then Next -> Next -> Finish.
And my issue gone.
Check your local.properties file
If sdk.dir="Your sdk path" is not available in the file. Please add it and try.
You should also change it on Project Structure.
Close the current project and you'll see pop up with dialog which will then proceed to Configure option.
Configure -> Project Defaults -> Project Structure -> SDKs on left column -> Android SDK Home Path -> give the exact path as you did on local.properties and select Valid Target.
You should define sdk path in your local.properties file and also in the Android SDK home path.
local.properties file is not available in your project. Please add it Gradle scripts and give the sdk path to sdk.dir
It will resolve your issue.
Please check correct sdk path in your local.properties file and also in the Android SDK home path.
If still not successful, You have to just copy your local.properties file to the folder where project is stored and it will work. But remember, it must be placed in the root folder where the project is stored.
I am writing an Android application using Android Studio + Gradle and, instead of writing the SDK pathname on local.properties as
sdk.dir=/opt/android/sdk
I would like to know if is possible write something like
sdk.dir=${ANDROID_HOME}
so I could push the local.properties to the Git repository without concerning myself with the SDK location.
gradle , and thus Android Studio, will automatically use ANDROID_HOME environment variable , no need to write it into local.properties (you can just delete this file).
please see in gradle plugin user guide, search for local.properties
You should just remove that string from local.properties
That works for Eclipse ADT as well.
I recently downloaded Android Studio 3.5.1. Have also downloaded all the SDK tools
Error I am getting
this is the android sdk folder content
How do I resolve this?
Remove the ndk.dir line from your build.gradle. That's the older method of specifying the NDK to use, and that path is wrong for the NDK you've installed.
AGP 3.5 allows you to install multiple NDKs simultaneously (if you check the "show package details" box you'll see that "NDK (Side by side)" expands) and select which one to use in your build.gradle with android.ndkVersion.
You can continue using ndk.dir for now, but it's deprecated and there isn't much reason to.
See https://developer.android.com/studio/projects/install-ndk for more information.
Try like this.
/your/path/Android/sdk/ndk/20.0.5594570
But in case you are creating a native application using Android Studio, I think you should not locate for your ndk path manual.
The issue was the path only. Apparently android studio downloaded ndk as
Library/Android/sdk/ndk/20.0.5594570/allfiles
I had to rename the ndk folder to ndk-bundle and moved the subfolder files to ndk folder.