Android build failed in ubuntu


#1

ionic 3

:heavy_multiplication_x: Running command - failed!
[ERROR] An error occurred while running cordova build android (exit code 1):

    ANDROID_HOME=/home/ashvin/Desktop/Sdk
    JAVA_HOME=/usr/lib/jvm/java-8-oracle
    Subproject Path: CordovaLib
    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_aj61vzzs69lh4fntvtmpurw14.run(/var/www/html/ionic/myTabs/platforms/android/build.gradle:137)
    The JavaCompile.setDependencyCacheDir() method has been deprecated and 
    is scheduled to be removed in Gradle 4.0.
    Incremental java compilation is an incubating feature.
    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
    :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 FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':CordovaLib:processDebugResources'.
    > com.android.ide.common.process.ProcessException: Failed to execute 
    aapt
    
    * 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.257 secs
    Error: /var/www/html/ionic/myTabs/platforms/android/gradlew: Command 
    failed with exit code 1 Error output:
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':CordovaLib:processDebugResources'.
    > com.android.ide.common.process.ProcessException: Failed to execute 
    aapt
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or 
    --debug option to get more log output.

#2

What is your ionic info output?
Is ionic cordova requirements happy?


#3

when I run the command “ionic cordova build android --info”

I’m getting the result like this

ANDROID_HOME=/home/ashvin/Desktop/Sdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle
Subproject Path: CordovaLib
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_aj61vzzs69lh4fntvtmpurw14.run(/var/www/html/ionic/myTabs/platforms/android/build.gradle:137)
The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.
Incremental java compilation is an incubating feature.
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
: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 FAILED

    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':CordovaLib:processDebugResources'.
    > com.android.ide.common.process.ProcessException: Failed to execute aapt
    
    * 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: 2.113 secs
    Error: /var/www/html/ionic/myTabs/platforms/android/gradlew: Command failed with exit code 1 Error output:
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':CordovaLib:processDebugResources'.
    > com.android.ide.common.process.ProcessException: Failed to execute aapt
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

#4

I’m unsure if you were able to solve your issue, but I was plagued with this same problem. Here was my fix (Ubuntu 17.10 x64):

Install 32 bit dependances

sudo apt-get install -y lib32gcc1 libc6-i386 lib32z1 lib32stdc++6
sudo apt-get install -y lib32ncurses5 lib32gomp1 lib32z1-dev lib32bz2-dev

Ensure $ANDROID_HOME is set

Assuming you have Android Studio installed in home… does echo $ANDROID_HOME return it’s path? If not, add it to .bashrc:

# This will append two lines to the end of your .bashrc file.
# You'll need to reopen your any currently open terminals for this to take effect.
echo -e "export ANDROID_HOME=$HOME/Android/Sdk\nexport ANDROID_HOME=$HOME/Android/Sdk2" >> ~/.bashrc

Check for further problems

I then used ionic info and ionic cordova requirements in a terminal window (pathed to my project) to ensure all was well. For me, it was. After doing the above steps, ionic cordova emulate android -lc worked like a charm!