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

Adding flutter_secure_storage to a new project causes build failures with: Missing classes detected while running R8. #839

Open
arran4 opened this issue Dec 18, 2024 · 6 comments

Comments

@arran4
Copy link

arran4 commented Dec 18, 2024

With a brand new project:

arran@arran-desktop:/home/arran/Documents/Projects/untitled2 34340 
% java --version
openjdk 17.0.13 2024-10-15
OpenJDK Runtime Environment 17.0.13_p11 (build 17.0.13+11)
OpenJDK 64-Bit Server VM 17.0.13_p11 (build 17.0.13+11, mixed mode, sharing)
arran@arran-desktop:/home/arran/Documents/Projects/untitled2 34341 
% flutter --version
Flutter 3.27.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 17025dd882 (2 days ago) • 2024-12-17 03:23:09 +0900
Engine • revision cb4b5fff73
Tools • Dart 3.6.0 • DevTools 2.40.2
arran@arran-desktop:/home/arran/Documents/Projects/untitled2 34369 
% grep -v '^\(\s*#\|$\)' pubspec.yaml
name: untitled2
description: "A new Flutter project."
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
  sdk: ^3.6.0
dependencies:
  flutter:
    sdk: flutter
  flutter_secure_storage: 9.2.2
dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^5.0.0
flutter:
  uses-material-design: true

Causes:

arran@arran-desktop:/home/arran/Documents/Projects/untitled2 34368 
% flutter clean && flutter build appbundle
Deleting build...                                                   25ms
Deleting .dart_tool...                                               3ms
Deleting Generated.xcconfig...                                       0ms
Deleting flutter_export_environment.sh...                            0ms
Deleting ephemeral...                                                0ms
Deleting ephemeral...                                                0ms
Deleting ephemeral...                                                0ms
Deleting .flutter-plugins-dependencies...                            0ms
Deleting .flutter-plugins...                                         0ms
Resolving dependencies... 
Downloading packages... 
  async 2.11.0 (2.12.0 available)
  boolean_selector 2.1.1 (2.1.2 available)
  characters 1.3.0 (1.4.0 available)
  clock 1.1.1 (1.1.2 available)
  collection 1.19.0 (1.19.1 available)
  fake_async 1.3.1 (1.3.2 available)
< flutter_secure_storage 8.1.0 (was 9.1.1) (9.2.2 available)
< flutter_secure_storage_windows 2.1.1 (was 3.1.2) (3.1.2 available)
  js 0.6.7 (0.7.1 available)
  leak_tracker 10.0.7 (10.0.8 available)
  leak_tracker_flutter_testing 3.0.8 (3.0.9 available)
  matcher 0.12.16+1 (0.12.17 available)
  material_color_utilities 0.11.1 (0.12.0 available)
  meta 1.15.0 (1.16.0 available)
  path 1.9.0 (1.9.1 available)
  source_span 1.10.0 (1.10.1 available)
  string_scanner 1.3.0 (1.4.1 available)
  term_glyph 1.2.1 (1.2.2 available)
  test_api 0.7.3 (0.7.4 available)
  vm_service 14.3.0 (15.0.0 available)
