Issue
I want to build an app bundle for my flutter project, however I get an exception every time. Here is the terminal message:
💪 Building with sound null safety 💪
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: /Users/ahmet/Documents/dev/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_flutter_android-2.1.10/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/ahmet/Documents/dev/flutter/.pub-cache/hosted/pub.dartlang.org/libphonenumber-2.0.2/android/src/main/java/com/codeheadlabs/libphonenumber/LibphonenumberPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/ahmet/Documents/dev/flutter/.pub-cache/hosted/pub.dartlang.org/location-4.4.0/android/src/main/java/com/lyokone/location/FlutterLocation.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
ERROR:/Users/ahmet/.gradle/caches/transforms-3/df9b61f0f2e66d13a646c74f00bdcc6f/transformed/jetified-bcprov-jdk15on-1.65.jar: R8: Type org.bouncycastle.jcajce.provider.asymmetric.edec.KeyFactorySpi$Ed25519 is defined multiple times: /Users/ahmet/.gradle/caches/transforms-3/df9b61f0f2e66d13a646c74f00bdcc6f/transformed/jetified-bcprov-jdk15on-1.65.jar:META-INF/versions/11/org/bouncycastle/jcajce/provider/asymmetric/edec/KeyFactorySpi$Ed25519.class, /Users/ahmet/.gradle/caches/transforms-3/df9b61f0f2e66d13a646c74f00bdcc6f/transformed/jetified-bcprov-jdk15on-1.65.jar:org/bouncycastle/jcajce/provider/asymmetric/edec/KeyFactorySpi$Ed25519.class
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:minifyReleaseWithR8'.
> com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: /Users/ahmet/.gradle/caches/transforms-3/df9b61f0f2e66d13a646c74f00bdcc6f/transformed/jetified-bcprov-jdk15on-1.65.jar:META-INF/versions/11/org/bouncycastle/jcajce/provider/asymmetric/edec/KeyFactorySpi$Ed25519.class
* 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.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)
* 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
BUÄ°LD FAILED in 6m 10s
Running Gradle task 'bundleRelease'... 374,1s
┌─ Flutter Fix ──────────────────────────────────────────────────────────────┐
│ [!] The shrinker may have failed to optimize the Java bytecode. │
│ To disable the shrinker, pass the `--no-shrink` flag to this command. │
│ To learn more, see: https://developer.android.com/studio/build/shrink-code │
└────────────────────────────────────────────────────────────────────────────┘
Gradle task bundleRelease failed with exit code 1
I assume the error is related to some kind of Java stuff because of the KeyFactorySpi$Ed25519.class
but I can not end up with something meaningful.
pubspec.yaml
name: fortinayn
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.7.1+27
environment:
sdk: '>=2.12.0 <3.0.0'
dependencies:
flutter:
sdk: flutter
# carousel_pro: ^1.0.0 (outdated)
carousel_slider: ^4.1.1
card_swiper: ^2.0.4
location: ^4.4.0
google_maps_flutter: ^2.1.12
flutter_google_places: ^0.3.0
sleek_circular_slider: ^2.0.1
geolocator: ^9.0.1
# geocoder: ^0.2.1 (outdated)
http: ^0.13.5
provider: ^6.0.3
# progress_dialog: ^1.2.4
progress_dialog_null_safe: ^1.0.7
shared_preferences: ^2.0.15
image_picker: ^0.8.5+3
flutter_rating_bar: ^4.0.1
url_launcher: ^6.1.5
flutter_barcode_scanner: ^2.0.0
onesignal_flutter: ^3.4.1
#search_map_place: ^0.3.0
pattern_formatter: ^2.0.0
pin_code_fields: ^7.4.0
webview_flutter: ^3.0.4
# splashscreen: ^1.3.5 (outdated)
easy_splash_screen: ^1.0.4
share: ^2.0.4
photo_view: ^0.14.0
fl_chart: ^0.55.1
# flutter_facebook_login: ^3.0.0 (discontinued)
flutter_facebook_auth: ^4.4.1+1
firebase_auth: ^3.6.4
google_sign_in: ^5.4.1
# apple_sign_in: ^0.1.0 (discontinued)
sign_in_with_apple: ^4.1.0
intl_phone_number_input: ^0.7.0+2
qr_flutter: ^4.0.0
flutter_pdfview: ^1.2.3
path_provider: ^2.0.11
# firebase_analytics: ^5.0.11
flutter_localizations:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.5
flutter_staggered_grid_view: ^0.6.2
cached_network_image: ^3.2.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: ^0.10.0
flutter_icons:
android: true
ios: true
image_path: "dev_assets/logo.png"
adaptive_icon_background: "#FC7F23"
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/images/
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
fonts:
- family: Roboto
fonts:
- asset: assets/fonts/Roboto-Regular.ttf
- asset: assets/fonts/Roboto-Italic.ttf
style: italic
- asset: assets/fonts/Roboto-Bold.ttf
weight: 700
- asset: assets/fonts/Roboto-Black.ttf
weight: 900
- family: Alata
fonts:
- asset: assets/fonts/Alata-Regular.ttf
- family: MyFlutterApp
fonts:
- asset: assets/fonts/MyFlutterApp.ttf
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
build.gradle
buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
jcenter()
maven {url 'https://plugins.gradle.org/m2/'}
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1,0.99.99]'
classpath 'com.google.gms:google-services:4.3.5'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app/build.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 33
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.mcc.fortinaynn"
minSdkVersion 20
targetSdkVersion 30
multiDexEnabled true
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.facebook.android:facebook-android-sdk:latest.release'
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.google.gms.google-services'
flutter doctor -v
ahmet@192 ~ % flutter doctor -v
[✓] Flutter (Channel stable, 3.3.3, on macOS 13.0 22A5365d darwin-x64, locale
tr-TR)
• Flutter version 3.3.3 on channel stable at
/Users/ahmet/Documents/dev/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 18a827f393 (8 days ago), 2022-09-28 10:03:14 -0700
• Engine revision 5c984c26eb
• Dart version 2.18.2
• DevTools version 2.15.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/ahmet/Library/Android/sdk
• Platform android-33, build-tools 33.0.0
• ANDROID_HOME = /Users/ahmet/Library/Android/sdk
• Java binary at: /Applications/Android
Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.
[!] Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS
development.
Download at: https://developer.apple.com/xcode/download/
Or install Xcode via the App Store.
Once installed, run:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch
• CocoaPods version 1.11.3
[✓] Android Studio (version 2021.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build
11.0.13+0-b1751.21-8125866)
[✓] VS Code (version 1.71.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.50.0
[!] Connected device
! No devices available
[✓] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 2 categories.
Any help will be appreciated. Thanks.
Solution
I solved the issue. implementation 'com.facebook.android:facebook-android-sdk:latest.release'
was causing this problem. I assume that it conflicts with the flutter_facebook_auth
package added via pubspec.yaml
file. I removed this dependency and now everything is just working fine.
Answered By - Ahmet Özrahat
Answer Checked By - Marilyn (JavaFixing Volunteer)