flutter编译报错解决
问题一:java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE (class com.sun.xxx)
n exception has occurred in the compiler (1.8.0_242-release). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError: annotationType(): unrecognized Attribute name MODULE (class com.sun.tools.javac.util.UnsharedNameTable$NameImpl)
at com.sun.tools.javac.util.Assert.error(Assert.java:133)
at com.sun.tools.javac.code.TypeAnnotations.annotationType(TypeAnnotations.java:231)
at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.separateAnnotationsKinds(TypeAnnotations.java:294)
at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitMethodDef(TypeAnnotations.java:1066)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
at com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:275)
at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
解决方法:将jdk8改为jdk11就可以。
修改方法:在gradle.properties文件添加jdk路径。
问题二:安装应用一直卡在Installing build/app/outputs/flutter-apk/app.apk…不动。
解决方法:官方文档有解决方法,参考链接
https://flutteragency.com/flutter-run-stuck-at-installing-apk/
主要是先修改applicationId为其它的包名(跟原来的不一样就可以),然后依次执行flutter clean和flutter run就可以了。不行的话再重启一下AS。
问题三:CocoaPods not installed Skipping pod install。
使用AS通过run 将flutter 应用安装到iPhone报错:
Warning: CocoaPods not installed. Skipping pod install. CocoaPods is used to retrieve the iOS and macOS platform side’s plugin code that responds to your plugin usage on the Dart side. Without CocoaPods, plugins will not work on iOS or macOS. For more info, see https://flutter.dev/platform-plugins To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
Exception: CocoaPods not installed or not in valid state.
看报错是没有安装CocoaPods或者CocoaPods不正确,实际CocoaPods已经安装。
解决方法:参考链接https://stackoverflow.com/questions/68446186/flutter-warning-cocoapods-not-installed-skipping-pod-install-even-while-inst
- 方法一:使用flutter run安装。
- 方法二:先关闭AS和xcode的,在命令窗口使用
open /Applications/Android\ Studio.app
指令打开AS,再进入ios目录执行open Runner.xcworkspace
指令打开xcode,这时候再安装就OK了