Unable to create build ionic3 using command ionic build android - android

I set an environment path for JAVA_HOME and followed
android studio Error:Unable to start the daemon process.
I'm still getting an error, not able to create build. I am using latest version of node, npm, ionic.
Error:
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_11
studio
Subproject Path: CordovaLib
Subproject Path: app
[12:02:18] lint finished in 9.73 s
[Fatal Error] gradle-bintray-plugin-1.7.3.pom:2:1: Content is not allowed
log.
[Fatal Error] android-maven-gradle-plugin-1.5.pom:2:1: Content is not all
prolog.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> Could not resolve all files for configuration ':CordovaLib:classpath'.

Did you upgrade your cordova? After updating it might be run. Or you can remove nodemodule folder and then do npm install and then try to build your app.

Related

React-native-blob-util couldn't find ANDROID_SDK_ROOT

npx react-native run-android causes the following error with module react-native-blob-util on Big Sur/React Native 0.66.1/Android Studio 2020.3.1:
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/macair/Documents/code/js/xyz_app5/node_modules/react-native-blob-util/android/build.gradle' line: 69
* What went wrong:
A problem occurred configuring project ':react-native-blob-util'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/Users/macair/Documents/code/js/xyz_app5/android/local.properties'.
The line of code in react-native-blob-util 0.13.16 build.gradle which causes error is:
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
But a .bash_profile has been created with ANDROID_SDK_ROOT defined. Also in project structure under android studio SDK has been defined and pointing to /Library/android/sdk. What is really missing here?
Here is the SDK defined in project structure:
After installing Android 10 by following setup for Android in React Native, the error disappeared.

Instruct gradle to use local files

I am trying to build an ionic 4 project for android with this command:
ionic cordova build android --verbose
The bulid fails with the following error:
Running command: /path/gradlew cdvBuildDebug -b /path/build.gradle
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:3.3.0.
Searched in the following locations:
- https://dl.google.com/path/gradle-3.3.0.pom
- https://dl.google.com/path/gradle-3.3.0.jar
...
When I do wget https://dl.google.com/path/gradle-3.3.0.pom I get 404.
When I paste the url into the addressbar of my browser however the file does get downloaded. So, I have been able to download the files gradle is having trouble downloading.
Is there a way I instruct gradle to use the local files instead of trying to download them?
i think this is for sanctions and if we can use vpn thats resolved

"ionic cordova build" fails to build apk

I cannot build an apk in cordova. Build always fails.
Set my android SDK home
export ANDROID_HOME/home/felipe/Android/Sdk/
First, build cannot find gradle, so i put gradle in path. I have tried this with downloaded gradle or the gradle that i have in android studio.
export PATH=$PATH:/home/felipe/gradle-4.1/bin
For make sure that i have updated versions of cordova and ionic
npm install -g cordova#latest
npm install -g ionic#latest
simple sample app
ionic start sidemenu sidemenu --type ionic1
cd sidemenu
ionic cordova platform add android
ionic cordova build android
And then i got:
> ionic cordova prepare
> cordova prepare
✔ Running command - done!
Running command: /home/felipe/ionic-testes/sidemenu/hooks/after_prepare/010_add_platform_class.js /home/felipe/ionic-testes/sidemenu
add to body class: platform-android
> cordova build android
✖ 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):
Running command: /home/felipe/ionic-testes/sidemenu/hooks/after_prepare/010_add_platform_class.js
/home/felipe/ionic-testes/sidemenu
add to body class: platform-android
ANDROID_HOME=/home/felipe/Android/Sdk/
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
Subproject Path: CordovaLib
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:2.2.3.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:2.2.3.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom'.
> Could not HEAD 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested
target
* 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.176 secs
Error: /home/felipe/ionic-testes/sidemenu/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'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:2.2.3.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:2.2.3.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom'.
> Could not HEAD 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested
target
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Please. Could somebody help me? Thank you for attention
Solved. I've Just opened in Android Studio.
I don't know why, but the user whose answar was correct has deleted his post. I had installed sdk with sdk manager in Android Studio, and i had installed other updates suggested by Android Studio, but only when i open the project in android studio it did the updates required.
From error message, i guess i have some Certification Authority missing in my open jdk installation (i am using openjdk from ubuntu repositories and have installed ca-certificates-java package). But, for now, it works.
Please create project with this commands
Ionic start sidemenu sidemenu --blank
Cd sidemenu
Add required platform Android, iOS
4.Cordova build android
Cordova run android

