Skip to content
This repository has been archived by the owner on May 13, 2021. It is now read-only.

Android Studio 3.0 default gradle build file fails due to old Gradle dependency #293

Open
ghhv opened this issue Mar 7, 2018 · 7 comments

Comments

@ghhv
Copy link

ghhv commented Mar 7, 2018

The Build Gradle dependency on line 34 of the build.gradle file generated by PWABuilder will not build with default Android Studio 3 due to the version being too old.

Error is similar to

Error:Gradle version 2.10 is required. Current version is 4.4. If using the gradle wrapper...

If Grade 2.x is installed, it will still fail as it needs something from a newer Gradle.

Existing Code:

dependencies { classpath 'com.android.tools.build:gradle:1.5.0' }

Fix Required to build:
This needs to be updated to at least v3 as per
dependencies { classpath 'com.android.tools.build:gradle:3.0.1' }

Can the build files generation be updated so the build works as is?

Thanks

@boyofgreen
Copy link
Contributor

Thanks for the feedback. Does the gradle version update okay when android studio does it for you? its a lot to try to keep the gradle dependency at the right version, so we've always relayed on being able to easily upgrade.

@ghhv
Copy link
Author

ghhv commented Mar 8, 2018

Unfortunately no.. you end up in a dependency loop where the system says it needs 2.2 when you have 4.x. When you downgrade gradle to 2.2, it says it's using a feature that needs a newer gradle and round you go.. the only fix is to change the base reference as above so it can use the newer gradle as required.

@LucasBassetti
Copy link

Same problem here. Any update about this issue?

@cmdalbem
Copy link

@LucasBassetti I managed to fix the problem and build the project.
1 - manually edit the Gradle dependency version as described in the original post text
2 - if it complains about not being able to resolve CordovaLib, apply the fix as described here: https://stackoverflow.com/questions/47263668/could-not-resolve-project-cordovalib

@projecteon
Copy link

Same issues and above answer by @cmdalbem did not help :/

@raphaelmerx
Copy link

An alternative is to build the app with gradle alone, without Android Studio. Following the documentation at https://developer.android.com/studio/build/building-cmdline:

cd Polyfills/cordova/platforms/android # from the pwabuilder project

# generate a keystore
keytool -genkey -v -keystore my-store.jks -keyalg RSA -keysize 2048 -validity 10000 -alias my-store

# build the unsigned apk
./gradlew assemble

# align the unsigned apk
cd build/outputs/apk
zipalign -v -p 4 android-release-unsigned.apk android-release-aligned.apk

# sign the aligned apk
apksigner sign --ks ../../../my-store.jks --out android-release.apk android-release-aligned.apk

The above generates android-release.apk, which can be uploaded to the Play Store.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants
@cmdalbem @LucasBassetti @boyofgreen @projecteon @raphaelmerx @ghhv and others