Error while running in android device


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

[ERROR] An error occurred while running cordova run android (exit code 1).

#2

Please post the rest of the error message and the exact command your are running.
Also post your ionic info output please.


#3
@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 ios 4.4.0
Ionic Framework    : ionic-angular 3.6.0

System:

Node : v8.1.4
OS   : Windows 10
npm  : 5.0.3

#4

It was happen lot of times when i was remove the platform and then add it again the error was occuring


#5

You haven’t posted the actual error yet. This is just the message that there was an error. The actual error comes before or after. Also, please mention the exact commands you executed. “remove the platform and then add it again” can be done with 20 different commands.


#6

I found an error …The error was mergedebug resources error…!


    BUILD FAILED

    Total time: 7.637 secs

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':mergeDebugResources'.
    > Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:

    * 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:
    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':mergeDebugResources'.
    > Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:

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

#7

how can i resolve the error…

I build with cmd

  ionic cordova build android
  ionic cordova run android

#8

No idea. Post the whole output of the build process, including the command you ran.


#9

I run the command as : ionic cordova build android

Error :


C:\Users\Admin\sample_locationAccuracy>ionic cordova build android
Running app-scripts build: --build --iscordovaserve --nobrowser

[16:58:46]  build dev started ...
[16:58:46]  clean started ...
[16:58:46]  clean finished in 16 ms
[16:58:46]  copy started ...
[16:58:46]  transpile started ...
[16:58:50]  transpile finished in 3.87 s
[16:58:50]  preprocess started ...
[16:58:50]  deeplinks started ...
[16:58:50]  deeplinks finished in 86 ms
[16:58:50]  preprocess finished in 86 ms
[16:58:50]  webpack started ...
[16:58:51]  copy finished in 4.31 s
[16:59:00]  webpack finished in 9.51 s
[16:59:00]  sass started ...
[16:59:01]  sass finished in 1.75 s
[16:59:01]  postprocess started ...
[16:59:01]  postprocess finished in 16 ms
[16:59:01]  lint started ...
[16:59:02]  build dev finished in 15.31 s
> ionic cordova prepare
> cordova prepare
√ Running command - done!

> cordova build android
\ Running command [16:59:08]  tslint: C:/Users/Admin/sample_locationAccuracy/src/app/app.component.ts, line: 1
            All imports are unused.

       L1:  import { SplashPage } from './../pages/splash/splash';
       L2:  import { Component } from '@angular/core';