Ubuntu 16/Cordova 6.4/Android: Could not resolve com.android.tools.build:gradle

I'm trying to use Cordova 6.4 with Android Studio in Ubuntu 16 OS.
I've installed the Android Studio Correctly and downloads the SDK.
And the npm and cordova is also installed.
And I tried to create a project:
cordova create myapp
cd myapp
cordova platform add android
And this yields the following error:
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: io.cordova.hellocordova
Name: HelloCordova
Activity: MainActivity
Android target: android-24
Subproject Path: CordovaLib
Android project created with cordova-android#6.0.0
Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project
Fetching plugin "cordova-plugin-whitelist#1" via npm
Installing "cordova-plugin-whitelist" for android
ANDROID_HOME=/home/alfred/Android/Sdk/
JAVA_HOME=/usr/lib/jvm/java-8-oracle
Subproject Path: CordovaLib
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:2.2.0.
Required by:
:android:unspecified
> Could not resolve com.android.tools.build:gradle:2.2.0.
> Could not get resource 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.pom'.
> Could not GET 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Could not resolve com.android.tools.build:gradle:2.2.0.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.pom'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.pom'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
* 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: 4.847 secs
Failed to install 'cordova-plugin-whitelist':Error: /home/alfred/app/myapp/platforms/android/gradlew: Command failed with exit code 1
at ChildProcess.whenDone (/home/alfred/app/myapp/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:877:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
Failed to restore plugin "cordova-plugin-whitelist" from config.xml. You might need to try adding it again. Error: Error: /home/alfred/app/myapp/platforms/android/gradlew: Command failed with exit code 1
And if I run cordova run android after that, it still tells the block of Could not resolve com.android.tools.build:gradle:2.2.0. error.
The same thing seemed not happening under windows.
I've search around the web with no luck. Anyone knows how?
The below article tells how to import a ssl certificate of a secific site to java environment.
https://github.com/meteor/meteor/issues/6362#issuecomment-262684912
Step 1 : Download the certificate
Download this file.
Or the same on Mozilla Firefox :
Go to https://repo1.maven.org
Click on the green padlock at the left of adress bar.
Click on Details.
Click on View certificate.
Click on Details.
Click on Export.
Export file to "X.509 Certificate (PEM) (*.crt; *.pem)"
Step 2 : Add the certificate to default java keystore
sudo keytool -import -alias MavenRepo -keystore $JAVA_HOME/jre/lib/security/cacerts -file /PATH/TO/YOUR/EXPORTED/FILE.crt
Your $JAVA_HOME variable is normally declared in your .bashrc file, so you can use this command just replacing the /PATH/TO/YOUR/EXPORTED/FILE parameter.
PS : The default password of java keystore is : changeit
It get the procedure a bit forward, but still not solved.
Finally I solved the problem by reinstall the OS.
It seemed it is not relavent with ubuntu or linux itself, codova and android studio worked well in ubuntu after I reinstall the OS.

Ionic android build issue in linux

I have successfully installed cordova v6.3.1, ionic v2.0.0 and Android Studio
OS: Virtualbox (Xubuntu)
when i run ionic build android
I get below error:
BUILD FAILED
Total time: 7.749 secs
Error: /var/lib/mymachine/ionic-01/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'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:2.1.0.
Required by:
:android:unspecified
> Could not resolve com.android.tools.build:gradle:2.1.0.
> Could not get resource 'https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.1.0/gradle-2.1.0.pom'.
> org.apache.http.ssl.SSLInitializationException: /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/security/cacerts (No such file or directory)
> Could not resolve com.android.tools.build:gradle:2.1.0.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.0/gradle-2.1.0.pom'.
> org.apache.http.ssl.SSLInitializationException: /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/security/cacerts (No such file or directory)
Few post suggested to install Android support repository and Google Repository. I installed it. But still i face the face problem.
I had the similar problem. In my case it was simple java webapp which was using gradle. This project used java 6. My java 6 was not installed properly. Thats why I had the below issue.
gradle was not able to find the /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/security/cacerts
This is a symlink to another file which was not present.
So I removed my jdk and re-installed it. That solved the problem.

Categories

Resources