[SOLVED] Ionic package build android

ANDROID_HOME=/opt/android-sdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle
:wrapper

BUILD SUCCESSFUL

Total time: 0.766 secs
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_bfyx52z65ifmoajf885we8qut.run(/home/package/workspace/apps-a9857aba-65/cordova/platforms/android/build.gradle:141)
Checking the license for package Android SDK Platform 26 in /opt/android-sdk/licenses
License for package Android SDK Platform 26 accepted.
Preparing "Install Android SDK Platform 26".
Warning: Failed to read or create install properties file.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Failed to install the following SDK components:
  [Android SDK Platform 26]
  The SDK directory (/opt/android-sdk) is not writeable,
  please update the directory permissions.

* 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.053 secs
Error: /home/package/workspace/apps-a9857aba-65/cordova/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Failed to install the following SDK components:
  [Android SDK Platform 26]
  The SDK directory (/opt/android-sdk) is not writeable,
  please update the directory permissions.

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

Hey there! I’ll get in touch with the pro team and see whats up!

same thing happening here to something that worked before!!!

Android support cordova to Android API Level 25.
cordova-android Version Supported Android API-Levels
6.X.X 16 - 25
5.X.X 14 - 23
4.1.X 14 - 22
4.0.X 10 - 22
3.7.X 10 - 21

Need the 26 android version, but it don’t available.

1 Like

From the log last week where build succeeded, it is pulling Android 25 for 6.2.3:

You have been opted out of telemetry. To change this, run: cordova telemetry on.
Using cordova-fetch for cordova-android@^6.2.3
Adding android project…
Creating Cordova project for the Android platform:
Path: platforms/android
Package: com.xxxxxx.xxxxxx
Name: xxxxx_xxxx
Activity: MainActivity
Android target: android-25

Today their build process is pulling Android 26 for the same specified version of 6.2.3:

You have been opted out of telemetry. To change this, run: cordova telemetry on.
Using cordova-fetch for cordova-android@^6.2.3
Adding android project…
Creating Cordova project for the Android platform:
Path: platforms/android
Package: com.xxxxxx.xxxxxx
Name: xxxxx_xxxx
Activity: MainActivity
Android target: android-26

Are you does cordova platform update android@6.2.3 on project?

from config.xml

have not done any updates to this project and last week config worked with same value.

i have opened a ticket thru my ionic pro account. i have had sporadic build issues in the past, colleague had an IoS issue that lasted 1.5 days, two weeks ago, with no real explain of why IoS builds were failing. It was enough for him to cancel his account. Given I don’t believe there is anything i have done to make this happen, i would like to know what testing is done prior to making (public) gradle script changes that they are using in ionic pro build/packaging.

The solution to this problem until Ionic includes Android 26 is to downgrade the cordova-android from android@6.3.x to android @6.2.x which will then use android-sdk-25.

To do this, changing the android engine in the config.xml will not suffice, you must change the cordova-android plugin in your package.json as this is what Ionic Pro Package is using to build the project

1 Like

Yes. That works fine and the packaging will succeeed

Just to clarify, I changed my package.json to:

"cordova-android": "6.2.0",

which fixed the problem for me.

6 Likes

Hi Folks! So it appears the Android-26 API issue is due to a mis-match cordova-android issue.

If you’re attempting to build and package your app, please make sure your config.xml and package.json do not contain a ^ or a ~ in the version/spec.

3 Likes

Thanks, I was having this issue too and was about to open a ticket, but I suspect this will solve my issue! A+

Sem-ver, it’s neve that easy :smile:

Glad to be able to help!

This totally worked for me. Please remember to remove the “^” i.e. change “^6.2.3” to “6.2.0”

2 Likes

Great, It works for me :slight_smile:

Hey @mhartington,

I’ve come across the same problem with ‘ionic package build android’ with cordova-android 6.3.0

* What went wrong:
A problem occurred configuring root project 'android'.
> Failed to install the following SDK components:
  [Android SDK Platform 26]
  The SDK directory (/opt/android-sdk) is not writeable,
  please update the directory permissions.

However, the build works locally with ‘cordova build android’ with cordova-android 6.3.0.

I have plugin that seems to only work on the latest cordova-android 6.3.x

Do you know if ‘ionic package build android’ will work with cordova-android 6.3.0 soon without having to downgrade?

Thanks =)

Hey friend!

Use downgrade process to work build with android@6.2.3, all plugins same work android@6.3.0.
Remember to look your config.xml and package.json remove ^or a ~ in the version/spec as quoted @mhartington.

I hope help you!

Hey @medeiraf,

There’s an issue with google play dependencies when using multiple plugins (ie. background geolocation + phonegap push plugin) (This thread) that was fixed in cordova-android 6.3.0, but will not work in 6.2.x.

So that’s why I’m asking if there’s a way to get android@6.3.0 to work on ‘ionic package build android’?

I’ve tried to build locally with android 6.3.0 and it’s working.

Thanks for the reply though!

Hello @donw,

I’ve problems much problems with upgrade to android@6.3.0 doesn’t work on ‘ionic package build android’ anyway in my case.
Locally it’s work normally however on ‘ionic package build android’ failure:

* What went wrong:
A problem occurred configuring root project 'android'.
> Failed to install the following SDK components:
  [Android SDK Platform 26]
  The SDK directory (/opt/android-sdk) is not writeable,
  please update the directory permissions.

I don’t know a solution, no forward me a solution. Now wait for a method to work on the latest cordova-android 6.3.x
:frowning:

Did you find the solution ? I’m stuck in it too
Can you help me out please …