Error: Attribute meta-data#android.support.VERSION@value value=(26.0.0-alpha1).

The above error message I got while trying to build the APK for Android using the Ionic 2 Framework.

Without reading the full error description, I thought it may be caused by the plugin versions. So I tried to remove the recently added plugins. Then tried to build the APK. But nothing helps me. I failed again and again. Then I tried googling the error message and understood this is happened due to Grade build.

Usually, the Gradle dependency grabs newly available Android libraries instead taking the version which is mentioned by you in the Ionic 2 project.

Full Error Description:
 
" Command failed with exit code 1 Error output:
platforms/android/AndroidManifest.xml:27:9-38 Error:
    Attribute meta-data#android.support.VERSION@value value=(26.0.0-alpha1) from [com.android.support:support-v4:26.0.0-alpha1] AndroidManifest.xml:27:9-38
    is also present at [com.android.support:appcompat-v7:25.3.1] AndroidManifest.xml:27:9-31 value=(25.3.1).
    Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:25:5-27:41 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=(26.0.0-alpha1) from [com.android.support:support-v4:26.0.0-alpha1] AndroidManifest.xml:27:9-38
      is also present at [com.android.support:appcompat-v7:25.3.1] AndroidManifest.xml:27:9-31 value=(25.3.1).
      Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:25:5-27:41 to override.

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

Solution:

Add the below code at the end of the build.gradle file.
The file is located at proj_name/platforms/android/build.gradle

configurations.all {
  resolutionStrategy.eachDependency { DependencyResolveDetails details ->
    def requested = details.requested
    if (requested.group == 'com.android.support') {
      if (!requested.name.startsWith("multidex")) {
        details.useVersion '25.3.0'
      }
    }
  }
}

 I have Android 25.3.* version (installed using the Android Studio). 

Please change the details.useVersion with your actual version(Open Android Studio SDK Manager to know the versions).

Then I tried to build the APK. It working fine.

For more information, please visit the below link.

https://docs.gradle.org/current/userguide/dependency_management.html#sec:blacklisting_version

Below is the Ionic 2 software information while writing this tutorial.

Cordova CLI: 6.5.0 
Ionic Framework Version: 3.0.1
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.3.0
ios-deploy version: Not installed
ios-sim version: 5.0.13 
OS: macOS Sierra
Node Version: v6.10.0
Xcode version: Xcode 8.2.1

Installed platforms:
  android 6.1.2
  ios 4.1.1

Summary:

Grade build causes the error while trying to generate the Android APK file. Why because it tries to choose the latest  Android version instead of the version mentioned by you in the Ionic 2 project. So, modify the build.grade file to solve this error using the DependencyResolveDetails of useVersion.