These packages are no longer being depended on:
- ffi 2.1.3
- path_provider 2.1.5
- path_provider_android 2.2.15
- path_provider_foundation 2.4.1
- path_provider_linux 2.2.1
- path_provider_platform_interface 2.1.2
- path_provider_windows 2.3.0
- platform 3.1.6
- win32 5.9.0
- xdg_directories 1.1.0
Changed 12 dependencies!
20 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.

Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 1384 bytes (99.9% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /home/arran/Documents/Projects/untitled2/build/app/outputs/mapping/release/missing_rules.txt.
ERROR: R8: Missing class com.google.errorprone.annotations.CanIgnoreReturnValue (referenced from: com.google.crypto.tink.KeysetManager com.google.crypto.tink.KeysetManager.add(com.google.crypto.tink.KeyTemplate) and 52 other contexts)
Missing class com.google.errorprone.annotations.CheckReturnValue (referenced from: com.google.crypto.tink.InsecureSecretKeyAccess and 1 other context)
Missing class com.google.errorprone.annotations.Immutable (referenced from: com.google.crypto.tink.InsecureSecretKeyAccess and 40 other contexts)
Missing class com.google.errorprone.annotations.RestrictedApi (referenced from: com.google.crypto.tink.aead.AesEaxKey$Builder com.google.crypto.tink.aead.AesEaxKey.builder() and 6 other contexts)
Missing class javax.annotation.Nullable (referenced from: java.lang.Object com.google.crypto.tink.PrimitiveSet$Entry.fullPrimitive and 86 other contexts)
Missing class javax.annotation.concurrent.GuardedBy (referenced from: com.google.crypto.tink.proto.Keyset$Builder com.google.crypto.tink.KeysetManager.keysetBuilder and 3 other contexts)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:minifyReleaseWithR8'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable
   > Compilation failed to complete

* 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 24s
Running Gradle task 'bundleRelease'...                             24.9s
Gradle task bundleRelease failed with exit code 1
arran@arran-desktop:/home/arran/Documents/Projects/untitled2 34369 
% grep -v '^\(\s*#\|$\)' pubspec.yaml
name: untitled2
description: "A new Flutter project."
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
  sdk: ^3.6.0
dependencies:
  flutter:
    sdk: flutter
  flutter_secure_storage: 9.2.2
dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^5.0.0
flutter:
  uses-material-design: true
arran@arran-desktop:/home/arran/Documents/Projects/untitled2 34370 
% flutter clean && flutter build appbundle
Deleting build...                                                   21ms
Deleting .dart_tool...                                               3ms
Deleting Generated.xcconfig...                                       0ms
Deleting flutter_export_environment.sh...                            0ms
Deleting ephemeral...                                                0ms
Deleting ephemeral...                                                0ms
Deleting ephemeral...                                                0ms
Deleting .flutter-plugins-dependencies...                            0ms
Deleting .flutter-plugins...                                         0ms
Resolving dependencies... 
Downloading packages... 
  async 2.11.0 (2.12.0 available)
  boolean_selector 2.1.1 (2.1.2 available)
  characters 1.3.0 (1.4.0 available)
  clock 1.1.1 (1.1.2 available)
  collection 1.19.0 (1.19.1 available)
  fake_async 1.3.1 (1.3.2 available)
+ ffi 2.1.3
> flutter_secure_storage 9.2.2 (was 8.1.0)
> flutter_secure_storage_windows 3.1.2 (was 2.1.1)
  js 0.6.7 (0.7.1 available)
  leak_tracker 10.0.7 (10.0.8 available)
  leak_tracker_flutter_testing 3.0.8 (3.0.9 available)
  matcher 0.12.16+1 (0.12.17 available)
  material_color_utilities 0.11.1 (0.12.0 available)
  meta 1.15.0 (1.16.0 available)
  path 1.9.0 (1.9.1 available)
+ path_provider 2.1.5
+ path_provider_android 2.2.15
+ path_provider_foundation 2.4.1
+ path_provider_linux 2.2.1
+ path_provider_platform_interface 2.1.2
+ path_provider_windows 2.3.0
+ platform 3.1.6
  source_span 1.10.0 (1.10.1 available)
  string_scanner 1.3.0 (1.4.1 available)
  term_glyph 1.2.1 (1.2.2 available)
  test_api 0.7.3 (0.7.4 available)
  vm_service 14.3.0 (15.0.0 available)
+ win32 5.9.0
+ xdg_directories 1.1.0
Changed 12 dependencies!
18 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.

Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 1384 bytes (99.9% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /home/arran/Documents/Projects/untitled2/build/app/outputs/mapping/release/missing_rules.txt.
ERROR: R8: Missing class com.google.errorprone.annotations.CanIgnoreReturnValue (referenced from: com.google.crypto.tink.KeysetManager com.google.crypto.tink.KeysetManager.add(com.google.crypto.tink.KeyTemplate) and 52 other contexts)
Missing class com.google.errorprone.annotations.CheckReturnValue (referenced from: com.google.crypto.tink.InsecureSecretKeyAccess and 1 other context)
Missing class com.google.errorprone.annotations.Immutable (referenced from: com.google.crypto.tink.InsecureSecretKeyAccess and 40 other contexts)
Missing class com.google.errorprone.annotations.RestrictedApi (referenced from: com.google.crypto.tink.aead.AesEaxKey$Builder com.google.crypto.tink.aead.AesEaxKey.builder() and 6 other contexts)
Missing class javax.annotation.Nullable (referenced from: java.lang.Object com.google.crypto.tink.PrimitiveSet$Entry.fullPrimitive and 86 other contexts)
Missing class javax.annotation.concurrent.GuardedBy (referenced from: com.google.crypto.tink.proto.Keyset$Builder com.google.crypto.tink.KeysetManager.keysetBuilder and 3 other contexts)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:minifyReleaseWithR8'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable
   > Compilation failed to complete

* 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 12s
Running Gradle task 'bundleRelease'...                             13.0s
Gradle task bundleRelease failed with exit code 1

Which keeps on leading me back to this error: flutter/flutter#156304

I have also logged a ticket downstream at oauth2_client: teranetsrl/oauth2_client#203

@nathnaeld
Copy link

nathnaeld commented Dec 19, 2024

I have encountered a similar issue with the release build, but the debug build works fine.

@arran4
Copy link
Author

arran4 commented Dec 19, 2024

I suspect (but I don't really know) the issue is happening as a result of tree shaking.

@niluved
Copy link

niluved commented Dec 21, 2024

same here.
Debug build works fine, release build crashes with same error.

@w568w
Copy link

w568w commented Dec 28, 2024

Have you checked #748 (comment)?

@arran4
Copy link
Author

arran4 commented Dec 29, 2024

-dontwarn means that the application builds but doesn't open on android.

I believe I have done the "(real)" fix but the test could be contaminated so doing it in my clean project.

It did build:

Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 1384 bytes (99.9% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
Running Gradle task 'bundleRelease'...                             29.3s
✓ Built build/app/outputs/bundle/release/app-release.aab (19.0MB)

Can confirm worked with apk release (and drag drop install)

image

APK also fails like aab when fix is disabled:

image

I was also able to get it to work by using the dependency to just:

    implementation("com.google.crypto.tink:tink-android:1.14.1")

Which makes me think that:
#842

Would resolve this.

@nathnaeld
Copy link

Have you checked #748 (comment)?

Thanks, it worked for me.
I have added these dependencies in the android/app/build.gradle

android {
    ...

    // Required by flutter_secure_storage
    dependencies {
        implementation 'com.google.errorprone:error_prone_annotations:2.36.0'
        implementation 'com.github.spotbugs:spotbugs-annotations:4.8.6'
    }
}

And replaced the version codes with the most recent from these links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants