katzer/cordova-plugin-local-notifications

Gradle version support-v4:+ fetches alpha version causing build errors

dpa99c opened this issue · 8 comments

Environment

  • Plugin version: 0.8.5
  • Platform: Android
  • OS version: N/A
  • Device manufacturer / model: N/A
  • Cordova version (cordova -v): 7.0.1
  • Cordova platform version (cordova platform ls): 6.2.3
  • Plugin config N/A
  • Ionic Version (if using Ionic) N/A

Expected Behavior

The plugin will include the latest release version of the Android Support Library, which is compatible with other plugins.

Actual Behavior

The plugin will includes the latest alpha version of the Android Support Library, which is incompatible with other plugins, causing a build failure.

Explanation

This is because of the line in this plugin.xml:

<framework src="com.android.support:support-v4:+" value="gradle" />

This causes Gradle to pull in the very latest (bleeding edge) version of the Android Support Library which is currently 26.0.0-alpha1.
However, because it's an alpha, this causes issues with some other plugins, for example see this issue with cordova-plugin-facebook4.

Other plugins have also been suffering from these Gradle version collisions: see phonegap-plugin-barcodescanner#480 and cordova-diagnostic-plugin#212.

Steps to Reproduce

Reproduce by adding the latest version of this plugin along with an

  1. cordova create test && cd test/
  2. cordova platform add android@latest
  3. cordova plugin add cordova-plugin-facebook4 --save --variable APP_ID="123456789" --variable APP_NAME="myApplication"
  4. cordova compile

Observe the build succeeds and in the console output is v25.3.1 of Android Support Library:

:prepareComAndroidSupportSupportV42531Library
  1. cordova plugin add de.appplant.cordova.plugin.local-notification
  2. cordova compile

Observe the build failed and in the console output (see below) is v26.0.0-alpha1 of Android Support Library:

:prepareComAndroidSupportSupportV42600Alpha1Library

Steps to Resolve

  1. Pin the support library version to the latest major release
    • edit plugins/de.appplant.cordova.plugin.local-notification/plugin.xml and change <framework src="com.android.support:support-v4:+" value="gradle" /> to <framework src="com.android.support:support-v4:25.+" value="gradle" />
  2. Remove & re-add the Android platform to rebuild the Gradle config
    • cordova platform rm android && cordova platform add android
  3. Re-compile: cordova compile

Observe that the build succeeds and in the console output is v25.3.1 of Android Support Library:

:prepareComAndroidSupportSupportV42531Library

Debug logs

Android console output for failed build

$ cordova compile
ANDROID_HOME=\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_31
Subproject Path: CordovaLib
Parallel execution with configuration on demand is an incubating feature.
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
        at build_6nhbipi8n96npr5m0yzptpel7.run(D:\Temp\test\platforms\android\build.gradle:137)
