In Android Studio 1.3.2, I have set sdk.dir and ndk.dir set in local.properties, but how can I access them within my gradle build scripts?
What I want to do is call ndk-build manually without having to hard code a path to the ndk-build, which now is in a known location at sdk/ndk-bundle/ndk-build. Are these path variables exposed, or, how can I expose them?
You can get the ndk.dir by android.ndkDirectory. Look at this answer to see how you can call ndk-build from gradle: https://stackoverflow.com/a/28566337/3836816
Related
When using CMake in a regular project, some variables (e.g library paths) can be configured via -D option or by using ccmake or cmake-gui The values are saved in the cache, and this provides for a local configuration that is specific to every user/developer of the code.
In Android Studio, CMake can be configured from Gradle, but I haven't been able to find an equivalent to the options above. The local.properties file can be read from gradle, but it's overwritten by AS.
Is there any way of setting CMake variables to local values from Android Studio?
Example: On a regular CMake project, I can add a line to my CMakeLists.txt like:
set(EIGEN_DIR /usr/local/include/eigen3 CACHE PATH "Eigen path")
And then two different developers may set that value to their particular systems (ie. /usr/local/include/eigen3 or /opt/local/include/eigen3) without affecting the project source code. However, in Android Studio, the only way seems to be from build.gradle, which is part of the project, and will get committed to the repositories.
I found this can be achieved by putting the variables with the desired value in the local.properties file, and then read them with the code from this answer:
Properties props = new Properties()
props.load(new FileInputStream(project.rootProject.file('local.properties')))
String conf_value = props['conf.value']
and then
externalNativeBuild{
cmake {
arguments "-DMY_CONF_VALUE="+conf_value
...
}
}
Using Android Studio:
To keep my source directories small, for google drive backup etc, I found how to specify a global gradle build directory outside my project directories here:
Gradle global build directory
Is it possible also to put the rather large .gradle/.../taskArtifacts directory outside the project directory.
Set --gradle-cache-dir when invoking gradle from the command line.
I found no option for clean project in build in android studio. what is reason for that? or is there different way to clean the project in android studio
Make sure you are looking a the correct directory. I also thought clean was missing when I looked under the root directory. Turns out it see example is located under the :app directory.
Open the Gradle side panel on the right. Select app->Tasks->build->clean
This problem can occur when you import the root directory rather than the project file. If you imported the file, make sure you select the correct file:
I'm trying to use ndk-build in cygwin but for some reason, it isn't able to find the command.
I've tried to add the path of the NDK to PATH Environment variable as shown. I'm able to invoke ndk-build from command-line but cannot do so in cygwin.
Then as suggested from this post, I've tried to run ndk-build by appending ./ in front. Still doesn't work.
As a last resort, I edited .bash_profile's path so that it points to the NDK directory. Again, it doesn't work.
SIGH....... I'd appreciate any guidance.
Remove that trailing/blank space in the folder where the ndk is installed.
See Android NDK: No rule to make target for a similar problem.
I have a Visual C++ 2012 Express project on Git that uses an external libcurl (not included in the repository).
I added the library by adding the corresponding paths on my machine (D:\libcurl\XXX) to Include Directories and Library Directories in VC++ Directories of Project Properties. So these settings are saved in the .vcxproj file.
If someone whose libcurl path is different from mine wants to build the project, he would have to:
Change VC++ Directories settings in Project Properties.
(then the project file will become modified, which is not what I want.)
Move his libcurl files to match mine (D:\libcurl).
(library path is forced to be D:\libcurl, not so flexible)
My question is: Is there a way to avoid this?
(In old versions of Visual C++, I can set the paths in the global VC++ Directories of the Tools->Options dialog instead. But the feature is deprecated in recent versions.)
I believe u can achieve this by using environment variables.
For example, you can add an environment variable called: LIBCURL
You can then set the LIBCURL to any path u want: D:\libcurl or X:\lib2.3b ...
no matter what ur library path is, u can always use the same VC++ Directories: $(LIBCURL)\XXX