Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android compile error registrar #1643

Closed
1 of 4 tasks
abdelaziz-mahdy opened this issue Dec 11, 2024 · 58 comments
Closed
1 of 4 tasks

Android compile error registrar #1643

abdelaziz-mahdy opened this issue Dec 11, 2024 · 58 comments
Labels
new issue An issue that hasn't yet been seen from the maintainer

Comments

@abdelaziz-mahdy
Copy link
Contributor

Describe the bug
After upgrading to flutter 3.27 the code fails to compile on android , using flutter build apk

Platform

  • Android
  • iOS
  • Web
  • Desktop

Platform OS version
What version did it happen?

How are you picking?

Please, post the snippet here

Details to reproduce the issue
Provide all the details to reproduce the issue.

Error Log

/Users/AbdelazizMahdy/.pub-cache/hosted/pub.dev/file_picker-8.1.5/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:257: error: cannot find symbol
        if (registrar != null) {
            ^
  symbol:   variable registrar
  location: class FilePickerPlugin
/Users/AbdelazizMahdy/.pub-cache/hosted/pub.dev/file_picker-8.1.5/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:260: error: cannot find symbol
            registrar.addActivityResultListener(this.delegate);
            ^
  symbol:   variable registrar
  location: class FilePickerPlugin
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':file_picker:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

Screenshots and/or video
If applicable, add screenshots or video to help explain your problem.

Flutter Version details

[✓] Flutter (Channel stable, 3.27.0, on macOS 15.1.1 24B91 darwin-arm64, locale
    en-EG)
    • Flutter version 3.27.0 on channel stable at
      /Users/AbdelazizMahdy/Developer/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 8495dee1fd (25 hours ago), 2024-12-10 14:23:39 -0800
    • Engine revision 83bacfc525
    • Dart version 3.6.0
    • DevTools version 2.40.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/AbdelazizMahdy/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16B40
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • 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
      17.0.11+0-17.0.11b1207.24-11852314)