The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.
The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instead.
Download https://repo1.maven.org/maven2/com/facebook/android/facebook-android-sdk/4.23.0/facebook-android-sdk-4.23.0.pom
Download https://repo1.maven.org/maven2/com/parse/bolts/bolts-android/1.4.0/bolts-android-1.4.0.pom
Download https://repo1.maven.org/maven2/com/parse/bolts/bolts-applinks/1.4.0/bolts-applinks-1.4.0.pom
Download https://repo1.maven.org/maven2/com/parse/bolts/bolts-applinks/1.4.0/bolts-applinks-1.4.0.jar
Download https://repo1.maven.org/maven2/com/parse/bolts/bolts-android/1.4.0/bolts-android-1.4.0.jar
Download https://repo1.maven.org/maven2/com/facebook/android/facebook-android-sdk/4.23.0/facebook-android-sdk-4.23.0.aar
:preBuild
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:preBuild UP-TO-DATE
:preDebugBuild UP-TO-DATE
:checkDebugManifest
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:preReleaseBuild UP-TO-DATE
:CordovaLib:compileDebugAidl
:generateDebugBuildConfig
:generateDebugResValues
:incrementalDebugJavaCompilationSafeguard
:CordovaLib:compileDebugNdk NO-SOURCE
:CordovaLib:compileLint
:compileDebugNdk NO-SOURCE
:mergeDebugShaders
:CordovaLib:copyDebugLint NO-SOURCE
:CordovaLib:mergeDebugShaders
:compileDebugShaders
:CordovaLib:compileDebugShaders
:CordovaLib:generateDebugAssets
:CordovaLib:mergeDebugAssets
:generateDebugAssets
:processDebugJavaRes
:CordovaLib:mergeDebugProguardFiles
:processDebugJavaRes NO-SOURCE
:validateSigningDebug
:CordovaLib:mergeDebugProguardFiles UP-TO-DATE
:CordovaLib:packageDebugRenderscript NO-SOURCE
:CordovaLib:compileDebugRenderscript
:CordovaLib:generateDebugResValues
:CordovaLib:generateDebugResources
:CordovaLib:packageDebugResources
:CordovaLib:processDebugManifest
:CordovaLib:generateDebugBuildConfig
:CordovaLib:processDebugResources
:CordovaLib:generateDebugSources
:CordovaLib:incrementalDebugJavaCompilationSafeguard
:CordovaLib:compileDebugJavaWithJavac
:CordovaLib:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:CordovaLib:processDebugJavaRes NO-SOURCE
:CordovaLib:transformResourcesWithMergeJavaResForDebug
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug
:CordovaLib:mergeDebugJniLibFolders
:CordovaLib:transformNative_libsWithMergeJniLibsForDebug
:CordovaLib:transformNative_libsWithSyncJniLibsForDebug
:CordovaLib:bundleDebug
:CordovaLib:preReleaseBuild UP-TO-DATE
:CordovaLib:checkReleaseManifest
:CordovaLib:prepareReleaseDependencies
:CordovaLib:compileReleaseAidl
:prepareOrgApacheCordovaCordovaLib623DebugLibrary
:CordovaLib:compileReleaseNdk NO-SOURCE
:CordovaLib:copyReleaseLint NO-SOURCE
:CordovaLib:mergeReleaseShaders
:CordovaLib:compileReleaseShaders
:CordovaLib:generateReleaseAssets
:CordovaLib:mergeReleaseAssets
:CordovaLib:mergeReleaseProguardFiles
:CordovaLib:packageReleaseRenderscript NO-SOURCE
:CordovaLib:compileReleaseRenderscript
:CordovaLib:generateReleaseResValues
:CordovaLib:generateReleaseResources
:CordovaLib:packageReleaseResources
:CordovaLib:processReleaseManifest
:CordovaLib:generateReleaseBuildConfig
:CordovaLib:processReleaseResources
:CordovaLib:generateReleaseSources
:CordovaLib:incrementalReleaseJavaCompilationSafeguard
:CordovaLib:compileReleaseJavaWithJavac
:CordovaLib:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:CordovaLib:processReleaseJavaRes NO-SOURCE
:CordovaLib:transformResourcesWithMergeJavaResForRelease
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForRelease
:CordovaLib:mergeReleaseJniLibFolders
:CordovaLib:transformNative_libsWithMergeJniLibsForRelease
:CordovaLib:transformNative_libsWithSyncJniLibsForRelease
:CordovaLib:bundleRelease
:prepareComAndroidSupportAnimatedVectorDrawable2531Library
:prepareComAndroidSupportAppcompatV72531Library
:prepareComAndroidSupportCardviewV72531Library
:prepareComAndroidSupportCustomtabs2531Library
:prepareComAndroidSupportSupportCompat2531Library
:prepareComAndroidSupportSupportCoreUi2531Library
:prepareComAndroidSupportSupportCoreUtils2531Library
:prepareComAndroidSupportSupportFragment2531Library
:prepareComAndroidSupportSupportMediaCompat2531Library
:prepareComAndroidSupportSupportV42531Library
:prepareComAndroidSupportSupportVectorDrawable2531Library
:prepareComFacebookAndroidFacebookAndroidSdk4230Library
:prepareDebugDependencies
:compileDebugAidl
:compileDebugRenderscript
:generateDebugResources
:mergeDebugResources
:processDebugManifest
:processDebugResources
:generateDebugSources
:compileDebugJavaWithJavac
:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
Note: D:\Temp\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:compileDebugSources
:mergeDebugAssets
:transformClassesWithDexForDebug
:mergeDebugJniLibFolders
:transformNative_libsWithMergeJniLibsForDebug
:transformNative_libsWithStripDebugSymbolForDebug
:transformResourcesWithMergeJavaResForDebug
:packageDebug
:assembleDebug
:cdvBuildDebug

BUILD SUCCESSFUL

