Fix it by add this block to android/app/build.gradle compileOptions { sourceCompatibility 1.8 targetCompatibility 1.8 }
If you named your app with the same name as any packages in pubspec.yaml. When running: $ flutter packages get You will have the bug: "A package may not list itself as a dependency" For example, I created an app named firebase_messaging and in pubspec.yaml I also included the package named firebase_messaging To fix this, you have to change the name of your app.