In Android Studio I can use a set of my sources by modifying settings.gradle like this:

include ':my_app', ':my_lib'
project(':my_lib').projectDir = new File(settingsDir, '<path_to_my_lib>')

I’d definitely like to use the same my_lib module in my Nsight Tegra project.
How is it possible?

hi deko, you can also create the same settings.gradle file, and then include the settings.gradle by Additional Options for Gradle Build task.

you can follow the steps:

  1. choose Gradle as Android Build System at project properties -> general -> Android Build System

  2. put the “-c C:\path\to\gradle.settings” into Additional Options at properties -> Gradle Build -> Command Line.

Hi Frankie_Sun,

Thank you for the answer, -c option works fine!
The next question is, what I should put in settings.gradle to build a project?
I created a simple project called TegraGradle and tried to include it in different ways, but always got the following error message:

FAILURE: Build failed with an exception.
[ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
[ERROR] [org.gradle.BuildExceptionReporter] No projects in this build have build file ‘C:\Work\Samples\TegraGradle\Tegra-Android\Debug\build\nsight_tegra_build.gradle’.
[ERROR] [org.gradle.BuildExceptionReporter]

Any ideas?

hi deko,
could you please describ more detail about your attempt ?

and could you please attach this whole project structue and build log ?

Hi Frankie_Sun,

Here is the simple project I use:

It doesn’t compile currently, but compiles when “-c” options is removed.

hi deko,
please check the content of your gradle.settings, seems it is incorrect.
I suggest you could take a verified sample to test the -c option in nsight tegra.

Hi Frankie_Sun,

You are right settings.gradle is incorrect now, as I try to make it from scratch.
Where can I find a “verified sample” to take a look at settings.gradle? The ordinary sample is created without this file.

hi deko,
I am testing to use settings.gradle to build the multi-modules project. unfortunately it’s failed when I build. anyway I will post my test details for discussion.

my test project structure is:

Android 13
| |–com
| |–test
| |–samplelib
| |–
| |–com
| |–example
| |–hellojni
| |– --------> import com.test.samplelib.SampleLib
|–nsight_tegra_build_overrides.gradle ------->the same function as build.gradle
|–settings.gradle ----------> content is: include ‘:libs’

that will fail due to:
1> * What went wrong:
1> A problem occurred evaluating settings ‘Android13’.
1> > Could not find method ?include() for arguments [:libs] on settings ‘Android13’ of type org.gradle.initialization.DefaultSettings.

troubleshooting is still ongoing.

if you have any comment are welcomed

Hi Frankie_Sun,

Thank you for investigating further!
Googling No projects in this build have build file, I found the archive topic.

Here is the example from there:

gradle -c ../settings.gradle -b build2.gradle ear
  • What went wrong:
    Could not select the default project for this build. No projects in this build have build file ‘build2.gradle’.

And the comment on the issue:
‘-b’ only works for single-project builds, but apparently you have a multi-project build. In that case, only ‘settings.gradle’ decides which build scripts are used, and conditionally using either ‘build.gradle’ or ‘build2.gradle’ is not a recommended approach.

In my example Tegra uses the following command line to execute Gradle:

"C:\...\gradle\gradle-2.2\bin\gradle.bat   -i -b C:\...\TegraGradle\Tegra-Android\Debug\build\nsight_tegra_build.gradle assembleDebug -c C:\...\TegraGradle\settings.gradle "

So, it seems that -b option is literally nailed down, and we can’t currently build mutli-project builds in Tegra. :(

I found a workaround.
I added my_lib sources in Java Source Directories settings section and it works.
Yes, I can’t still use the same Android Studio project in Tegra, but I can share the same sources, and that’s fine.