执行 flutter build apk打包app的时候出现一大堆错,明明是按照文档来的啊,怎么就报错了,报错如下:

    1. Warning: io.flutter.embedding.android.FlutterActivity: can't find superclass or interface android.arch.lifecycle.LifecycleOwner
    2. Warning: io.flutter.embedding.engine.FlutterEngine: can't find superclass or interface android.arch.lifecycle.LifecycleOwner
    3. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle: can't find superclass or interface android.arch.lifecycle.LifecycleRegistry
    4. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle$1: can't find superclass or interface android.arch.lifecycle.DefaultLifecycleObserver
    5. Warning: io.flutter.embedding.engine.plugins.FlutterPlugin$FlutterPluginBinding: can't find superclass or interface android.arch.lifecycle.LifecycleOwner
    6. Warning: io.flutter.embedding.android.FlutterActivity: can't find referenced class android.arch.lifecycle.LifecycleRegistry
    7. Warning: io.flutter.embedding.android.FlutterActivity: can't find referenced class android.arch.lifecycle.LifecycleRegistry
    8. Warning: io.flutter.embedding.android.FlutterActivity: can't find referenced class android.arch.lifecycle.Lifecycle$Event
    9. Warning: io.flutter.embedding.android.FlutterActivity: can't find referenced class android.arch.lifecycle.LifecycleRegistry
    10. Warning: io.flutter.embedding.android.FlutterActivity: can't find referenced class android.arch.lifecycle.Lifecycle$Event
    11. Warning: io.flutter.embedding.android.FlutterActivity: can't find referenced class android.arch.lifecycle.Lifecycle$Event
    12. Warning: io.flutter.embedding.android.FlutterActivity: can't find referenced class android.arch.lifecycle.Lifecycle$Event
    13. Warning: io.flutter.embedding.android.FlutterActivity: can't find referenced class android.arch.lifecycle.Lifecycle$Event
    14. Warning: io.flutter.embedding.android.FlutterActivity: can't find referenced class android.arch.lifecycle.Lifecycle$Event
    15. Warning: io.flutter.embedding.android.FlutterActivity: can't find referenced class android.arch.lifecycle.LifecycleOwner
    16. Warning: io.flutter.embedding.android.FlutterActivity: can't find referenced class android.arch.lifecycle.Lifecycle$Event
    17. Warning: io.flutter.embedding.android.FlutterActivity: can't find referenced class android.arch.lifecycle.Lifecycle
    18. Warning: io.flutter.embedding.android.FlutterActivity: can't find referenced class android.arch.lifecycle.LifecycleRegistry
    19. Warning: io.flutter.embedding.android.FlutterActivity: can't find referenced class android.arch.lifecycle.Lifecycle
    20. Warning: io.flutter.embedding.android.FlutterActivityAndFragmentDelegate$Host: can't find referenced class android.arch.lifecycle.Lifecycle
    21. Warning: io.flutter.embedding.android.FlutterFragment: can't find referenced method 'void setArguments(android.os.Bundle)' in program class io.flutter.embedding.android.FlutterFragment
    22. Warning: io.flutter.embedding.android.FlutterFragment: can't find referenced method 'android.support.v4.app.FragmentActivity getActivity()' in program class io.flutter.embedding.android.FlutterFragment
    23. Warning: io.flutter.embedding.android.FlutterFragment: can't find referenced method 'android.os.Bundle getArguments()' in program class io.flutter.embedding.android.FlutterFragment
    24. Warning: io.flutter.embedding.android.FlutterFragment$1: can't find referenced method 'android.support.v4.app.FragmentActivity getActivity()' in program class io.flutter.embedding.android.FlutterFragment
    25. Warning: io.flutter.embedding.android.FlutterFragment$CachedEngineFragmentBuilder: can't find referenced method 'void setArguments(android.os.Bundle)' in program class io.flutter.embedding.android.FlutterFragment
    26. Warning: io.flutter.embedding.android.FlutterFragment$NewEngineFragmentBuilder: can't find referenced method 'void setArguments(android.os.Bundle)' in program class io.flutter.embedding.android.FlutterFragment
    27. Warning: io.flutter.embedding.android.FlutterView: can't find referenced method 'android.graphics.Insets getSystemGestureInsets()' in library class android.view.WindowInsets
    28. Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets
    29. Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets
    30. Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets
    31. Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets
    32. Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets
    33. Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets
    34. Warning: io.flutter.embedding.engine.FlutterEngine: can't find referenced class android.arch.lifecycle.LifecycleOwner
    35. Warning: io.flutter.embedding.engine.FlutterEngine: can't find referenced class android.arch.lifecycle.Lifecycle
    36. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle: can't find referenced class android.arch.lifecycle.LifecycleRegistry
    37. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle: can't find referenced class android.arch.lifecycle.Lifecycle
    38. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle: can't find referenced class android.arch.lifecycle.Lifecycle$Event
    39. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle: can't find referenced class android.arch.lifecycle.Lifecycle
    40. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle: can't find referenced class android.arch.lifecycle.LifecycleRegistry
    41. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle: can't find referenced class android.arch.lifecycle.Lifecycle$State
    42. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle: can't find referenced method 'void markState(android.arch.lifecycle.Lifecycle$State)' in program class io.flutter.embedding.engine.FlutterEngineAndroidLifecycle
    43. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle: can't find referenced class android.arch.lifecycle.LifecycleRegistry
    44. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle: can't find referenced class android.arch.lifecycle.Lifecycle$Event
    45. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle: can't find referenced class android.arch.lifecycle.Lifecycle
    46. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle: can't find referenced class android.arch.lifecycle.Lifecycle$State
    47. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle: can't find referenced class android.arch.lifecycle.Lifecycle
    48. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle: can't find referenced class android.arch.lifecycle.LifecycleObserver
    49. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle: can't find referenced class android.arch.lifecycle.LifecycleOwner
    50. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle: can't find referenced class android.arch.lifecycle.LifecycleOwner
    51. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle: can't find referenced class android.arch.lifecycle.Lifecycle
    52. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle: can't find referenced class android.arch.lifecycle.Lifecycle
    53. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle: can't find referenced class android.arch.lifecycle.Lifecycle$Event
    54. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle: can't find referenced class android.arch.lifecycle.Lifecycle$Event
    55. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle$1: can't find referenced class android.arch.lifecycle.Lifecycle$Event
    56. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle$1: can't find referenced class android.arch.lifecycle.Lifecycle$Event
    57. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle$1: can't find referenced class android.arch.lifecycle.Lifecycle$Event
    58. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle$1: can't find referenced class android.arch.lifecycle.Lifecycle$Event
    59. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle$1: can't find referenced class android.arch.lifecycle.DefaultLifecycleObserver
    60. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle$1: can't find referenced class android.arch.lifecycle.Lifecycle$Event
    61. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle$1: can't find referenced class android.arch.lifecycle.Lifecycle
    62. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle$1: can't find referenced class android.arch.lifecycle.LifecycleOwner
    63. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle$1: can't find referenced class android.arch.lifecycle.LifecycleOwner
    64. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle$1: can't find referenced class android.arch.lifecycle.LifecycleOwner
    65. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle$1: can't find referenced class android.arch.lifecycle.LifecycleOwner
    66. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle$1: can't find referenced class android.arch.lifecycle.LifecycleOwner
    67. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle$1: can't find referenced class android.arch.lifecycle.LifecycleOwner
    68. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle$1: can't find referenced class android.arch.lifecycle.LifecycleOwner
    69. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle$1: can't find referenced class android.arch.lifecycle.LifecycleOwner
    70. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle$1: can't find referenced class android.arch.lifecycle.LifecycleOwner
    71. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle$1: can't find referenced class android.arch.lifecycle.LifecycleOwner
    72. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle$1: can't find referenced class android.arch.lifecycle.LifecycleOwner
    73. Warning: io.flutter.embedding.engine.FlutterEngineAndroidLifecycle$1: can't find referenced class android.arch.lifecycle.LifecycleOwner
    74. Warning: io.flutter.embedding.engine.FlutterEnginePluginRegistry: can't find referenced class android.arch.lifecycle.Lifecycle
    75. Warning: io.flutter.embedding.engine.FlutterEnginePluginRegistry: can't find referenced class android.arch.lifecycle.Lifecycle
    76. Warning: io.flutter.embedding.engine.FlutterEnginePluginRegistry: can't find referenced class android.arch.lifecycle.Lifecycle
    77. Warning: io.flutter.embedding.engine.FlutterEnginePluginRegistry: can't find referenced class android.arch.lifecycle.Lifecycle
    78. Warning: io.flutter.embedding.engine.FlutterEnginePluginRegistry: can't find referenced class android.arch.lifecycle.Lifecycle
    79. Warning: io.flutter.embedding.engine.FlutterEnginePluginRegistry: can't find referenced class android.arch.lifecycle.Lifecycle
    80. Warning: io.flutter.embedding.engine.FlutterEnginePluginRegistry: can't find referenced class android.arch.lifecycle.Lifecycle
    81. Warning: io.flutter.embedding.engine.FlutterEnginePluginRegistry: can't find referenced class android.arch.lifecycle.Lifecycle
    82. Warning: io.flutter.embedding.engine.FlutterEnginePluginRegistry: can't find referenced class android.arch.lifecycle.Lifecycle
    83. Warning: io.flutter.embedding.engine.plugins.FlutterPlugin$FlutterPluginBinding: can't find referenced class android.arch.lifecycle.LifecycleOwner
    84. Warning: io.flutter.embedding.engine.plugins.FlutterPlugin$FlutterPluginBinding: can't find referenced class android.arch.lifecycle.Lifecycle
    85. Warning: io.flutter.embedding.engine.plugins.FlutterPlugin$FlutterPluginBinding: can't find referenced class android.arch.lifecycle.Lifecycle
    86. Warning: io.flutter.embedding.engine.plugins.FlutterPlugin$FlutterPluginBinding: can't find referenced class android.arch.lifecycle.Lifecycle
    87. Warning: io.flutter.embedding.engine.plugins.FlutterPlugin$FlutterPluginBinding: can't find referenced class android.arch.lifecycle.Lifecycle
    88. Warning: io.flutter.embedding.engine.plugins.activity.ActivityControlSurface: can't find referenced class android.arch.lifecycle.Lifecycle
    89. Warning: io.flutter.embedding.engine.plugins.broadcastreceiver.BroadcastReceiverControlSurface: can't find referenced class android.arch.lifecycle.Lifecycle
    90. Warning: io.flutter.embedding.engine.plugins.contentprovider.ContentProviderControlSurface: can't find referenced class android.arch.lifecycle.Lifecycle
    91. Warning: io.flutter.embedding.engine.plugins.service.ServiceControlSurface: can't find referenced class android.arch.lifecycle.Lifecycle
    92. Warning: io.flutter.view.FlutterView: can't find referenced method 'android.graphics.Insets getSystemGestureInsets()' in library class android.view.WindowInsets
    93. Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets
    94. Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets
    95. Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets
    96. Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets
    97. Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets
    98. Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets
    99. Note: io.flutter.view.AccessibilityViewEmbedder$ReflectionAccessors: can't find dynamically referenced class android.util.LongArray
    100. Note: kotlin.internal.PlatformImplementationsKt: can't find dynamically referenced class kotlin.internal.jdk8.JDK8PlatformImplementations
    101. Note: kotlin.internal.PlatformImplementationsKt: can't find dynamically referenced class kotlin.internal.JRE8PlatformImplementations
    102. Note: kotlin.internal.PlatformImplementationsKt: can't find dynamically referenced class kotlin.internal.JRE7PlatformImplementations
    103. Note: kotlin.jvm.internal.Reflection: can't find dynamically referenced class kotlin.reflect.jvm.internal.ReflectionFactoryImpl
    104. Note: there were 5 unresolved dynamic references to classes or interfaces.
    105. You should check if you need to specify additional program jars.
    106. (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
    107. Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.
    108. Thread(Tasks limiter_2): destruction
    109. Warning: there were 89 unresolved references to classes or interfaces.
    110. You may need to add missing library jars or update their versions.
    111. If your code works fine without the missing classes, you can suppress
    112. the warnings with '-dontwarn' options.
    113. (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
    114. Warning: there were 7 unresolved references to program class members.
    115. Your input classes appear to be inconsistent.
    116. You may need to recompile the code.
    117. (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
    118. Warning: there were 2 unresolved references to library class members.
    119. You probably need to update the library versions.
    120. (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)
    121. FAILURE: Build failed with an exception.
    122. * What went wrong:
    123. Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
    124. > Job failed, see logs for details
    125. * Try:
    126. 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.
    127. * Get more help at https://help.gradle.org
    128. BUILD FAILED in 2s
    129. Running Gradle task 'assembleRelease'...
    130. Running Gradle task 'assembleRelease'... Done 3.4s
    131. *******************************************************************************************
    132. The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
    133. See https://goo.gl/CP92wY for more information on the problem and how to fix it.
    134. *******************************************************************************************
    135. Gradle task assembleRelease failed with exit code 1

    然后google了一番,说是Proguard 导致的。取消了就好, 然后就进入 android/app/build.gradle中:

    1. buildTypes {
    2. release {
    3. // TODO: Add your own signing config for the release build.
    4. // Signing with the debug keys for now, so `flutter run --release` works.
    5. signingConfig signingConfigs.debug
    6. // minifyEnabled true
    7. // useProguard true
    8. // proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    9. }
    10. }

    注释掉添加的混淆代码的功能就好了。

    使用的过程中遇到了问题,记录一下。