UPDATE | 2018-12-04:
This issue is resolved fully in cordova-android v7.1.4
FOR REFERENCE ONLY:
Several java dependencies appear to be missing from https://jcenter.bintray.com causing the failure of android native builds. As a workaround Ionic Appflow Package users can create the following hook script to adjust their build.gradle file. This script will force a check of https://maven.google.com before jcenter, allowing for retrieval of the necessary dependencies.
This issue was partially resolved in cordova-android v7.1.1 where maven has been prioritized over jcenter by default.
Users experiencing this issue should update to cordova-android v7.1.1 if possible. There is already a PR for a fix that should resolve the issue when cordova-android 7.1.2 is released. In the meantime it will be necessary to use the following script to package for Android in Ionic Pro.
cordova-android 7.1.1
Create a file named maven_swap.sh in the root of your project.
#!/bin/bash
if [ "$CI_SERVER" = "yes" ]; then
# If CI_SERVER is undefined or 'no' then the build is not running in Ionic Appflow
echo 'Ionic Appflow build detected, proritizing maven'
#remove jcenter
sed -i '/jcenter()/d' ./platforms/android/CordovaLib/build.gradle
#append jcenter
sed -i '/maven {/{
N
N
a\
jcenter()
}' ./platforms/android/CordovaLib/build.gradle
cat ./platforms/android/CordovaLib/build.gradle
fi
Reference the script in the android platform node in config.xml using the hook reference shown below.
<platform name="android">
<hook src="maven_swap.sh" type="before_build" />
...
</platform>
Add execute permissions using chmod +x maven_swap.sh
. If your OS doesn't include the chmod command execute permissions can be added using git. See the following article for more details.
Local Builds
When building locally this issue can be addressed manually. Change the position of maven in any build.gradle files where jcenter appears first.
- platforms/android/app/build.gradle
- platforms/android/build.gradle
- platforms/android/CordovaLib/build.gradle
change this:
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
to this:
repositories {
maven {
url "https://maven.google.com"
} jcenter()
}
This technique will not work during a Appflow package build because the platform is regenerated when the build runs.
Build log error examples:
Could not resolve all files for configuration ':debugCompileClasspath'.
> Could not find common.jar (android.arch.core:common:1.0.0).
Searched in the following locations:
https://jcenter.bintray.com/android/arch/core/common/1.0.0/common-1.0.0.jar * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
FAILURE: Build failed with an exception. * What went wrong:
A problem occurred configuring project ':CordovaLib'.
> Could not resolve all files for configuration ':CordovaLib:classpath'.
> Could not find intellij-core.jar (com.android.tools.external.com-intellij:intellij-core:26.0.1).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/external/com-intellij/intellij-core/26.0.1/intellij-core-26.0.1.jar
* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> Could not resolve all files for configuration ':CordovaLib:classpath'.
> Could not find intellij-core.jar (com.android.tools.external.com-intellij:intellij-core:26.0.1).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/external/com-intellij/intellij-core/26.0.1/intellij-core-26.0.1.jar
Comments
0 comments
Article is closed for comments.