[16:59:08]  lint finished in 6.44 s
× 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) ... ject) 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 UP-TO-DATE
        :CordovaLib:compileDebugNdk UP-TO-DATE
        :CordovaLib:compileLint UP-TO-DATE
        :CordovaLib:copyDebugLint UP-TO-DATE
        :CordovaLib:mergeDebugShaders UP-TO-DATE
        :CordovaLib:compileDebugShaders UP-TO-DATE
        :CordovaLib:generateDebugAssets UP-TO-DATE
        :CordovaLib:mergeDebugAssets UP-TO-DATE
        :CordovaLib:mergeDebugProguardFiles UP-TO-DATE
        :CordovaLib:packageDebugRenderscript UP-TO-DATE
        :CordovaLib:compileDebugRenderscript UP-TO-DATE
        :CordovaLib:generateDebugResValues UP-TO-DATE
        :CordovaLib:generateDebugResources UP-TO-DATE
        :CordovaLib:packageDebugResources UP-TO-DATE
        :CordovaLib:processDebugManifest UP-TO-DATE
        :CordovaLib:generateDebugBuildConfig UP-TO-DATE
        :CordovaLib:processDebugResources UP-TO-DATE
        :CordovaLib:generateDebugSources UP-TO-DATE
        :CordovaLib:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
        :CordovaLib:compileDebugJavaWithJavac UP-TO-DATE
        :CordovaLib:processDebugJavaRes UP-TO-DATE
        :CordovaLib:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
        :CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug UP-TO-DATE
        :CordovaLib:mergeDebugJniLibFolders UP-TO-DATE
        :CordovaLib:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
        :CordovaLib:transformNative_libsWithSyncJniLibsForDebug UP-TO-DATE
        :CordovaLib:bundleDebug UP-TO-DATE
        :CordovaLib:preReleaseBuild UP-TO-DATE
        :CordovaLib:checkReleaseManifest
        :CordovaLib:prepareReleaseDependencies
        :CordovaLib:compileReleaseAidl UP-TO-DATE
        :CordovaLib:compileReleaseNdk UP-TO-DATE
        :CordovaLib:copyReleaseLint UP-TO-DATE
        :CordovaLib:mergeReleaseShaders UP-TO-DATE
        :CordovaLib:compileReleaseShaders UP-TO-DATE
        :CordovaLib:generateReleaseAssets UP-TO-DATE
        :CordovaLib:mergeReleaseAssets UP-TO-DATE
        :CordovaLib:mergeReleaseProguardFiles UP-TO-DATE
        :CordovaLib:packageReleaseRenderscript UP-TO-DATE
        :CordovaLib:compileReleaseRenderscript UP-TO-DATE
        :CordovaLib:generateReleaseResValues UP-TO-DATE
        :CordovaLib:generateReleaseResources UP-TO-DATE
        :CordovaLib:packageReleaseResources UP-TO-DATE
        :CordovaLib:processReleaseManifest UP-TO-DATE
        :CordovaLib:generateReleaseBuildConfig UP-TO-DATE
        :CordovaLib:processReleaseResources UP-TO-DATE
        :CordovaLib:generateReleaseSources UP-TO-DATE
        :CordovaLib:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
        :CordovaLib:compileReleaseJavaWithJavac UP-TO-DATE
        :CordovaLib:processReleaseJavaRes UP-TO-DATE
        :CordovaLib:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
        :CordovaLib:transformClassesAndResourcesWithSyncLibJarsForRelease UP-TO-DATE
        :CordovaLib:mergeReleaseJniLibFolders UP-TO-DATE
        :CordovaLib:transformNative_libsWithMergeJniLibsForRelease UP-TO-DATE
        :CordovaLib:transformNative_libsWithSyncJniLibsForRelease UP-TO-DATE
        :CordovaLib:bundleRelease UP-TO-DATE
        :prepareComAndroidSupportSupportCompat2520Library UP-TO-DATE
        :prepareComAndroidSupportSupportCoreUi2520Library UP-TO-DATE
        :prepareComAndroidSupportSupportCoreUtils2520Library UP-TO-DATE
        :prepareComAndroidSupportSupportFragment2520Library UP-TO-DATE
        :prepareComAndroidSupportSupportMediaCompat2520Library UP-TO-DATE
        :prepareComAndroidSupportSupportV42520Library UP-TO-DATE
        :prepareComGoogleAndroidGmsPlayServicesBase1101Library UP-TO-DATE
        :prepareComGoogleAndroidGmsPlayServicesBasement1101Library UP-TO-DATE
        :prepareComGoogleAndroidGmsPlayServicesLocation1101Library UP-TO-DATE
        :prepareComGoogleAndroidGmsPlayServicesTasks1101Library UP-TO-DATE
        :prepareOrgApacheCordovaCordovaLib623DebugLibrary UP-TO-DATE
        :prepareDebugDependencies
        :compileDebugAidl UP-TO-DATE
        :compileDebugRenderscript UP-TO-DATE
        :generateDebugBuildConfig UP-TO-DATE
        :generateDebugResValues UP-TO-DATE
        :generateDebugResources UP-TO-DATE
        :mergeDebugResources
        Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
        :mergeDebugResources FAILED

        BUILD FAILED

        Total time: 6.671 secs

        FAILURE: Build failed with an exception.

        * What went wrong:
        Execution failed for task ':mergeDebugResources'.
        > Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:

        * 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:
        FAILURE: Build failed with an exception.

        * What went wrong:
        Execution failed for task ':mergeDebugResources'.
        > Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:

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

#10

No useful information in there :confused:

Do you get the same error with a new project? (ionic start blank blank)


#11

I would try removing the android platform, readding it, and then running ionic cordova resources.


#12

NO @Sujan12 when i was converted my custom icon and theme it cause an error


#13

Is this only happening when trying to run on device ? did you run it before or its first time ?


#14

I already running in device and again convert my resource images then again running in android on that time it wil show an error


#15

i got this before also and i found that i didn’t install the right version of android-sdk api level. Check the api level you are using in your config.xml file and then open sdk manager of android and check if the api level is installed.


#16

Yeah now its working…:neutral_face: thanks @dotnetdreamer


#17

i am glad it worked :slight_smile:


#18

I have the same problem. config.xml has minSdkVersion as 16. I am on 27. And Android 6.3.0. I have from level 23 v. 6.0 onwards installed. Still can’t build or run android. Possibly gradle issue. Let me know if you can see any issue in the above.