Total time: 33.219 secs
Built the following apk(s):
        D:/Temp/test/platforms/android/build/outputs/apk/android-debug.apk


$ cordova plugin add de.appplant.cordova.plugin.local-notification
Installing "de.appplant.cordova.plugin.local-notification" for android
Installing "cordova-plugin-device" for android
ANDROID_HOME=\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_31
Subproject Path: CordovaLib
Parallel execution with configuration on demand is an incubating feature.
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
        at build_6nhbipi8n96npr5m0yzptpel7.run(D:\Temp\test\platforms\android\build.gradle:137)
The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.
The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instead.
:clean
:CordovaLib:clean

BUILD SUCCESSFUL

Total time: 2.079 secs
Installing "cordova-plugin-app-event" for android
Subproject Path: CordovaLib
Adding de.appplant.cordova.plugin.local-notification to package.json
Saved plugin info for "de.appplant.cordova.plugin.local-notification" to config.xml


$ cordova compile
ANDROID_HOME=\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_31
Subproject Path: CordovaLib
Parallel execution with configuration on demand is an incubating feature.
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
        at build_6nhbipi8n96npr5m0yzptpel7.run(D:\Temp\test\platforms\android\build.gradle:137)
The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.
The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instead.
:preBuild UP-TO-DATE
:preDebugBuild UP-TO-DATE
:checkDebugManifest
:preReleaseBuild UP-TO-DATE
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:checkDebugManifest
:CordovaLib:prepareDebugDependencies
:CordovaLib:compileDebugAidl
:CordovaLib:compileDebugNdk NO-SOURCE
:CordovaLib:compileLint
:CordovaLib:copyDebugLint NO-SOURCE
:CordovaLib:mergeDebugShaders
:CordovaLib:compileDebugShaders
:CordovaLib:generateDebugAssets
:CordovaLib:mergeDebugAssets
:generateDebugBuildConfig
:generateDebugResValues
:incrementalDebugJavaCompilationSafeguard
:compileDebugNdk NO-SOURCE
:mergeDebugShaders
:compileDebugShaders
:generateDebugAssets
:processDebugJavaRes NO-SOURCE
:validateSigningDebug
:CordovaLib:mergeDebugProguardFiles UP-TO-DATE
:CordovaLib:packageDebugRenderscript NO-SOURCE
:CordovaLib:compileDebugRenderscript
:CordovaLib:generateDebugResValues
:CordovaLib:generateDebugResources
:CordovaLib:packageDebugResources
:CordovaLib:processDebugManifest
:CordovaLib:generateDebugBuildConfig
:CordovaLib:processDebugResources
:CordovaLib:generateDebugSources
:CordovaLib:incrementalDebugJavaCompilationSafeguard
:CordovaLib:compileDebugJavaWithJavac
:CordovaLib:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:CordovaLib:processDebugJavaRes NO-SOURCE
:CordovaLib:transformResourcesWithMergeJavaResForDebug
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug
:CordovaLib:mergeDebugJniLibFolders
:CordovaLib:transformNative_libsWithMergeJniLibsForDebug
:CordovaLib:transformNative_libsWithSyncJniLibsForDebug
:CordovaLib:bundleDebug
:CordovaLib:preReleaseBuild UP-TO-DATE
:CordovaLib:checkReleaseManifest
:CordovaLib:prepareReleaseDependencies
:CordovaLib:compileReleaseAidl
:prepareOrgApacheCordovaCordovaLib623DebugLibrary
:CordovaLib:compileReleaseNdk NO-SOURCE
:CordovaLib:copyReleaseLint NO-SOURCE
:CordovaLib:mergeReleaseShaders
:CordovaLib:compileReleaseShaders
:CordovaLib:generateReleaseAssets
:CordovaLib:mergeReleaseAssets
:CordovaLib:mergeReleaseProguardFiles UP-TO-DATE
:CordovaLib:packageReleaseRenderscript NO-SOURCE
:CordovaLib:compileReleaseRenderscript
:CordovaLib:generateReleaseResValues
:CordovaLib:generateReleaseResources
:CordovaLib:packageReleaseResources
:CordovaLib:processReleaseManifest
:CordovaLib:generateReleaseBuildConfig
:CordovaLib:processReleaseResources
:CordovaLib:generateReleaseSources
:CordovaLib:incrementalReleaseJavaCompilationSafeguard
:CordovaLib:compileReleaseJavaWithJavac
:CordovaLib:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
Note: Some input files use or override a deprecated API.
:CordovaLib:processReleaseJavaRes NO-SOURCE
:CordovaLib:transformResourcesWithMergeJavaResForRelease
:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForReleaseNote: Recompile with -Xlint:deprecation for details.

