Skip to content

After upgrading to 1.9 duplicate class and reference warnings throw error when building apk #40364

@Vanethos

Description

@Vanethos

After upgrading to 1.9, whenever I run the command

flutter creat apk --args

I get close to 600 duplicate classes from Kotlin:

Note: duplicate definition of library class [kotlin.reflect.KProperty]                                             
Note: duplicate definition of library class [kotlin.reflect.KMutableProperty1]                                     
Note: duplicate definition of library class [kotlin.reflect.KCallable]                                             
Note: duplicate definition of library class [kotlin.reflect.KVisibility]                                           
Note: duplicate definition of library class [kotlin.reflect.KAnnotatedElement]         
...
Note: there were 639 duplicate class definitions.                                                                  
      (http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)  

Reference errors:

Warning: io.flutter.embedding.android.FlutterView: can't find referenced method 'android.graphics.Insets getSystemGestureInsets()' in library class android.view.WindowInsets
Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets             
Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets             
Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets             
Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets             
Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets             
Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets             
Warning: io.flutter.view.FlutterView: can't find referenced method 'android.graphics.Insets getSystemGestureInsets()' in library class android.view.WindowInsets
Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets                          
Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets                          
Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets                          
Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets                          
Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets                          
Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets                          
Note: com.crashlytics.android.core.CrashlyticsController: can't find dynamically referenced class com.google.firebase.crash.FirebaseCrash
Note: com.google.android.gms.common.util.WorkSourceUtil: can't find dynamically referenced class android.os.WorkSource$WorkChain
Note: com.google.android.gms.internal.clearcut.zzaw: can't find dynamically referenced class libcore.io.Memory     
Note: com.google.android.gms.internal.clearcut.zzaw: can't find dynamically referenced class org.robolectric.Robolectric
Note: com.google.android.gms.internal.clearcut.zzbs: can't find dynamically referenced class com.google.protobuf.ExtensionRegistry
Note: com.google.android.gms.internal.clearcut.zzbt: can't find dynamically referenced class com.google.protobuf.Extension
...

Note: the configuration keeps the entry point 'io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService { void onMessageReceived(com.google.firebase.messaging.RemoteMessage); }', but not the descriptor class 'com.google.firebase.messaging.RemoteMessage'

...

And it fails building with the following log message:

Note: there were 1 references to unknown classes.                       
      You should check your configuration for typos.                    
      (http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
Note: there were 2 references to unknown class members.                 
      You should check your configuration for typos.                    
Note: there were 87 unkept descriptor classes in kept class members.    
      You should consider explicitly keeping the mentioned classes      
      (using '-keep').                                                  
      (http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass)
Note: there were 72 unresolved dynamic references to classes or interfaces.
      You should check if you need to specify additional program jars.  
      (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.
Thread(Tasks limiter_4): destruction                                    
Warning: there were 12 unresolved references to classes or interfaces.  
         You may need to add missing library jars or update their versions.
         If your code works fine without the missing classes, you can suppress
         the warnings with '-dontwarn' options.                         
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning: there were 2 unresolved references to library class members.   
         You probably need to update the library versions.              
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)
                                                                        
FAILURE: Build failed with an exception.   

* What went wrong:                                                      
Execution failed for task ':app:transformClassesAndResourcesWithProguardForProdRelease'.
> Job failed, see logs for details          

Including -ignorewarnings in proguard-rules.pro does let us build the app, but this shouldn't be the fix since it was no problem in past versions.

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v1.9.1+hotfix.2, on Mac OS X 10.14.5 18F203, locale en-PT)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
[✓] Android Studio (version 3.4)
[✓] VS Code (version 1.38.1)
[✓] Connected device (1 available)

• No issues found!

EDIT: I went back to v1.7.8+hotfix.4 and saw that I did indeed have these as warnings, though to be totally honest I don't remember them at all.

However, nonetheless, no exception is thrown due to the warnings and "note"s, this has happened only in the latest 1.9 version

Metadata

Metadata

Assignees

No one assigned

    Labels

    platform-androidAndroid applications specificallyt: gradle"flutter build" and "flutter run" on Android

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions