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

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.

Related

There is a error in android studio but same code working on flutlab.io

i tried to run a basic code in android studio. but it showing error. but the same code successfully compiled on flutlab.io
here is the error message.
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
Could not open settings generic class cache for settings file 'C:\Users\HP\AndroidStudioProjects\helloapp\android\settings.gradle' (C:\Users\HP\.gradle\caches\6.7\scripts\1fnwrr8g4rohfp291nvlxj5qe).
> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 60
* 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 2s
Exception: Gradle task assembleDebug failed with exit code 1
i'm new to android studio. so please tell what's the wrong here.
Try to use JAVA SDK 15.
First remove your old JDK, and download & install Java JDK 15 from here.
Then, in Android Studio, change the path to the Java JDK so that it matches the latest install. Finally, restart Android Studio to apply the changes.

Error while launching flutter Application

I am new to flutter development so i followed the google getting started with flutter page as is.
When i used the andriod studio (or) visual studio to create a demo flutter application and try to run it on a emulator i get the below lines .
*Launching lib\main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
What went wrong:
Could not open settings generic class cache for settings file 'D:\personalnicknacks\softwares\flutter\hello_app_world\android\settings.gradle' (C:\Users\ing12703.gradle\caches\6.7\scripts\1fnwrr8g4rohfp291nvlxj5qe).
BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 60
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 1s
Exception: Gradle task assembleDebug failed with exit code 1*
I have the tried following things.
1)Ensured my JAVA_HOME environment is correct pointing.
2)used the latest java version 16.0
3)used the andriod studio to install the flutter plugins.
4)have also tried to install the gradel manually using the page https://gradle.org/install/#manually
5)now even my gradel output is correct
C:\Users\ing12703>gradle -v
Welcome to Gradle 7.0.2!
Here are the highlights of this release:
File system watching enabled by default
Support for running with and building Java 16 projects
Native support for Apple Silicon processors
Dependency catalog feature preview
For more details see https://docs.gradle.org/7.0.2/release-notes.html
Gradle 7.0.2
Build time: 2021-05-14 12:02:31 UTC
Revision: 1ef1b260d39daacbf9357f9d8594a8a743e2152e
Kotlin: 1.4.31
Groovy: 3.0.7
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 16.0.1 (Oracle Corporation 16.0.1+9-24)
OS: Windows 10 10.0 amd64
The suggestion I got online was to downgrade the JDK to say a 12 or so but is that the only viable option or am i missing something?
OK another thing i did try now was to indeed delete JAVA SDK 16 and install the JAVA SDK 15 and it works like a charm.
However I still wonder how do we know when to upgrade to latest JAVA SDK? is some compatibility list of SDK and their respective versions available in flutter documentation?

JDK installation not found by flutter starter app

I have cloned the flutter repo and installed the Android SDK command-line tools, setting them up in $HOME/Android. I then made flutter aware of the SDK installation by setting $ANDROID_HOME to $HOME/Android. Things seem to have worked out, with <path-to-flutter> doctor finding
Android SDK
my Java JDK 8 installation (openjdk-8-jdk package on Ubuntu 18.04), and
a connected Android phone with USB debugging
I am now trying to follow the test-run instructions for building a first app on the command line. <path-to-flutter> create myapp works and produces a myapp directory. I then try to run the resulting starter app:
cd myapp
~/myapp$ ANDROID_HOME=~/Android JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 <path-to-flutter> run
This results in the following error:
Launching lib/main.dart on ONEPLUS A6013 in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Kotlin could not find the required JDK tools in the Java installation '/usr/lib/jvm/java-8-openjdk-amd64/jre' used by Gradle. Make sure Gradle is running on a JDK, not JRE.
* 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 10s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 11.0s
Exception: Gradle task assembleDebug failed with exit code 1
I have seen this issue discussed before, but none of those replies seem to address it (in my case, at least). You can see from the command that I am exporting the right $JAVA_HOME, and besides, running
./android/gradlew build
inside the myapp directory does work:
~/myapp$ ./android/gradlew build
> Task :buildEnvironment
------------------------------------------------------------
Root project
------------------------------------------------------------
classpath
No dependencies
A web-based, searchable dependency report is available by adding the --scan option.
BUILD SUCCESSFUL in 319ms
1 actionable task: 1 executed
So this seems to be specific to flutter itself somehow, rather than gradle.
It turns out this must have been a path issue. The Flutter starter app builds (and pops up on my device) after inserting the following snippet in a file sourced in my profile (my .bashrc):
# Java
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
# Android
export ANDROID_HOME=${HOME}/Android
export ANDROID_SDK_ROOT=${HOME}/Android
# Flutter
export FLUTTER_HOME=${HOME}/repos/flutter
PATH=${FLUTTER_HOME}/bin:$PATH; export PATH
you can do like this -->
sudo apt-get remove --auto-remove openjdk*
sudo apt-get install openjdk-8-jre
now goto to home and visible your hidden folder by pressing ctrl+h
Now open .bashrc or your .rc
paste these on last
export PATH="$PATH:/snap/bin/flutter/bin"
export PATH="$PATH:/usr/bin/java"
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre
export ANDROID_SDK_ROOT=/home/<YOUR USER NAME>/Android/Sdk
then run
source ~/bashrc
flutter doctor -v

