Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova android - How to replace custom build.gradle with generated

I have a cordova project, I have added android platform in it. Now I need to use my build.gradle file instead of the one generated.

In the plugins.xml, I have the below code to do that.

<framework src="src/android/build.gradle" custom="true" type="gradleReference" />

But while adding plugin, this build.gradle has been put under the package.It looks like this.

// PLUGIN GRADLE EXTENSIONS START
apply from: "com.test.Name/Name-build.gradle"
// PLUGIN GRADLE EXTENSIONS END

And I am getting below error in the build.gradle generated.

Error:(89, 0) Cannot convert relative path libs to an absolute file.

I need my custom build.gradle replace the auto generated. Please tell me how to specify this in plugin.xml The cordova version I use is 6.1.1

like image 460
Neela Avatar asked May 06 '16 07:05

Neela


1 Answers

The following excerpt from official cordova documentation should help you,

Extending build.gradle

If you need to customize build.gradle, rather than edit it directly, you should create a sibling file named build-extras.gradle. This file will be included by the main build.gradle when present. This file must be placed in the app folder of the android platform directory (/platforms/android/app), so it is recommended that you copy it over via a script attached to the before_build hook.

Here's an example:

// Example build-extras.gradle
// This file is included at the beginning of `build.gradle`
ext.cdvDebugSigningPropertiesFile = '../../android-debug-keys.properties'

// When set, this function allows code to run at the end of `build.gradle`
ext.postBuildExtras = {
    android.buildTypes.debug.applicationIdSuffix = '.debug'
}

Note that plugins can also include build-extras.gradle files via:

<framework src="some.gradle" custom="true" type="gradleReference"/>

Check out the offical cordova documentation for more info. Hope it helps.

like image 55
Gandhi Avatar answered Oct 08 '22 06:10

Gandhi