Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NativeScript: how to avoid editing build.gradle in platforms/android

Tags:

nativescript

In order to get Firebase messaging running I had to do some editing in the build.gradle file in platforms/android. If I do a tns platform remove/add then my modifications are gone. Is it somehow possible to put something in app/App_Resources/android to prevent from my changes to disappear. A consideration here is that app/** is in Git whereas platform/** is not.

like image 775
Bronco Oostermeyer Avatar asked Jun 29 '16 08:06

Bronco Oostermeyer


People also ask

Why does Android use gradle?

Android Studio uses Gradle, an advanced build toolkit, to automate and manage the build process, while allowing you to define flexible custom build configurations. Each build configuration can define its own set of code and resources, while reusing the parts common to all versions of your app.

What is the purpose of the gradle in Android Studio and at what point can its content be modified?

Gradle is another build system that takes the best features from other build systems and combines them into one. It is improved based off of their shortcomings. It is a JVM-based build system. That means you can write your own script in Java, which Android Studio makes use of.

What is NativeScript Gradle build?

NativeScript uses gradle to build android applications. The gradle build files are part of the application template that comes from the android runtime package. Sometimes, if you want to use any external plugins or libraries you need to add some code to the gradle files.

How do I use NativeScript with Android Studio?

Android Studio installs the latest Android SDK by default, which in most cases should be all that's needed to build a NativeScript app. Configure the ANDROID_HOME environment variable for NativeScript to be able to find the Android SDK, and add the required tools to path.

How to set the default Android SDK version in Gradle?

Then, in your gradle script file, you can access the property by accessing it on the project object as project.myCustomVariable. In this file you can set the default Android configurations like minSdkVersion and targetSdkVersion.

What version of Android Gradle plugin does Ninja support?

This AGDE feature is built on the experimental Android Gradle plugin feature to support Ninja as a build system. Caution: These changes rely on experimental features in the Android Gradle plugin that are subject to change or removal. Change the project-level build.gradle to refer to Android Gradle plugin version 7.3.0-alpha02 or later. For example:


1 Answers

Yes. Use the app.gradle file located in App_Resources/Android.

Since this file is specific to your app it won't be removed when it's necessary to remove/add the platform to fix android build issues. I don't recall the exact NS version this was added but I think it was 1.7. Hope that helps.

like image 65
Brad Martin Avatar answered Oct 30 '22 03:10

Brad Martin