Problems when building in ionic cordova android - ionic-framework

What went wrong:
A problem occurred configuring project ':CordovaLib'.
No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 1s
cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring project ':CordovaLib'.
No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 1s
[ERROR] An error occurred while running subprocess cordova.
cordova build android --release exited with exit code 1.
Re-running this command with the --verbose flag may provide more information

I had the same problem and I tried many things.
I updated everything I could in Android Studio and SDK Manager. Gradle and Android Gradle Plugin got updated in the process - but this didn't help.
Then I updated cordova (from 8.1.2 to 9.0.0) and cordova-android (to 8.0.0) to latest versions - but this in itself didn't help either.
Only removing and re-adding android platform finally solved the issue:
npm install -g cordova#latest
npm install cordova-android#latest --save
ionic cordova platform remove android
ionic cordova platform check android
ionic cordova platform add android

Upgrade your version of cordova-android to the latest 7.1.3 and it will use the gradle plugin for android v3.3 which no longer checks for mips abi in the NDK.
also make sure to set the ANDROID_NDK_HOME environment variable to the location of your NDK.

Did two steps
1.Set ANDROID_HOME_NDK
2.Updated as answered by zbyl
npm install -g cordova#latest
npm install cordova-android#latest --save
ionic cordova platform remove android
ionic cordova platform check android
ionic cordova platform add android
And it worked.

Related

ionic - BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 63

I am working ionic angular
while run this comment cordova build android --release
am getting this error
PS C:\Users\Nirali\Documents\nmhapp> cordova build android --release
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=C:\Users\Nirali\AppData\Local\Android\Sdk (recommended setting)
ANDROID_HOME=C:\Users\Nirali\AppData\Local\Android\Sdk (DEPRECATED)
Using Android SDK: C:\Users\Nirali\AppData\Local\Android\Sdk
FAILURE: Build failed with an exception.
What went wrong:
Could not open settings generic class cache for settings file 'C:\Users\Nirali\Documents\nmhapp\platforms\android\settings.gradle' (C:\Users\Nirali.gradle\caches\7.5.1\scripts\7e15adv812akcxkuh6ist7or8).
BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 63
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.5.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 771ms
Command failed with exit code 1: C:\ProgramData\chocolatey\bin\gradle.EXE -p C:\Users\Nirali\Documents\nmhapp\platforms\android wrapper -b C:\Users\Nirali\Documents\nmhapp\platforms\android\wrapper.gradle
PS C:\Users\Nirali\Documents\nmhapp>
How to fix this issue.
Upgrade to a snapshot of gradle 7.6, or wait for the 7.6 release
https://services.gradle.org/distributions-snapshots/gradle-7.6-20221021231540+0000-bin.zip
Solved this issue by opening my project in Android Studio, and it began building Gradle, then it recommended I upgrade Gradle. After the upgrade in Android Studio, I can now run my app.
Windows user:
Go to C:\Users\arpan.gradle\caches and delete all the gradle cache.
then,
Go to "C:\Program Files\Android\Android Studio" there you will see jbr and jre folder then copy the content of jbr and paste the content into jre folder.
ss:
and run flutter doctor again and run your App.

Flutter project is not running on physical device

When I make a build of flutter project on windows(chrome) it run successfully but when i run on my phone it gives this error
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Failed to install the following SDK components:
tools Android SDK Tools
build-tools;29.0.2 Android SDK Build-Tools 29.0.2
The SDK directory is not writable (C:\Users\Cantt)
* 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
BUILD FAILED in 1m 44s
Exception: Gradle task assembleDebug failed with exit code 1
I installed the Andriod SDK platform 32 and 31. please help how to fix this issue.
Open android studio and go to SDK manager
Check SDK platforms API level 28, 29, 30
Then apply and ok
Then
flutter clean
flutter pub get
flutter run
Try the following on Android Studio.
Help>Find Action and then search for each and select:
clean project
rebuild project
Invalidate caches
Then restart Android Studio.
This should fix the issue.

I am using VS Code for Flutter. I have downloaded Android SDK platform 30. But it tells me to download 29 version

