Gradle support enabled for Android builds

  • 1
  • Announcement
  • Updated 4 years ago
  • (Edited)
All Android builds using version cli-5.1.1 or newer (PhoneGap Android platform version 4.0.0+) will now default to using Gradle builds on PhoneGap Build. This should fix most issues related to NPM plugins failing to build on Android.

For more information, read the post here: http://phonegap.com/blog/2015/09/28/android-using-gradle/

Edit: We reverted ANT builds to the default version for now. To enable gradle support, use '<preference name="android-build-tool" value="gradle" />' in config.xml.
Photo of Yi Ming Kuan

Yi Ming Kuan

  • 1840 Posts
  • 78 Reply Likes

Posted 5 years ago

  • 1
Photo of Petra V.

Petra V., Champion

  • 7794 Posts
  • 1391 Reply Likes
At the same time, you guys currently recommend to use ANT instead of Gradle, beating the purpose of this change.
Great.
Photo of ColinBau

ColinBau

  • 730 Posts
  • 18 Reply Likes
hi all
I am using PGB 5.2.0
I think the gradle build for PGB seem still have some problem
for example "crosswalk"

according to this
http://phonegap.com/blog/2015/06/16/p...

before PGB support gradle,it must use this fork version to instead (at That moment build on Android is success)
gap:plugin name='org.crosswalk.engine' source='pgb' version='1.3.0'

but for now,if PGB really support gradle,it should can use the official version from npm
gap:plugin name="cordova-plugin-crosswalk-webview" source="npm" version="1.3.1"
but I tried many times,still build fail only in android
although I am already use this line...
preference name="android-build-tool" value="gradle"

by the way,if I use cordova
cordova plugin add cordova-plugin-crosswalk-webview
cordova build android => no problem at all
Photo of ryan

ryan, Developer

  • 1538 Posts
  • 132 Reply Likes
Android builds have been reverted to use ant by default again while we sort out the issues. Sorry for the hassle.
Photo of ColinBau

ColinBau

  • 730 Posts
  • 18 Reply Likes
hi ryan
so you mean is the gradle build still have some issue (just like my above feedback) for now,right ?
Photo of ryan

ryan, Developer

  • 1538 Posts
  • 132 Reply Likes
gradle builds should be ok now. to use gradle:

<preference name="android-build-tool" value="gradle" />
Photo of ColinBau

ColinBau

  • 730 Posts
  • 18 Reply Likes
hi ryan
sorry for bother
for now I have this problem
Any idea?
http://community.phonegap.com/nitobi/...
Photo of Kent Willis

Kent Willis

  • 7 Posts
  • 0 Reply Likes
I'm getting this error:
Error - One of your plugins required the gradle android build tool to build - You can fix this here
but I have this specified:
preference name="android-minSdkVersion" value="14"
preference name="android-build-tool" value="gradle"

Do I have to have a certain phonegap-version to build with gradle?
Photo of Yi Ming Kuan

Yi Ming Kuan

  • 1840 Posts
  • 78 Reply Likes
Hi Kent,

Android platform version 4.0.0+ is required. cli-5.2.0 (the default version, if phonegap-version is unspecified) or cli-5.1.1 will do.

-yiming
Photo of Dan

Dan

  • 27 Posts
  • 0 Reply Likes
Hi,

Is Gradle already working fine?

I am using:

cli-5.2.0 (3.9.1 / 4.1.1 / 3.8.1)

preference name="phonegap-version" value="cli-5.2.0"
preference name="android-build-tool" value="gradle"

----------------------------------------------
I'm receiving error:
----------------------------------------------
What went wrong:
Execution failed for task ':dexRelease'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/android-sdk/build-tools/23.0.1/dx --dex --output /project/build/intermediates/dex/release --input-list=/project/build/intermediates/tmp/dex/release/inputList.txt
Error Code:
2
Output:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
Photo of Yi Ming Kuan

Yi Ming Kuan

  • 1840 Posts
  • 78 Reply Likes
different issue

Please reference the new conversation here: Multiple dex files define Landroid/support/annotation/AnimRes
Photo of Kevin Bailey

Kevin Bailey

  • 6 Posts
  • 0 Reply Likes
I'm still having the error "Error - One of your plugins required the gradle android build tool to build" popup when building to android using PhoneGap Build. I have included

<preference name="android-build-tool" value="gradle" />

in my config.xml above my plugin definitions.

<plugin name="cordova-plugin-device" spec="1.1.1" />
<plugin name="cordova-plugin-whitelist" spec="1.2.1" />
<plugin name="phonegap-plugin-push" spec="1.5.3" />
Photo of Kevin Bailey

Kevin Bailey

  • 6 Posts
  • 0 Reply Likes
http://community.phonegap.com/nitobi/... for a link to the new topic
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Kevin,
Please start a new thread for you issue. You issue is likely beyond what you have written.
Jesse
Photo of Juangui Jordán

Juangui Jordán

  • 3 Posts
  • 0 Reply Likes
Which gradle version is PhoneGap Build using?

Can we specify the gradle version in any way?