phonegap/phonegap-plugin-push

Getting Build Error while ionic cordova build android

quocent08 opened this issue · 10 comments

Expected Behaviour

Should build the app & generate APK.

Actual Behaviour

Getting error while running build command

Reproduce Scenario (including but not limited to)

It can be easily reproduced, without any customisation, by creating a new app then install plugin & build the app.

Steps to Reproduce

Create new ionic app
ionic start PushApp blank --type=ionic-angular
cd PushApp

Install Plugin
$ ionic cordova plugin add phonegap-plugin-push
$ npm install --save @ionic-native/push@4

Pu the google-service.json file in the root of project

Add google-service.json in config.xml

Build Application
ionic cordova build android

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

Moto

Cordova CLI version and cordova platform version

Ionic version
ionic -v
CLI 4.9.0

cordova --version                                    9.0.0 (cordova-lib@9.0.1)
cordova platform version android           android 8.1.0

Plugin version

cordova plugin version | grep phonegap-plugin-push   phonegap-plugin-push 2.3.0 "PushPlugin"

Sample Push Data Payload

Sample Code that illustrates the problem

Logs taken while reproducing problem

[cordova] FAILURE: Build failed with an exception.
[cordova]
[cordova] * Where:
[cordova] Build file '/home/sujit/Ionic/PushApp/platforms/android/app/build.gradle' line: 101
[cordova]
[cordova] * What went wrong:
[cordova] A problem occurred evaluating project ':app'.
[cordova] > Could not resolve all artifacts for configuration 'classpath'.
[cordova] > Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.60-eap-25.
[cordova] Searched in the following locations:
[cordova] - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.pom
[cordova] - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.jar
[cordova] - https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.pom
[cordova] - https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.jar
[cordova] - https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.pom
[cordova] - https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.jar
[cordova] Required by:
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.build:builder:4.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.lint:lint-gradle-api:27.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.build:gradle-api:4.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > androidx.databinding:databinding-compiler-common:4.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.build:builder:4.0.0-alpha01 > com.android.tools:sdk-common:27.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.build:builder:4.0.0-alpha01 > com.android.tools:common:27.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.build:builder:4.0.0-alpha01 > com.android.tools.build:manifest-merger:27.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.build:builder:4.0.0-alpha01 > com.android.tools.analytics-library:tracker:27.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.build:builder:4.0.0-alpha01 > com.android.tools:sdklib:27.0.0-alpha01 > com.android.tools:repository:27.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.build:builder:4.0.0-alpha01 > com.android.tools:sdk-common:27.0.0-alpha01 > com.android.tools.analytics-library:shared:27.0.0-alpha01
[cordova] > Could not find org.jetbrains.kotlin:kotlin-reflect:1.3.60-eap-25.
[cordova] Searched in the following locations:
[cordova] - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-reflect/1.3.60-eap-25/kotlin-reflect-1.3.60-eap-25.pom
[cordova] - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-reflect/1.3.60-eap-25/kotlin-reflect-1.3.60-eap-25.jar
[cordova] - https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.3.60-eap-25/kotlin-reflect-1.3.60-eap-25.pom
[cordova] - https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.3.60-eap-25/kotlin-reflect-1.3.60-eap-25.jar
[cordova] - https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-reflect/1.3.60-eap-25/kotlin-reflect-1.3.60-eap-25.pom
[cordova] - https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-reflect/1.3.60-eap-25/kotlin-reflect-1.3.60-eap-25.jar
[cordova] Required by:
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.lint:lint-gradle-api:27.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.build:builder:4.0.0-alpha01 > com.android.tools:sdk-common:27.0.0-alpha01
[cordova] > Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.60-eap-25.
[cordova] Searched in the following locations:
[cordova] - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.pom
[cordova] - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.jar
[cordova] - https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.pom
[cordova] - https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.jar
[cordova] - https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.pom
[cordova] - https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.jar
[cordova] Required by:
[cordova] unspecified:unspecified:unspecified > com.google.gms:google-services:4.2.0 > com.google.android.gms:strict-version-matcher-plugin:1.1.0
[cordova]
[cordova] * Try:
[cordova] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[cordova]
[cordova] * Get more help at https://help.gradle.org
[cordova]
[cordova] BUILD FAILED in 44s
[cordova] /home/sujit/Ionic/PushApp/platforms/android/gradlew: Command failed with exit code 1 Error output:
[cordova] Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
[cordova]
[cordova] FAILURE: Build failed with an exception.
[cordova]
[cordova] * Where:
[cordova] Build file '/home/sujit/Ionic/PushApp/platforms/android/app/build.gradle' line: 101
[cordova]
[cordova] * What went wrong:
[cordova] A problem occurred evaluating project ':app'.
[cordova] > Could not resolve all artifacts for configuration 'classpath'.
[cordova] > Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.60-eap-25.
[cordova] Searched in the following locations:
[cordova] - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.pom
[cordova] - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.jar
[cordova] - https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.pom
[cordova] - https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.jar
[cordova] - https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.pom
[cordova] - https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.jar
[cordova] Required by:
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.build:builder:4.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.lint:lint-gradle-api:27.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.build:gradle-api:4.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > androidx.databinding:databinding-compiler-common:4.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.build:builder:4.0.0-alpha01 > com.android.tools:sdk-common:27.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.build:builder:4.0.0-alpha01 > com.android.tools:common:27.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.build:builder:4.0.0-alpha01 > com.android.tools.build:manifest-merger:27.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.build:builder:4.0.0-alpha01 > com.android.tools.analytics-library:tracker:27.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.build:builder:4.0.0-alpha01 > com.android.tools:sdklib:27.0.0-alpha01 > com.android.tools:repository:27.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.build:builder:4.0.0-alpha01 > com.android.tools:sdk-common:27.0.0-alpha01 > com.android.tools.analytics-library:shared:27.0.0-alpha01
[cordova] > Could not find org.jetbrains.kotlin:kotlin-reflect:1.3.60-eap-25.
[cordova] Searched in the following locations:
[cordova] - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-reflect/1.3.60-eap-25/kotlin-reflect-1.3.60-eap-25.pom
[cordova] - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-reflect/1.3.60-eap-25/kotlin-reflect-1.3.60-eap-25.jar
[cordova] - https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.3.60-eap-25/kotlin-reflect-1.3.60-eap-25.pom
[cordova] - https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.3.60-eap-25/kotlin-reflect-1.3.60-eap-25.jar
[cordova] - https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-reflect/1.3.60-eap-25/kotlin-reflect-1.3.60-eap-25.pom
[cordova] - https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-reflect/1.3.60-eap-25/kotlin-reflect-1.3.60-eap-25.jar
[cordova] Required by:
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.lint:lint-gradle-api:27.0.0-alpha01
[cordova] unspecified:unspecified:unspecified > com.android.tools.build:gradle:4.0.0-alpha01 > com.android.tools.build:builder:4.0.0-alpha01 > com.android.tools:sdk-common:27.0.0-alpha01
[cordova] > Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.60-eap-25.
[cordova] Searched in the following locations:
[cordova] - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.pom
[cordova] - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.jar
[cordova] - https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.pom
[cordova] - https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.jar
[cordova] - https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.pom
[cordova] - https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.60-eap-25/kotlin-stdlib-jdk8-1.3.60-eap-25.jar
[cordova] Required by:
[cordova] unspecified:unspecified:unspecified > com.google.gms:google-services:4.2.0 > com.google.android.gms:strict-version-matcher-plugin:1.1.0
[cordova]
[cordova] * Try:
[cordova] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[cordova]
[cordova] * Get more help at https://help.gradle.org
[cordova]
[cordova] BUILD FAILED in 44s
[ERROR] An error occurred while running subprocess cordova.