[✓] IntelliJ IDEA Community Edition (version 2024.2.0.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin version 242.20629

[✓] VS Code (version 1.95.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.102.0

[✓] Connected device (3 available)
    • macOS (desktop)                 • macos                 • darwin-arm64   •
      macOS 15.1.1 24B91 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         •
      macOS 15.1.1 24B91 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript •
      Google Chrome 131.0.6778.109

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Additional context
Add any other context about the problem here.

@abdelaziz-mahdy abdelaziz-mahdy added the new issue An issue that hasn't yet been seen from the maintainer label Dec 11, 2024
@DennisKragekjaer
Copy link

same here

@abdelaziz-mahdy
Copy link
Contributor Author

abdelaziz-mahdy commented Dec 11, 2024

just tested on the master branch example app got the same error so its in the package itself


You are applying Flutter's main Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/to/flutter-gradle-plugin-apply

Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 2180 bytes (99.9% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
/Users/AbdelazizMahdy/flutter_projects/flutter_file_picker/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:257: error: cannot find symbol
        if (registrar != null) {
            ^
  symbol:   variable registrar
  location: class FilePickerPlugin
/Users/AbdelazizMahdy/flutter_projects/flutter_file_picker/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:260: error: cannot find symbol
            registrar.addActivityResultListener(this.delegate);
            ^
  symbol:   variable registrar
  location: class FilePickerPlugin
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':file_picker:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* 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 45s
Running Gradle task 'assembleRelease'...                           46.7s
Gradle task assembleRelease failed with exit code 1
AbdelazizMahdy@abdelazizs-MacBook-Pro example % 

@millerf
Copy link

millerf commented Dec 11, 2024

Same with gradle 7.5

 compileSdkVersion = 34                // or higher / as desired
        targetSdkVersion = 34                // or higher / as desired
        minSdkVersion = 23                // Required minimum
        appCompatVersion = "1.4.2"           // or higher / as desired
        playServicesLocationVersion = "21.0.1"  // or higher / as de

@abdelaziz-mahdy
Copy link
Contributor Author

for anyone who is having the issue you can use my branch until the pr gets merged

dependency_overrides: 
  file_picker:
    git:
      url: https://github.com/abdelaziz-mahdy/flutter_file_picker
      ref: fix-flutter-3.27-compile-error

@ddxl123
Copy link

ddxl123 commented Dec 12, 2024

same

@ekuleshov
Copy link

Oddly. Reverting to file_picker: 8.1.4 makes it compile with Flutter 3.27

@abdelaziz-mahdy
Copy link
Contributor Author

actually yes it was removed before looks like a commit brought it back
7c5ff40 this the removal one

@mohsinnaqvi606
Copy link

same issue. even after downgrading to the last working version i.e file_picker: ^8.1.4 issue is not going

@ekuleshov
Copy link

same issue. even after downgrading to the last working version i.e file_picker: ^8.1.4 issue is not going

You need to use exact version. Not the open ended with ^

@mohsinnaqvi606
Copy link

same issue. even after downgrading to the last working version i.e file_picker: ^8.1.4 issue is not going

You need to use exact version. Not the open ended with ^

@ekuleshov It worked for me, thanks.

@fadelfffar
Copy link

same issue here

@Crucialjun
Copy link

Just got this issue

@kiyo9w
Copy link

kiyo9w commented Dec 12, 2024

same issue here, thanks for your solution

@deakjahn
Copy link

deakjahn commented Dec 12, 2024

@abdelaziz-mahdy Yes, this one: 4083ae4

@AdelDaniel
Copy link

The error exists in the new version file_picker: ^8.1.5

So I changed the version to be file_picker: 8.1.4 downgrade and remove ^ and it works

@kjxbyz
Copy link

kjxbyz commented Dec 12, 2024

Same with gradle 8.11.1

compileSdkVersion = 34
targetSdkVersion = 34
minSdkVersion = 24

@krll-kov
Copy link
Contributor

Same

@neo11235
Copy link

same issue here, happened after running pub upgrade, now reverted back to version 8.1.3 and working fine

@muhsinPlanetMedia
Copy link

same

2 similar comments
@SherwinDeveloper
Copy link

same

@MisaGu
Copy link

MisaGu commented Dec 12, 2024

same

@rjahn
Copy link

rjahn commented Dec 12, 2024

same problem with 3.24.3 or 3.24.5

@Joao6
Copy link

Joao6 commented Dec 12, 2024

same here

1 similar comment
@diegodulval
Copy link

same here

@jaimecalderon19
Copy link

jaimecalderon19 commented Dec 12, 2024

I did the same thing with a flutter clean and then a flutter pub get and it stopped working.

mi gradle:
distributionUrl=https://services.gradle.org/distributions/gradle-8.10.2-all.zip

@troller2017
Copy link

same same issue.

@alessandromrt
Copy link

Same here

@RanaUsama20
Copy link

Oddly. Reverting to file_picker: 8.1.4 makes it compile with Flutter 3.27

it worked, thanks!! do you know what is the difference between 8.1.4 and ^8.1.4 tho?

@richanshah
Copy link

Describe the bug After upgrading to flutter 3.27 the code fails to compile on android , using flutter build apk

Platform

  • Android
  • iOS
  • Web
  • Desktop

Platform OS version What version did it happen?

How are you picking?

Please, post the snippet here

Details to reproduce the issue Provide all the details to reproduce the issue.

Error Log

/Users/AbdelazizMahdy/.pub-cache/hosted/pub.dev/file_picker-8.1.5/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:257: error: cannot find symbol
        if (registrar != null) {
            ^
  symbol:   variable registrar
  location: class FilePickerPlugin
/Users/AbdelazizMahdy/.pub-cache/hosted/pub.dev/file_picker-8.1.5/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:260: error: cannot find symbol
            registrar.addActivityResultListener(this.delegate);
            ^
  symbol:   variable registrar
  location: class FilePickerPlugin
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':file_picker:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

Screenshots and/or video If applicable, add screenshots or video to help explain your problem.

Flutter Version details

[✓] Flutter (Channel stable, 3.27.0, on macOS 15.1.1 24B91 darwin-arm64, locale
    en-EG)
    • Flutter version 3.27.0 on channel stable at
      /Users/AbdelazizMahdy/Developer/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 8495dee1fd (25 hours ago), 2024-12-10 14:23:39 -0800
    • Engine revision 83bacfc525
    • Dart version 3.6.0
    • DevTools version 2.40.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/AbdelazizMahdy/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16B40
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • 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
      17.0.11+0-17.0.11b1207.24-11852314)

[✓] IntelliJ IDEA Community Edition (version 2024.2.0.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin version 242.20629

[✓] VS Code (version 1.95.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.102.0

[✓] Connected device (3 available)
    • macOS (desktop)                 • macos                 • darwin-arm64   •
      macOS 15.1.1 24B91 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         •
      macOS 15.1.1 24B91 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript •
      Google Chrome 131.0.6778.109

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Additional context Add any other context about the problem here.

please close the issue, too many unnecessary comments coming.

@deakjahn
Copy link

@RanaUsama20 Yes. ^some-version means "some version or newer" (provided it's compatible). That's why it doesn't help you here, if you forget removing the caret, you'll get the newer version automatically.

@abdelaziz-mahdy
Copy link
Contributor Author

Describe the bug After upgrading to flutter 3.27 the code fails to compile on android , using flutter build apk

Platform

  • Android
  • iOS
  • Web
  • Desktop

Platform OS version What version did it happen?

How are you picking?

Please, post the snippet here

Details to reproduce the issue Provide all the details to reproduce the issue.

Error Log

/Users/AbdelazizMahdy/.pub-cache/hosted/pub.dev/file_picker-8.1.5/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:257: error: cannot find symbol
        if (registrar != null) {
            ^
  symbol:   variable registrar
  location: class FilePickerPlugin
/Users/AbdelazizMahdy/.pub-cache/hosted/pub.dev/file_picker-8.1.5/android/src/main/java/com/mr/flutter/plugin/filepicker/FilePickerPlugin.java:260: error: cannot find symbol
            registrar.addActivityResultListener(this.delegate);
            ^
  symbol:   variable registrar
  location: class FilePickerPlugin
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':file_picker:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

Screenshots and/or video If applicable, add screenshots or video to help explain your problem.

Flutter Version details

[✓] Flutter (Channel stable, 3.27.0, on macOS 15.1.1 24B91 darwin-arm64, locale
    en-EG)
    • Flutter version 3.27.0 on channel stable at
      /Users/AbdelazizMahdy/Developer/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 8495dee1fd (25 hours ago), 2024-12-10 14:23:39 -0800
    • Engine revision 83bacfc525
    • Dart version 3.6.0
    • DevTools version 2.40.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/AbdelazizMahdy/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16B40
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • 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
      17.0.11+0-17.0.11b1207.24-11852314)

[✓] IntelliJ IDEA Community Edition (version 2024.2.0.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin version 242.20629

[✓] VS Code (version 1.95.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.102.0

[✓] Connected device (3 available)
    • macOS (desktop)                 • macos                 • darwin-arm64   •
      macOS 15.1.1 24B91 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         •
      macOS 15.1.1 24B91 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript •
      Google Chrome 131.0.6778.109

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Additional context Add any other context about the problem here.

please close the issue, too many unnecessary comments coming.

I don't have a way to limit the comments, and people have mentioned that each one commenting on the same problem or the same fix doesn't help, but people do it anyway

I hope the package maintainer merges the pr so we can close this as completed

Note: even if I close the issue it won't limit the comments 😅 and won't solve the issue so that's not a solution

As a lot of people mentioned

Reverting to file_picker: 8.1.4 fixes the issue, or using my branch as you can find at a comment above

For newcomers please read the fixes provided above before adding any more comments

@dong336
Copy link

dong336 commented Dec 14, 2024

I'm Flutter 3.24.5, It's resolved by using 8.1.4.

@SaurabhAlex
Copy link

If you're facing build errors related to file_picker or Java/Kotlin version mismatches, here's a solution that worked for me:

Step 1: Update file_picker Version
In your pubspec.yaml, downgrade file_picker to a compatible version:
file_picker: 8.1.4
(Remove the ^ symbol to avoid automatic updates.)

Step 2: Update build.gradle File
In android/app/build.gradle, replace the compileOptions block with this:
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}

Step 3: Update Gradle Wrapper
In android/gradle/wrapper/gradle-wrapper.properties, update the distributionUrl:
distributionUrl=https://services.gradle.org/distributions/gradle-8.3-all.zip

(If you're using a different Gradle version, update 8.3 accordingly.)

Step 4: Update settings.gradle
In android/settings.gradle, adjust the plugin versions:
com.android.application → 8.1.0
org.jetbrains.kotlin.android → 1.8.22

After making these changes, run the following commands:
flutter clean
flutter pub get
flutter build apk

This resolved the issue for me. Let me know if it works for you too! 😊

@Icarus-conf
Copy link

Solution is to update your pubspec.yaml
file_picker: 8.1.4
without ^

@FeodorFitsner
Copy link

FeodorFitsner commented Dec 15, 2024

I'm getting "registrar" error again with file_picker: 8.1.5. Regression?

Sorry for the noise, I didn't realize the error is in 8.1.5 and removing ^ pins it to before 8.1.5.

@Zayha
Copy link

Zayha commented Dec 16, 2024

  1. Add the version to pubspec.yaml: file_picker: 8.1.4
  2. Clearing the cache: dart pub cache clean
  3. Download the new dependency: flutter pub get
  4. Profit! flutter build apk --release without errors

@rufus-op
Copy link

you can use this repo i have fixed the issue

https://github.com/rufus-op/file_picker

replace

file_picker: 8.1.5

with

file_picker:
git:
url: https://github.com/rufus-op/file_picker

@AwaisQazii
Copy link

I don't have file_picker in app but still getting same issue

@abdelaziz-mahdy
Copy link
Contributor Author

abdelaziz-mahdy commented Dec 16, 2024

I don't have file_picker in app but still getting same issue

@AwaisQazii you can override it like this comment since a package is using it in your app

#1643 (comment)
or

dependency_overrides: 
  file_picker: 8.1.4

@reidbaker
Copy link

My teammate on flutter removed v1 embeddings in this pr #1527 fixing the issue we filed #1526.

Is appears that in pull request #1453 the lines we removed were added back in.

5 days ago flutter released 3.27 which was the first stable release to not have the v1 embedding code so any user with this plugin and 3.27 would fail to compile.

At first glance this pr appears to address the regression.

@miguelpruivo
Copy link
Owner

Fixed with 8.1.6.

@YesThatGy
Copy link

YesThatGy commented Dec 16, 2024

you can use this repo i have fixed the issue

https://github.com/rufus-op/file_picker

replace

file_picker: 8.1.5

with

file_picker: git: url: https://github.com/rufus-op/file_picker

Thank you! This worked a treat, until the official release settles

EDIT:

Upgrading to 8.1.6 resolved this issue. Thanks!

@RanaUsama20
Copy link

@RanaUsama20 Yes. ^some-version means "some version or newer" (provided it's compatible). That's why it doesn't help you here, if you forget removing the caret, you'll get the newer version automatically.

Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new issue An issue that hasn't yet been seen from the maintainer
Projects
None yet
Development

No branches or pull requests