20

I'm trying to use Ionic framework to build hybrid mobile apps but I'm facing the following problem since a few days.

When I want to build the application (which is actually a blank project), the command "ionic cordova build android" returns this error (detailed logs below) when executing CordovaLib:processDebugResources task:

/home/pi/android-sdk/build-tools/23.0.1/aapt: Syntax error: newline unexpected (expecting ")")

I tried to reinstall many times Android SDK. I also tried different versions of Android tools/platforms (23, 26) but it did nothing.

I didn't find on the web any solution to solve this problem. So, if someone has an idea or already faced this problem and solved it, do not hesitate!

  • Detailled logs when building the app:

:CordovaLib:generateDebugBuildConfig UP-TO-DATE :CordovaLib:processDebugResources/home/pi/android-sdk/build-tools/23.0.1/aapt: 2: /home/pi/android-sdk/build-tools/23.0.1/aapt: Syntax error: newline unexpected (expecting ")")

      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: 55.363 secs
    Error: /home/pi/IonicPJ/platforms/android/gradlew: Command failed with exit code 1 Error output:
    Picked up _JAVA_OPTIONS: -Xmx256M
    /home/pi/android-sdk/build-tools/23.0.1/aapt: 2: /home/pi/android-sdk/build-tools/23.0.1/aapt: Syntax error:
    newline unexpected (expecting ")")
                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                              
    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
  • You will find below different element concerning the components installed.

    Ionic 3.8.1
    Cordova 7.0.1
    Gradle 4.1
    JAVA 8
    

I set the variables $JAVA_HOME, $ANDROID_HOME and added $ANDROID_HOME/tools and $ANDROID_HOME/platform-tools to $PATH variable

This is the packages I installed via Android SDKManager:

    Installed packages:
  Path                        | Version | Description                    | Location
  -------                     | ------- | -------                        | -------
  build-tools;23.0.1          | 23.0.1  | Android SDK Build-Tools 23.0.1 | build-tools/23.0.1/
  emulator                    | 26.1.3  | Android Emulator               | emulator/
  extras;android;m2repository | 47.0.0  | Android Support Repository     | extras/android/m2repository/
  extras;google;m2repository  | 57      | Google Repository              | extras/google/m2repository/
  patcher;v4                  | 1       | SDK Patch Applier v4           | patcher/v4/
  platform-tools              | 26.0.0  | Android SDK Platform-Tools     | platform-tools/
  platforms;android-23        | 3       | Android SDK Platform 23        | platforms/android-23/
  platforms;android-25        | 3       | Android SDK Platform 25        | platforms/android-25/
  tools                       | 26.0.2  | Android SDK Tools              | tools/

When I run "ionic cordova platform ls", I have:

Installed platforms:
android 6.2.3

And everything is running on a raspberry with Raspbian Jessie:

Linux raspberrypi 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux
2
  • Same problem, did you get any solution?
    – FeanDoe
    Nov 27, 2017 at 12:40
  • Posible reason SDK not installed properly. Try reinstall SDK 23 again. Jul 5, 2018 at 5:12

2 Answers 2

0

Me too faced this issue, This issue occurred when I've added allowClearTextTraffic in config.xml for fixing the clear text issue. I've fixed the cleartext issue in another way and then run

ionic cordova resources android

Then the build issue was fixed!

0

There is some configuration issue with the setup of these variables.

ANDROID_HOME=/home/username/Android/Sdk
ANDROID_SDK_ROOT=/home/username/Android/Sdk
PATH=${PATH}:$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools/29.0.2/

You can do a build using android studio instead of ionic CLI.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.