Closed reimager closed 5 months ago
same question,I think the requirement of VERSION_17 is very unreasonable
I get this error even when building on machine with Java 17 (openjdk 17.0.9) installed.
Changing the file ~/.pub-cache/hosted/pub.dev/file_saver-0.2.9/android/build.gradle
according to the first message fixes the issue.
Hi there, was there any other resolution to this? For me the change above (targetCompatibility JavaVersion.VERSION_1_8 ) worked, but since is inside the pub cache, I'm assuming any pub operation might overwrite it, correct?
I also had to update my compileSdkVersion from flutter.compileSdkVersion to 34 to eliminate an warning/error on build (which still opens the app) and kotlin to latest (not really sure if connected but all happened at the same time)
Hi there, was there any other resolution to this? For me the change above (targetCompatibility JavaVersion.VERSION_1_8 ) worked, but since is inside the pub cache, I'm assuming any pub operation might overwrite it, correct?
I also had to update my compileSdkVersion from flutter.compileSdkVersion to 34 to eliminate an warning/error on build (which still opens the app) and kotlin to latest (not really sure if connected but all happened at the same time)
I used the flutter run command to get rid of the error brought by version 17
I got it fixed by updating Android Studio.
Before doing anything, launch Android Studio and Click Help
> About
and take a note of the Runtime version
. For me, it was a JDK 11
version.
After updating to 2023.3.1 the same About page showed JDK 17
and the Android builds ran fine.
Why are the PRs not merged?
Is there an alternative package?
Same error when running flutter build appbundle
`* What went wrong: Execution failed for task ':file_saver:compileReleaseJavaWithJavac'.
error: invalid source release: 17 `
Tried all the solutions above.
The same error for indirect dependency for this package https://pub.dev/packages/to_csv
POTENTIAL FIX:
Solution steps:
flutter build appbundle
.Started working with this
It works. @SzymonDziak
POTENTIAL FIX:
- The problem lies within the Android inner files, not the package itself.
Solution steps:
- Visit the official website and download the latest version of Android Studio. link
- Once installed, execute the command
flutter build appbundle
.- After following these steps, the issue should be resolved, and everything should function properly.
The potential fix does not work for CI/Github aAtions
Do we have a fix yet guys? Thank you!
Is there any fix yet for CI/CD?
You can use my fork
pubspec.yaml
file_saver:
git:
url: https://github.com/adrianvintu/file_saver.git
ref: VERSION_1_8
@incrediblezayed Can u please upgrade the lib? thanks
The correct way is remove these two lines;
android { namespace "com.incrediblezayed.file_saver" compileSdk 34
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
minSdkVersion 19
}
// compileOptions {
// targetCompatibility JavaVersion.VERSION_18
// sourceCompatibility JavaVersion.VERSION_18
// }
}
The correct way is remove these two lines;
android { namespace "com.incrediblezayed.file_saver" compileSdk 34
sourceSets { main.java.srcDirs += 'src/main/kotlin' } defaultConfig { minSdkVersion 19 } // compileOptions { // targetCompatibility JavaVersion.VERSION_18 // sourceCompatibility JavaVersion.VERSION_18 // }
}
The correct way is remove these two lines;
android { namespace "com.incrediblezayed.file_saver" compileSdk 34
sourceSets { main.java.srcDirs += 'src/main/kotlin' } defaultConfig { minSdkVersion 19 } // compileOptions { // targetCompatibility JavaVersion.VERSION_18 // sourceCompatibility JavaVersion.VERSION_18 // }
}
It's work for me
same here
For me it helped to fork the repository and adjust content in following files (just place there same versions for java, kotlin and etc.): gradle-wrapper.properties build.gradle gradle.properties
I'm so sorry guys, if it is very urgent for everyone you guys can go ahead & use the package form the PR created by a contributor in issue #87 this will fix the issue, & further discussion of this issue will take place in issue #87 so follow up in that.
It doesn't work with JavaVersion.VERSION_1_8
now...
Can we just stick with the Flutter recommended. It's annoying, this is the only package wasting my time.
You may use this until we have an update from the developer
file_saver:
git:
url: https://github.com/adrianvintu/file_saver.git
ref: 0aae1be4df8d1c30f267e080d9bf6be9bd9a4147
Is there any fix yet for CI/CD?
this might fix CI/CD https://stackoverflow.com/a/78086249/8623062
for gh actions
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
cache: 'gradle'
check-latest: true
POTENTIAL FIX:
- The problem lies within the Android inner files, not the package itself.
Solution steps:
- Visit the official website and download the latest version of Android Studio. link
- Once installed, execute the command
flutter build appbundle
.- After following these steps, the issue should be resolved, and everything should function properly.
The potential fix does not work for CI/Github aAtions
yes, man I am facing same issue means i am using github CI/CD to autogenerate APk in github actions but some @plus_plugins like connectiivty_plus, share_plus are not working and you wll always get "invalid source release: 17" or similar ones .
You can also use something like below, to force the VERSION_17 build
buildscript {
ext.kotlin_version = '1.9.20'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.2'
classpath 'com.google.gms:google-services:4.3.15'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
// When upgrading to AGP8, some projects do not have a namespace set, so we add one
// https://stackoverflow.com/questions/76108428/how-do-i-fix-namespace-not-specified-error-in-android-studio
subprojects {
afterEvaluate { project ->
if (project.hasProperty('android')) {
project.android {
if (namespace == null) {
namespace project.group
}
}
}
}
subprojects {
afterEvaluate {
if (project.plugins.hasPlugin("com.android.application")
|| project.plugins.hasPlugin("com.android.library")) {
// https://github.com/matanshukry/flutter_google_places_sdk/issues/71
if (project.name == "flutter_google_places_sdk_android") {
project.android.compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}
}
}
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
}
}
rootProject.buildDir = '../build'
subprojects {
// https://github.com/matanshukry/flutter_google_places_sdk/issues/71
afterEvaluate {
if (project.plugins.hasPlugin("com.android.application")
|| project.plugins.hasPlugin("com.android.library")) {
if (project.name == "flutter_google_places_sdk_android") {
project.android.compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}
}
}
}
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
any update
Is there any fix yet for CI/CD?
this might fix CI/CD https://stackoverflow.com/a/78086249/8623062
for gh actions
- name: Setup Java uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: '17' cache: 'gradle' check-latest: true
Works to me
I comment
those options
compileOptions { targetCompatibility JavaVersion.VERSION_17 sourceCompatibility JavaVersion.VERSION_17
but i face a other error when i run .\gradlew clean build
`
WARNING:The specified Android SDK Build Tools version (28.0.3) is ignored, as it is below the minimum supported version (30.0.3) for Android Gradle Plugin 7.3.0. Android SDK Build Tools 30.0.3 will be used. To suppress this warning, remove "buildToolsVersion '28.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
Task :connectivity_plus:processDebugManifest package="dev.fluttercommunity.plus.connectivity" found in source AndroidManifest.xml: C:\Users\HP\AppData\Local\Pub\Cache\hosted\pub.dev\connectivity_plus-6.0.3\android\src\main\AndroidManifest.xml. Setting the namespace via a source AndroidManifest.xml's package attribute is deprecated. Please instead set the namespace (or testNamespace) in the module's build.gradle file, as described here: https://developer.android.com/studio/build/configure-app-module#set-namespace This migration can be done automatically using the AGP Upgrade Assistant, please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.
Task :device_info_plus:processDebugManifest
package="dev.fluttercommunity.plus.device_info" found in source AndroidManifest.xml: C:\Users\HP\AppData\Local\Pub\Cache\hosted\pub.dev\device_info_plus-9.1.2\android\src\main\AndroidManifest.xml. Setting the namespace via a source AndroidManifest.xml's package attribute is deprecated. Please instead set the namespace (or testNamespace) in the module's build.gradle file, as described here: https://developer.android.com/studio/build/configure-app-module#set-namespace This migration can be done automatically using the AGP Upgrade Assistant, please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.Task :flutter_secure_storage:processDebugManifest package="com.it_nomads.fluttersecurestorage" found in source AndroidManifest.xml: C:\Users\HP\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_secure_storage-4.2.1\android\src\main\AndroidManifest.xml. Setting the namespace via a source AndroidManifest.xml's package attribute is deprecated. Please instead set the namespace (or testNamespace) in the module's build.gradle file, as described here: https://developer.android.com/studio/build/configure-app-module#set-namespace This migration can be done automatically using the AGP Upgrade Assistant, please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.
Task :image_gallery_saver:processDebugManifest package="com.example.imagegallerysaver" found in source AndroidManifest.xml: C:\Users\HP\AppData\Local\Pub\Cache\hosted\pub.dev\image_gallery_saver-2.0.3\android\src\main\AndroidManifest.xml. Setting the namespace via a source AndroidManifest.xml's package attribute is deprecated. Please instead set the namespace (or testNamespace) in the module's build.gradle file, as described here: https://developer.android.com/studio/build/configure-app-module#set-namespace This migration can be done automatically using the AGP Upgrade Assistant, please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.
Task :permission_handler_android:processDebugManifest package="com.baseflow.permissionhandler" found in source AndroidManifest.xml: C:\Users\HP\AppData\Local\Pub\Cache\hosted\pub.dev\permission_handler_android-12.0.5\android\src\main\AndroidManifest.xml. Setting the namespace via a source AndroidManifest.xml's package attribute is deprecated. Please instead set the namespace (or testNamespace) in the module's build.gradle file, as described here: https://developer.android.com/studio/build/configure-app-module#set-namespace This migration can be done automatically using the AGP Upgrade Assistant, please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.
Task :url_launcher_android:processDebugManifest package="io.flutter.plugins.urllauncher" found in source AndroidManifest.xml: C:\Users\HP\AppData\Local\Pub\Cache\hosted\pub.dev\url_launcher_android-6.3.1\android\src\main\AndroidManifest.xml. Setting the namespace via a source AndroidManifest.xml's package attribute is deprecated. Please instead set the namespace (or testNamespace) in the module's build.gradle file, as described here: https://developer.android.com/studio/build/configure-app-module#set-namespace This migration can be done automatically using the AGP Upgrade Assistant, please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.
Task :video_player_android:processDebugManifest package="io.flutter.plugins.videoplayer" found in source AndroidManifest.xml: C:\Users\HP\AppData\Local\Pub\Cache\hosted\pub.dev\video_player_android-2.4.13\android\src\main\AndroidManifest.xml. Setting the namespace via a source AndroidManifest.xml's package attribute is deprecated. Please instead set the namespace (or testNamespace) in the module's build.gradle file, as described here: https://developer.android.com/studio/build/configure-app-module#set-namespace This migration can be done automatically using the AGP Upgrade Assistant, please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.
Task :flutter_secure_storage:compileDebugJavaWithJavac Note: C:\Users\HP\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_secure_storage-4.2.1\android\src\main\java\com\it_nomads\fluttersecurestorage\FlutterSecureStoragePlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details.
Task :device_info_plus:compileDebugKotlin w: C:\Users\HP\AppData\Local\Pub\Cache\hosted\pub.dev\device_info_plus-9.1.2\android\src\main\kotlin\dev\fluttercommunity\plus\device_info\MethodCallHandlerImpl.kt: (67, 50): 'getter for defaultDisplay: Display!' is deprecated. Deprecated in Java w: C:\Users\HP\AppData\Local\Pub\Cache\hosted\pub.dev\device_info_plus-9.1.2\android\src\main\kotlin\dev\fluttercommunity\plus\device_info\MethodCallHandlerImpl.kt: (70, 25): 'getRealMetrics(DisplayMetrics!): Unit' is deprecated. Deprecated in Java
w: C:\Users\HP\AppData\Local\Pub\Cache\hosted\pub.dev\device_info_plus-9.1.2\android\src\main\kotlin\dev\fluttercommunity\plus\device_info\MethodCallHandlerImpl.kt: (72, 25): 'getMetrics(DisplayMetrics!): Unit' is deprecated. Deprecated in Java w: C:\Users\HP\AppData\Local\Pub\Cache\hosted\pub.dev\device_info_plus-9.1.2\android\src\main\kotlin\dev\fluttercommunity\plus\device_info\MethodCallHandlerImpl.kt: (89, 47): 'SERIAL: String!' is deprecated. Deprecated in JavaTask :image_gallery_saver:compileDebugKotlin w: C:\Users\HP\AppData\Local\Pub\Cache\hosted\pub.dev\image_gallery_saver-2.0.3\android\src\main\kotlin\com\example\imagegallerysaver\ImageGallerySaverPlugin.kt: (21, 48): 'Registrar' is deprecated. Deprecated in Java w: C:\Users\HP\AppData\Local\Pub\Cache\hosted\pub.dev\image_gallery_saver-2.0.3\android\src\main\kotlin\com\example\imagegallerysaver\ImageGallerySaverPlugin.kt: (104, 29): 'getExternalStoragePublicDirectory(String!): File!' is deprecated. Deprecated in Java w: C:\Users\HP\AppData\Local\Pub\Cache\hosted\pub.dev\image_gallery_saver-2.0.3\android\src\main\kotlin\com\example\imagegallerysaver\ImageGallerySaverPlugin.kt: (142, 49): 'ACTION_MEDIA_SCANNER_SCAN_FILE: String' is deprecated. Deprecated in Java w: C:\Users\HP\AppData\Local\Pub\Cache\hosted\pub.dev\image_gallery_saver-2.0.3\android\src\main\kotlin\com\example\imagegallerysaver\ImageGallerySaverPlugin.kt: (213, 33): Variable 'count' initializer is redundant
Task :app:compileDebugJavaWithJavac FAILED C:\Users\HP\Desktop\Projects\Work\p1_chatapp\flutter\creacom\android\app\src\main\java\io\flutter\app\FlutterMultiDexApplication.java:13: error: package androidx.multidex does not exist import androidx.multidex.MultiDex; ^ C:\Users\HP\Desktop\Projects\Work\p1_chatapp\flutter\creacom\android\app\src\main\java\io\flutter\app\FlutterMultiDexApplication.java:23: error: cannot find symbol MultiDex.install(this); ^ symbol: variable MultiDex location: class FlutterMultiDexApplication 2 errors
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
Try:
Run with --info option to get more log output. Run with --scan to get full insights.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.7/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 2m 3s 160 actionable tasks: 146 executed, 14 up-to-date `
For the people this issue still persists, please create a new issue & do add +1 with your flutter doctor -v output, I will try to reproduce & fix, apologies for the inactivity
I got it fixed by updating Android Studio.
Before doing anything, launch Android Studio and Click Help > About and take a note of the Runtime version. For me, it was a JDK 11 version.
After updating to 2023.3.1 the same About page showed JDK 17 and the Android builds ran fine.
This works.
What is the proper way to resolve this error:
I've just been going into ~/.pub-cache/hosted/pub.dev/file_saver-0.2.9/android/build.gradle
and changing:
to
but obviously thats not a real fix. (Also curious why do my projects have this issue and no one else seems to?)