:CordovaLib:mergeReleaseJniLibFolders
:CordovaLib:transformNative_libsWithMergeJniLibsForRelease
:CordovaLib:transformNative_libsWithSyncJniLibsForRelease
:CordovaLib:bundleRelease
:prepareComAndroidSupportAnimatedVectorDrawable2531Library
:prepareComAndroidSupportAppcompatV72531Library
:prepareComAndroidSupportCardviewV72531Library
:prepareComAndroidSupportCustomtabs2531Library
:prepareComAndroidSupportSupportCompat2600Alpha1Library
:prepareComAndroidSupportSupportCoreUi2600Alpha1Library
:prepareComAndroidSupportSupportCoreUtils2600Alpha1Library
:prepareComAndroidSupportSupportFragment2600Alpha1Library
:prepareComAndroidSupportSupportMediaCompat2600Alpha1Library
:prepareComAndroidSupportSupportV42600Alpha1Library
:prepareComAndroidSupportSupportVectorDrawable2531Library
:prepareComFacebookAndroidFacebookAndroidSdk4230Library
:prepareDebugDependencies
:compileDebugAidl
:compileDebugRenderscript
:generateDebugResources
:mergeDebugResources
:processDebugManifestD:\Temp\test\platforms\android\AndroidManifest.xml:27:9-31 Error:
        Attribute meta-data#android.support.VERSION@value value=(25.3.1) from [com.android.support:appcompat-v7:25.3.1] AndroidManifest.xml:27:9-31
        is also present at [com.android.support:support-v4:26.0.0-alpha1] AndroidManifest.xml:27:9-38 value=(26.0.0-alpha1).
        Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:25:5-27:34 to override.


See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.

:processDebugManifest FAILED


BUILD FAILED

Total time: 20.879 secs
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processDebugManifest'.
> Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(25.3.1) from [com.android.support:appcompat-v7:25.3.1] AndroidManifest.xml:27:9-31
        is also present at [com.android.support:support-v4:26.0.0-alpha1] AndroidManifest.xml:27:9-38 value=(26.0.0-alpha1).
        Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:25:5-27:34 to override.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Error: cmd: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
D:\Temp\test\platforms\android\AndroidManifest.xml:27:9-31 Error:
        Attribute meta-data#android.support.VERSION@value value=(25.3.1) from [com.android.support:appcompat-v7:25.3.1] AndroidManifest.xml:27:9-31
        is also present at [com.android.support:support-v4:26.0.0-alpha1] AndroidManifest.xml:27:9-38 value=(26.0.0-alpha1).
        Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:25:5-27:34 to override.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':processDebugManifest'.
> Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(25.3.1) from [com.android.support:appcompat-v7:25.3.1] AndroidManifest.xml:27:9-31
        is also present at [com.android.support:support-v4:26.0.0-alpha1] AndroidManifest.xml:27:9-38 value=(26.0.0-alpha1).
        Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:25:5-27:34 to override.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Hi,

pinning the support library should fix the problem?

I am still getting the same errors, could be more specific please?

Thank you very much

I tried doing your suggestion too, but i still got the same issue. Anything else we can do?
Thanks!

You need to remove and re-add the Android platform in the test project to rebuild the Gradle config so the changes will be reflected in the native project and the build will succeed.

I've updated the "Steps to resolve" to make this explicitly clear.

Cool it worked, so just need to re-add the platform. Thanks!

Thanks this worked for me. FYI (just in case) for Phonegap build, fork the repository and make the update, reference your forked version.

This caused us several hours today. Please make the appropriate 5-character fix, upstream! (cc: @mattblang )

That is fixed already.

@dpa99c
I got same problem like above.

The error message is below

What went wrong:
Could not resolve all files for configuration ':debugCompileClasspath'.
Could not find support-v4.jar (com.android.support:support-v4:26.1.0).
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/support-v4/26.1.0/support-v4-26.1.0.jar

On my plugin.xml is below
<framework src="com.android.support:support-v4:26.+" />

is there any way to fix the problem??

I am using 0.9.0-beta.3 for this library and
cordova version may 7.1.0-dev .... ( Meteor 1.7.0.3 version )