ProcessException: Process "C:\Users\Ayushi Sharma\attempt\android\gradlew.bat" exited abnormally:

Error running Gradle:
ProcessException: Process "C:\Users\Ayushi Sharma\attempt\android\gradlew.bat" exited abnormally:
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Users\Ayushi Sharma\attempt\android\app\build.gradle' line: 24
What went wrong:
A problem occurred evaluating project ':app'.
Failed to apply plugin [id 'com.android.application']
Minimum supported Gradle version is 5.4.1. Current version is 5.1.1. If using the gradle wrapper, try editing the
distributionUrl in C:\Users\Ayushi Sharma\attempt\android\gradle\wrapper\gradle-wrapper.properties to gradle-5.4.1-all.zip
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 0s
Command: C:\Users\Ayushi Sharma\attempt\android\gradlew.bat app:properties
Please review your Gradle project setup in the android/ folder.
Need help!!!!!!
To resolve, change com.android.tools.build:gradle:3.2.1 => com.android.tools.build:gradle:3.3.2, run flutter clean and try the build again.
According to the Gradle_release_note, the current (July 2019) version of the plugin and gradle are 3.4.2 and 5.1.1 respectively. I don't know if Flutter officially supports this version, although it seems to work on my project here and a clean build is markedly faster. The release notes cover some of the changes from 3.2.x => 3.3.x => 3.4.x.
To upgrade to the current version, edit android\gradle\wrapper\gradle-wrapper.properties to source Gradle 5.1.1, and then you're able to upgrade the Gradle plugin to 3.4.2.
Note that once gradle 5.1.1 is being used, you can still set the plugin version back to 3.2.1 to reproduce the issue.

Flutter: build error when adding "image_cropper" and "contacts_service" packages

I can successfully build and run a fresh new flutter project. But when I add both image_cropper: ^1.0.0 and contacts_service: ^0.2.4 packages to pubspec.yaml and run flutter packages get, I cannot build the project anymore, and get this build error:
D8: Program type already present: android.support.v4.app.INotificationSideChannel
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\2.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\3.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\4.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\5.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\6.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\7.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\8.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\9.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\10.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\11.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\12.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\13.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\14.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\15.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\16.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\17.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\18.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\19.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\20.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\21.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\22.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\23.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\24.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\25.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\26.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\27.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\28.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\29.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\30.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\31.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\32.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\33.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\34.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\35.jar, E:\Projects\flutter\hello\build\app\intermediates\transforms\dexBuilder\debug\36.jar
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: android.support.v4.app.INotificationSideChannel
* 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 19s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https:///CP92wY for more information on the problem and how to fix it.
*******************************************************************************************
Finished with error: Gradle task assembleDebug failed with exit code 1
I do not understand this error very well, but it seems that there is a naming conflict between these two packages (because of duplicate_classes in the error text). Is there any workaround for this?
Note that this error does not happen with any other pair of packages for me.
In build.gradle defaultConfig add multiDexEnabled true
This was an Android X compatibility issue. I could get it fixed by following the steps mentioned here, but in summary:
First make sure that compileSdkVersion is at least 28 in app/build.gradle. This property controls the version of the Android SDK that Gradle uses to build your APK. It doesn’t affect the minimum SDK version that your app can run on.
Right click on android directory of flutter project and open it using this menu: Flutter > Open android module in android studio
In the newly opened project, from menus select Refactor > Migrate to AdnroidX
Close the project and open your flutter project again.