Installing the Ionic Native Diagnostic plugin causes build to fail


#1

I’m following this guide to get started on using the diagnostic plugin: http://masteringionic.com/blog/2017-04-29-using-the-ionic-native-diagnostics-plugin/

And when I get to building an Android APK, I get this error in the CLI:

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.

    BUILD FAILED

    Total time: 22.339 secs
    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.
    C:\Users\user\Desktop\GitRepos\PPRepo\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.

And I don’t know what it means. Here is my project’s information:

@ionic/cli-plugin-cordova       : 1.6.2
@ionic/cli-plugin-ionic-angular : 1.4.1
@ionic/cli-utils                : 1.7.0
ionic (Ionic CLI)               : 3.7.0

 global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts : 2.0.2
Cordova Platforms  : android 6.2.3
Ionic Framework    : ionic-angular 3.5.3

System:

Android SDK Tools : 26.0.2
Node              : v7.10.0
OS                : Windows 10
npm               : 4.2.0

Online, I found some people who were having a similar issue and their solution was to downgrade the plugin, I tried doing so, but the problem is that the code related to the plugin will not run on the device I’m testing on, and I’m assuming that’s because it’s a pretty new device, API level 26.

To see what may be the problem with the newest plugin version, I created a new Ionic project exactly the same way as this project and it worked perfectly. The only difference is that this project runs on Ionic 3.5.3 and the separate one runs on 3.6.0. Because of this the best solution sounds to update this project to 3.6.0 but you can’t do that unless you start a new project and transfer everything form the old project to the new one. This would mean re-doing everything I have on my older project and is not do-able unless it’s absolutely necessary. Any ideas?


#2

Are you sure the plugin versions are identical in your project and the newly created? Also cordova-android?

You can also copy the individual items of the newly created package.json over to your project line by line, then run npm install. For a simple update from 3.5.3 to 3.6 this should take only a few minutes and not cause any problems.

But to your real problem: There were several topic here that posted solutions by doing something in build.gradle I think. Unfortunately I don’t have the links handy and you have to search for them yourself.


#3

Are you sure the plugin versions are identical in your project and the newly created?

Yes, I verified this by using the command:

 ionic cordova plugin ls

Also cordova-android?

i’m not sure what you mean by cordova-android, but I am now realizing I forgot to show my ionic info on the new project, which is:

@ionic/cli-plugin-cordova       : 1.6.2
@ionic/cli-plugin-ionic-angular : 1.4.1
@ionic/cli-utils                : 1.7.0
ionic (Ionic CLI)               : 3.7.0

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts : 2.1.3
Cordova Platforms  : android 6.2.3
Ionic Framework    : ionic-angular 3.6.0

System:

Android SDK Tools : 26.0.2
Node              : v7.10.0
OS                : Windows 10
npm               : 4.2.0

As you can see there’s two differences, the Ionic framework version and whatever “@ionic/app-scripts” is.

I did not know about this, I’m actually working with someone on this project and I’ll ask him if this is okay with him.

I’m currently searching for these posts, but there are a lot of them not directly related to my issue so this may take some time.


#4

This “android 6.2.3” here is internally known as “cordova-android”. Sorry for skipping the explanation.

Those are actually not relevant to your problem. (app-scripts is the thing the CLI uses to build your app - almost always when the CLI outputs a timestamp this is app-scripts talking)

Yeah I know, this is a nasty topic. (Caused by that silly alpha release and bad versioning practices in Cordova plugins and gradle in general).


#5

I found the post @Sujan12 was referencing, it’s this one: Ionic diagnostic plugin error when building in Phonegap build

I did what the configurations to the gradle file and it worked for me, strangely enough it didn’t work for one of the users in that same thread. I suspect it’s because I also ran:

npm uninstall --save @ionic-native/core
npm install --save @ionic-native/core@latest

#6

Failed to install ‘cordova.plugins.diagnostic’: Error: /Users/xxxx/Workspaces/Angular IDE 2017 CI/app/platforms/android/gradlew: Command failed with exit code 1
at ChildProcess.whenDone (/Users/xxxx/Workspaces/Angular IDE 2017 CI/app/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at maybeClose (internal/child_process.js:927:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

Error: /Users/xxx/Workspaces/Angular IDE 2017 CI/app/platforms/android/gradlew: Command failed with exit code 1

[ERROR] An error occurred while running cordova plugin add cordova.plugins.diagnostic --save (exit code 1).

plz help me with this.Thanks in advance