cordova run android exited with exit code 1.

Facing the same issue.

Looks like this is coming from the usage of cordova-support-google-services in this plugin. There's an open PR in that plugin's repo to fix this issue: chemerisuk/cordova-support-google-services#26

Related SO post: https://stackoverflow.com/questions/58529904/error-could-not-find-org-jetbrains-kotlinkotlin-stdlib-jdk81-3-60-eap-25-in-i/58531201

Thanks @krishnagopinath
Fixed it using below -

I edited platforms->android->cordova-support-google-services->myAppName-build.gradle

and changed

maventCentral()

to

maven { url "https://maven.google.com" }
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }

That solved the kotlin error then I was getting a different error that I resolved by changing

classpath 'com.google.gms:google-services:4.2.0'
to

classpath 'com.google.gms:google-services:4.1.0'
It then built successfully.

It would be great if this was fixed in this repo, so we could do this in a non-hacky way :)

Guys, A help please if possible,

How to make this change to be able to use the plugin in Phonegap Build? Would it be possible to make any changes via hooks or config.xml?

I appreciate any help.

As per https://stackoverflow.com/a/58531201, adding:

<plugin name="cordova-support-google-services" spec="https://github.com/LuisEGR/cordova-support-google-services#c0a08f10a74ca552fa00c26ba0e7720bdfda5af6" />

to your config.xml (even if that’s not a direct dependency) fixed the build issue for me.

When will this be out to the main branch? It will fix alot of issues for people, including myself.

The author of cordova-support-google-services has fixed it today with Version 1.3.2 of his plugin, see here.

This Plugin must use the new Version 1.3.2 of cordova-support-google-services.

As per https://stackoverflow.com/a/58531201, adding:

<plugin name="cordova-support-google-services" spec="https://github.com/LuisEGR/cordova-support-google-services#c0a08f10a74ca552fa00c26ba0e7720bdfda5af6" />

to your config.xml (even if that’s not a direct dependency) fixed the build issue for me.

Adding this to my config.xml work for me:

Thanks!!!!

The author of cordova-support-google-services has fixed it today with Version 1.3.2 of his plugin, see here.

This Plugin must use the new Version 1.3.2 of cordova-support-google-services.

The right way.

The problem lies in the cordova-support-google-services plugin for Cordova.

This plugin’s build.gradle looks like this as of today (October 24th, 2019):

dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:4.2.0'
}
More exactly the problem lies in this dependency:

classpath 'com.android.tools.build:gradle:+'
That is an extremely brittle way of specifying dependencies. The ‘+’ sign here means “fetch the most recent version available in the repo”. If a newer version is published in the repo, and it breaks the build, then everyone with this plugin has their projects broken. This happened today. The broken version that is being fetched is com.android.tools.build:gradle:4.0.0. It requires some Kotlin stuff.

That is why you need to ALWAYS freeze dependencies to reliably build your project. Never trust the newer stuff. This dependency compiles fine just as it did yesterday:

classpath 'com.android.tools.build:gradle:3.5.1'
For those using Cordova or Ionic, you can make a quick fix to be able to build the project by freezing the dependency in the file:

/platforms/android/cordova-support-google-services/-build.gradle
This is not a definitive solution though. If you reinstall the android platform via Cordova the error will show up again. The project maintainer should either freeze the dependency or fix it to support gradle 4.0.0. In the meantime just use a fixed fork of this plugin.

Findout With example At icetutor