I am new to flutter. Here is a list of available tools on SDK Manager -
As you can see I've downloaded the tools. But debugging in the ide shows an error and tells me download a tools that are not installed -
'''
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Failed to install the following SDK components:
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
platforms;android-29 Android SDK Platform 29
Install the missing components using the SDK manager in Android Studio.
2
* 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
BUILD FAILED in 51s
[!] Gradle threw an error while downloading artifacts from the network. Retrying to download...
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
'''
Please help me out.
There seemed to be errors in installing certain dependencies ( sdk 30 ). Might be a technical glitch. Try installing again using flutter doctor.
I think you have to accept the licenses before building.
Try this command in the terminal
flutter doctor --android-licenses
Try flutter doctor command in your terminal. which helps us diagnose issues with your setup
flutter doctor
to learn more https://stackoverflow.com/a/55641042/7904389
Please share the android/app/build.gradle, it is probably targeting API level 29 (targetSdkVersion 29 and compileSdkVersion 29). Change them to 30 or download the API level 29 SDKs.
If it still doesn't work after that, the SDK might be missing, go to the ANDROID_HOME directory and ensure it contains an sdk directory with the stuff you want.
I couldn't figure out what the error was, but creating a new project worked for me.

flutter project cant run in visual studio

FAILURE: Build failed with an exception.
What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
platforms;android-28 Android SDK Platform 28
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: /usr/lib/android-sdk
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
BUILD FAILED in 1m 4s
Exception: Gradle task assembleDebug failed with exit code 1
You have to accept licences before building app in visual studio.
This is only one time configuration to be done. Have you done it?
If not then run following command:
In Windows
%ANDROID_HOME%/tools/bin/sdkmanager --licenses
In Linux
yes | ~/Android/Sdk/tools/bin/sdkmanager --licenses
In macOS
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home
yes | ~/Library/Android/sdk/tools/bin/sdkmanager --licenses
If still problem persist then let me know.

ionic 4 beta No installed build tools found

I’m trying to compile android apk, but I get the error “No installed build tools found.”
$ ionic cordova build android
Error:
...
Android Studio project detected
Preparing Firebase on Android
ANDROID_HOME=/usr/lib/android-sdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle
studio
Subproject Path: CordovaLib
Subproject Path: app
FAILURE: Build failed with an exception.
* Where:
Script '/home/ubuntu/lapp/platforms/android/CordovaLib/cordova.gradle' line: 68
* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> No installed build tools found. Install the Android build tools version 19.1.0 or higher.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
/home/ubuntu/lapp/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* Where:
Script '/home/ubuntu/lapp/platforms/android/CordovaLib/cordova.gradle' line: 68
* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> No installed build tools found. Install the Android build tools version 19.1.0 or higher.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
[ERROR] An error occurred while running subprocess cordova.
cordova build android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
Environment Variables:
export ANDROID_HOME=/home/ubuntu/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
$ echo $ANDROID_HOME
/home/ubuntu/Android/Sdk
$ echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle
$ echo $PATH
...
/usr/lib/jvm/java-8-oracle/bin:
/usr/lib/jvm/java-8-oracle/db/bin:
/usr/lib/jvm/java-8-oracle/jre/bin:
/home/ubuntu/Android/Sdk/platform-tools:
/home/ubuntu/Android/Sdk/tools:
/home/ubuntu/Android/Sdk/build-tools:
/home/ubuntu/Android/Sdk/tools/bin:
/home/ubuntu/Android/Sdk/emulator
.
$ ionic info
Ionic:
ionic (Ionic CLI) : 4.6.0 (/usr/local/lib/node_modules/ionic)
Ionic Framework : #ionic/angular 4.0.0-rc.0
#angular-devkit/build-angular : 0.11.4
#angular-devkit/schematics : 7.1.4
#angular/cli : 7.1.4
#ionic/angular-toolkit : 1.2.2
Cordova:
cordova (Cordova CLI) : not installed
Cordova Platforms : not available
Cordova Plugins : not available
System:
Android SDK Tools : 26.1.1 (/home/ubuntu/Android/Sdk)
NodeJS : v10.14.2 (/usr/local/bin/node)
npm : 6.4.1
OS : Linux 4.15
I try:
ionic cordova platform remove android
ionic cordova platform add android
After all this, I installed all the SDKs from Android 4.3 and all Android SDK build-tools from 19.0.3, but even this did not help.
Ps: No matter how I try to set the path to ANDROID_HOME (~/.bash_profile, ~/.bashrc), but still takes ANDROID_HOME=/usr/lib/android-sdk
any ideas?
1) Terminal as root
$ sudo -s
2) Add path to ~/.bash_profile or ~/.bashrc
3) Done!