After updating to latest #ionic/cli version I started receiving this error, after I try to do this command : ionic cap run android -l --external
FAILURE: Build failed with an exception.
[capacitor]
[capacitor] * Where:
[capacitor] Build file 'E:\laragon\www\ProjekatA\frontend\android\app\build.gradle' line: 1
[capacitor]
[capacitor] * What went wrong:
[capacitor] A problem occurred evaluating project ':app'.
[capacitor] > Failed to apply plugin 'com.android.internal.application'.
[capacitor] > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
[capacitor] You can try some of the following options:
[capacitor] - changing the IDE settings.
[capacitor] - changing the JAVA_HOME environment variable.
[capacitor] - changing `org.gradle.java.home` in `gradle.properties`.
When I run command ,everything works fine, app gets served but after this line error is presented :
capacitor.cmd run android --no-sync --target Pixel_3_API_30
Also this is line executed before error presents itself in terminal :
E:\laragon\www\ProjekatA\frontend\android>"C:\Program Files\Java\jre1.8.0_291/bin/java.exe" "-Xmx64m" "-Xms64m" "-Dorg.gradle.appname=gradlew" -classpath "E:\laragon\www\ProjekatA\frontend\android\\gradle\wrapper\gradle-wrapper.jar" org.gradle.wrapper.GradleWrapperMain "assembleDebug"
I change gradle JDK to this :
Gradle JDK
But the error is still present.
Also this is what I have installed on system :
Java JRE version
Maybe I need to upgrade this? How and to which version if that is the case.
Thanks in advance!
Edit : When I build my app from Android Studio it works fine, it fails only when using ionic/cli.
I did as this guy suggested ##44_Chintan Vasoya, but I didn't delete android file because I already had some configuration set up.
I just uninstalled Java then installed JDK 11 and it worked without a problem.
Hope this helps somebody with same problem.
SOLVED!
delete your android folder and then upgrade jre and JDk .
when upgradation process complete then try to rebuild
i think that solve your problems.
Related
I'm trying to build an hybrid app using the cordova cli using command
cordova build android
But it fails with error (complete log) :
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=undefined (DEPRECATED)
Using Android SDK: /usr/lib/android-sdk
Subproject Path: CordovaLib
Subproject Path: app
FAILURE: Build failed with an exception.
* Where:
Script '/home/iam/Projects/lave/platforms/android/CordovaLib/cordova.gradle' line: 75
* What went wrong:
A problem occurred evaluating script.
> No usable Android build tools found. Highest 30.x installed version is 27.0.1; Recommended version is 30.0.3.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.1.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 1s
I have followed this step thinking it would solve the issue but problem remain and I get same error even after installing the packages.
Actual image from my Android SDK Settings :
It's worth mentioning that I have installed Android-SDK using apt and afterwards I have set up environment path with this command :
export ANDROID_HOME="/usr/lib/android-sdk/"
export PATH="${PATH}:${ANDROID_HOME}tools/:${ANDROID_HOME}platform-tools/"
After installing the packages in Android-SDK,I restarted Ubuntu thinking it would fix the problem. But still receives same error message when trying to build. Am I missing something?
From the error logs I think it cannot find your ANDROID_SDK_ROOT, please check if it is set like this in your environment variables:
export ANDROID_SDK_ROOT=/Users/[USERNAME]/Library/Android/sdk
export PATH=$ANDROID_SDK_ROOT/tools:$PATH
I believe you should also set the path to your build- and platform tools like so (for your versions/paths of course):
export PATH=${PATH}:/Users/[USERNAME]/Library/Android/sdk/build-tools/33.0.0uild-tools/30.0.3
export PATH=${PATH}:/Users/[USERNAME]/Library/Android/sdk/platform-tools
Can you check that you have set al of these, or something similar? Also be aware that you may have to fix something in your build tools (this is the case for several versions, I don't know of the top of my head which ones, so it's worth to check): Android Studio error "Installed Build Tools revision 31.0.0 is corrupted"
I want to offer the solution that worked for me for Ubuntu. I suddenly remembered I had written a tutorial for mac here on SO. Remembering this made me realize I forgot to set the JAVA_HOME which Cordova looks for while Checking Java JDK and Android SDK versions. Also, ANDROID_HOME is completely obsolete and deprecated. Set the same path for ANDROID_HOME to ANDROID_SDK_ROOT (same thing).
export PATH=$PATH:$ANDROID_HOME/platform-tools
export ANDROID_SDK_ROOT=/home/iam/Android/Sdk
export JAVA_HOME=/opt/android-studio-2021.3.1/android-studio/jre
Create a bash profile and paste the above codes then save
sudo gedit ~/.bash_profile
Run this
source ~/.bash_profile
Now when running
cordova build android --prod
Gradle should be able to configure for the first time and do the necessary tasks and then boom
BUILD SUCCESSFUL in 7m 4s
48 actionable tasks: 48 executed
After updating to React Native 0.68, I got this error when executing ./gradlew :
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/username/path/projectname/android/app/build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.application'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.properties`.
On MacOS, you just need to install the Java Development Kit recommended by React Native
brew tap homebrew/cask-versions
brew install --cask zulu11
I guess you need to do choco install -y nodejs-lts openjdk11 on Windows by I haven't tested it.
Source: https://reactnative.dev/docs/environment-setup#installing-dependencies
While deploying ionic app to android it's giving error as follows, It seems gradle is missing but when I check cordova requirements the gradle is installed. What's happening here?
auli#auli-H81H3-M4:~/ionic/iProjects/gplusauth$ cordova run android
ANDROID_HOME=/home/auli/Android/Sdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle
FAILURE: Could not determine which tasks to execute.
* What went wrong:
Task 'wrapper' not found in root project 'android'.
* Try:
Run gradle tasks to get a list of available tasks.
BUILD FAILED
Total time: 1.385 secs
Error: /usr/share/gradle/bin/gradle: Command failed with exit code 1
and here is cordova requirements:
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-26,android-25,android-24,android-23,android-22,android-21,android-20,android-19,android-18,android-17,android-16,android-15,android-14
Gradle: installed /usr/share/gradle/bin/gradle
I solved this issue with upgrading gradle to latest version.
https://www.vultr.com/docs/how-to-install-gradle-on-ubuntu-16-10
I am new to mobile app technology. I am trying to configure my system (in Ubuntu 16.04) for apk installation. After I run the following command in terminal
sudo ionic cordova run android
I got the following error
:CordovaLib:compileDebugRenderscript FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':CordovaLib:compileDebugRenderscript'.
> llvm-rs-cc is missing
I searched about it , but I couldn't find an accurate answer.
Thanks in advance.
So I found myself the solution to this problem. Its because of the version difference of build-tools inside my sdk folder. Updating to latest build-tools version will solve this problem.
After I created new project using cordova and added android platform, I got this error while building the project for first time
Download https://repo1.maven.org/maven2/com/android/tools/build/gradle-core/1.5.0/gradle-core-1.5.0.jar
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 download artifact 'gradle-core.jar (com.android.tools.build:gradle-core:1.5.0)'
> Failed to move file 'C:\Users\nienb\AppData\Local\Temp\gradle_download4337332192574000593bin' into filestore at 'C:\Users\nienb\.gradle\caches\modules-2\files-2.1\com.android.tools.build\gradle-core\1.5.0\70915a3f0ef4243d4630ea23219f5445fac82700\gradle-core-1.5.0.jar'
any one could help ?
I had the same issue developing on Windows after upgrading to Cordova 6. Run cmd as administrator and it resolved my issues.
Had the same problem. I noticed that when re-running the build, the file that the build got stuck on before would suddenly transfer just fine, but then the build failed on a different file.
I re-ran the build 4 or 5 times, and eventually it worked. I was running this in an administrator command prompt; not sure if that was important.
I solve my problem by downgrade gradle version from 1.5 to 1.3, both on main app and cordova plugin, but still looking for some official solutions