How to add plugin and classpaths

Hi, my root-top build.gradle contains:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath "com.newrelic.agent.android:agent-gradle-plugin:5.6.0"
        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

and my project/app build.gradle starts with:

apply plugin: 'com.android.application'
apply plugin: 'newrelic'

All is built and works fine in Android Studio but I have multiple issues (not found plugin and classpaths) while migrating to Tegra+VS2015. I have actually created new “nsight_tegra_build_overrides.gradle” and copied to that all content of my original build.gradle files, but it didn’t help. So my questions:

  1. How to add plugins (like Newrelic one) to Gradle coming with Tegra VS2015?
  2. where in Tegra settings I have to add classpaths from my original top-level build.gradle

Hi Nikolay,

It seems Project Root Path is different between your Android Studio project and Nsight Tegra Project.

You Can set “Gradle Project Root” Path at “Project Properties>Configuration Properties>Gradle Build>General>Gradle Project Root Path” in Nsight Tegra.

Victor

this Gradle path (Gradle Project Root Path) is the same as one in Android Studio. It points to myapp source code’s root folder. The only difference is that in VS it is given relative to VS project folder (myapp.vcxproj), it’s not absolute

please see the screenshot attached.

I can send you more logs to locate the issue.

could you also advise me how in VS\Tegra

  1. command similar to AndroidStudio’s Gradle “Synchronize” or how can I accomplish this?

  2. I use ndk-build system. Does VS\Tegra looks and uses all build.gradle files to create its final nsight_tegra_build.gradle? or i need to rename all my project’s build.gradle files into build.gradle.templates as advised by VS documentation here :
    Build your Android applications in Visual Studio using Gradle - C++ Team Blog

  3. If answer for item#2 above is No and VS/Tegra doesn’t use build.gradle and build.gradle.template then I should use nsight_tegra_build_overrides.gradle files, right? in this case should I put such overrides file on each gradle level (in same locations as my original build.gradle files)?

  4. how in VS\Tegra I can add additional classpaths and repositories for my Project? It looks VS/Tegra generates only one its internal gradle build script (nsight_tegra_build.gradle) not several (one for each level) like should be in Android application build. What is VS/Tegra doing to make this single nsight_tegra_build.gradle file to incorporate all levels Gradle settings?

Hello Nikolay,

Let me try to clarify the matters for you:

From now on let’s designate Nsight Tegra as NT and Android Studio as AS

  1. NT doesn’t have the “Synchronize” command
  2. NT doesn’t use build.gradle.templates - the linked post documents the Microsoft’s offering for Android application development that is not related to NT.
  3. You can use the configuration-specific files nsight_tegra_build_overrides.gradle to customize the project’s build script.
  4. NT uses a monolithic Gradle build script for a project, that’s not split into top-level and modules parts like it is in case of a typical AS project.

The upcoming version of NT will feature a few improvements to simplify a customisation of the project’s default auto-generated Gradle build script.

Currently, we’re not aiming to simplify the customisation of

buildscript {
    repositories { jcenter() }
    dependencies { classpath 'com.android.tools.build:gradle:2.3.3' }
}

configuration closure by adding a separate MSBuild project property for the classpaths.
The same reasoning applies to various plugins that can be used in a Gradle build script.
If the default auto-generated build script can’t be customised for your needs by tweaking the predefined parameters, then the suggested approach is to use a custom build script.

I suggest you to use an External Build System project type to wrap the invocation of your project’s top-level Gradle build script. This way you can use VS as a debugger for an APK built by the existing build scripts.

We’re open to suggestions on the topic of Gradle integration. Also, you can send us an application to participate in the evaluation of an upcoming release.