Ionic cordova build issue


#1

I am trying to build and application using Ionic. I created the application fully and the ionic build ios command works without any issue, but when i try to compile the application into android i am getting a build failed issue with the following message.
I have the latest version of JAVA being installed under my machine.

:heavy_multiplication_x: Running command - failed!

[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova build android (exit code 1):

    (truncated) ... :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 UP-TO-DATE
    :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
    :CordovaLib:compileReleaseNdk UP-TO-DATE
    :CordovaLib:copyReleaseLint UP-TO-DATE
    :CordovaLib:mergeReleaseShaders
    :CordovaLib:compileReleaseShaders
    :CordovaLib:generateReleaseAssets
    :CordovaLib:mergeReleaseAssets
    :CordovaLib:mergeReleaseProguardFiles
    :CordovaLib:packageReleaseRenderscript UP-TO-DATE
    :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 UP-TO-DATE
    :CordovaLib:transformResourcesWithMergeJavaResForRelease
    :CordovaLib:transformClassesAndResourcesWithSyncLibJarsForRelease
    :CordovaLib:mergeReleaseJniLibFolders
    :CordovaLib:transformNative_libsWithMergeJniLibsForRelease
    :CordovaLib:transformNative_libsWithSyncJniLibsForRelease
    :CordovaLib:bundleRelease
    :prepareBarcodescannerLibrary
    :prepareComAndroidSupportSupportCompat2600Alpha1Library
    :prepareComAndroidSupportSupportCoreUi2600Alpha1Library
    :prepareComAndroidSupportSupportCoreUtils2600Alpha1Library
    :prepareComAndroidSupportSupportFragment2600Alpha1Library
    :prepareComAndroidSupportSupportMediaCompat2600Alpha1Library
    :prepareComAndroidSupportSupportV42600Alpha1Library
    :prepareOrgApacheCordovaCordovaLib623DebugLibrary
    :prepareDebugDependencies
    :compileDebugAidl
    :compileDebugRenderscript
    :generateDebugBuildConfig
    :generateDebugResValues
    :generateDebugResources
    :mergeDebugResources
    :processDebugManifest
    :processDebugResources
    :generateDebugSources
    :incrementalDebugJavaCompilationSafeguard
    :compileDebugJavaWithJavac
    :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.
    :compileDebugNdk UP-TO-DATE
    :compileDebugSources
    :mergeDebugShaders
    :compileDebugShaders
    :generateDebugAssets
    :mergeDebugAssets
    :transformClassesWithDexForDebug FAILED
    FAILURE: Build failed with an exception.
    * What went wrong:
    Execution failed for task ':transformClassesWithDexForDebug'.
    > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException:
    java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define
    Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
    * 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: 1 mins 16.804 secs
    Error: /Users/adithya/Desktop/mobile-app/eImpact/platforms/android/gradlew: 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.
    Note: Some input files use or override a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    FAILURE: Build failed with an exception.
    * What went wrong:
    Execution failed for task ':transformClassesWithDexForDebug'.
    > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException:
    java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define
    Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

My dependency are as following

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    debugCompile(project(path: "CordovaLib", configuration: "debug"))
    releaseCompile(project(path: "CordovaLib", configuration: "release"))
    compile "com.android.support:support-v4:+"
    // SUB-PROJECT DEPENDENCIES END
}

I am using the following plugins

<plugin name="cordova-plugin-console" spec="^1.0.7" />
    <plugin name="cordova-plugin-device" spec="^1.1.6" />
    <plugin name="cordova-plugin-document-viewer" spec="^0.9.3" />
    <plugin name="cordova-plugin-file-opener2" spec="^2.0.19" />
    <plugin name="cordova-plugin-inappbrowser" spec="^1.7.1" />
    <plugin name="cordova-plugin-splashscreen" spec="^4.0.3" />
    <plugin name="cordova-plugin-statusbar" spec="^2.2.3" />
    <plugin name="cordova-plugin-whitelist" spec="^1.3.2" />
    <plugin name="ionic-plugin-keyboard" spec="^2.2.1" />

Can anyone help me to solve this issue thanks in advance


#2

This is the relevant part of the error message:

Searching the forum or googling for it should help you find multiple topics about the same error message.

PS: If you reply that none of those provided a solution, please collect them and include the whole list of posts you checked.


#3

I came across various solutions for this issue in stackoverflow and other forum websites, I tried all the methods that are being listed by them but i still end up with the same error.


#4

The issue is being solved by downgrading the plugin’s


#5

Great!

Which one was it in your case?


#6

By downgrading all these plugins
"cordova-plugin-console": {},
“cordova-plugin-device”: {},
“cordova-plugin-splashscreen”: {},
“cordova-plugin-statusbar”: {},
“cordova-plugin-whitelist”: {},
“ionic-plugin-keyboard”: {},


#7
"cordova-plugin-document-viewer"

was the problem for me


#8

tro to downgrade to the following version it works fine for me

<plugin name="cordova-plugin-console" spec="^1.0.5" />
    <plugin name="cordova-plugin-device" spec="^1.1.4" />
    <plugin name="cordova-plugin-document-viewer" spec="^0.9.5" />
    <plugin name="cordova-plugin-inappbrowser" spec="^1.7.1" />
    <plugin name="cordova-plugin-splashscreen" spec="^4.0.3" />
    <plugin name="cordova-plugin-statusbar" spec="^2.2.2" />
    <plugin name="cordova-plugin-whitelist" spec="^1.3.1" />
    <plugin name="ionic-plugin-keyboard" spec="^2.2.1" />
    <plugin name="phonegap-plugin-barcodescanner" spec="^6.0.7" />