我的flutter应用程序可以在调试模式下正常工作,但是当我尝试以发布模式运行它时,出现了gradle task assemblerelease failed with exit code 1
错误
flutter run --release
同样的问题
我删除了.gradle文件,同样的问题仍然出现
我从
classpath 'com.android.tools.build:gradle:3.4.2'
至
classpath 'com.android.tools.build:gradle:3.5.0'
不起作用
我不知道该怎么办
flutter run --release -v
日志是Gradle task assembleRelease failed with exit code 1
#0 throwToolExit (package:flutter_tools/src/base/common.dart:28:3)
#1 _buildGradleProjectV2 (package:flutter_tools/src/android/gradle.dart:751:5)
<asynchronous suspension>
#2 buildGradleProject (package:flutter_tools/src/android/gradle.dart:494:14)
<asynchronous suspension>
#3 buildApk (package:flutter_tools/src/android/apk.dart:34:9)
<asynchronous suspension>
#4 AndroidDevice.startApp (package:flutter_tools/src/android/android_device.dart:486:13)
<asynchronous suspension>
#5 FlutterDevice.runCold (package:flutter_tools/src/resident_runner.dart:439:46)
<asynchronous suspension>
#6 ColdRunner.run (package:flutter_tools/src/run_cold.dart:65:39)
<asynchronous suspension>
#7 RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:472:37)
<asynchronous suspension>
#8 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:490:18)
#9 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#10 _rootRunUnary (dart:async/zone.dart:1132:38)
#11 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#12 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#13 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#14 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#15 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#16 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:30:15)
#17 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:288:13)
#18 RunCommand.usageValues (package:flutter_tools/src/commands/run.dart)
#19 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#20 _rootRunUnary (dart:async/zone.dart:1132:38)
#21 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#22 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#23 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#24 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#25 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#26 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:30:15)
#27 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:288:13)
#28 AndroidDevice.isLocalEmulator (package:flutter_tools/src/android/android_device.dart)
#29 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#30 _rootRunUnary (dart:async/zone.dart:1132:38)
#31 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#32 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#33 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#34 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#35 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#36 Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:552:7)
#37 _rootRun (dart:async/zone.dart:1124:13)
#38 _CustomZone.run (dart:async/zone.dart:1021:19)
#39 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#40 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#41 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#42 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#43 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:116:13)
#44 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:173:5)
flutter doctor
-v日志为
[✓] Flutter (Channel stable, v1.9.1+hotfix.6, on Mac OS X 10.15.1 19B88, locale en-US)
• Flutter version 1.9.1+hotfix.6 at /Users/tabarekaljaaf/flutter
• Framework revision 68587a0916 (12 months ago), 2019-09-13 19:46:58 -0700
• Engine revision b863200c37
• Dart version 2.5.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
• Android SDK at /Users/tabarekaljaaf/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-30, build-tools 29.0.1
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3.1, Build version 11C504
• CocoaPods version 1.8.4
[✓] Android Studio (version 3.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 47.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
[✓] VS Code (version 1.48.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.14.1
[✓] Connected device (1 available)
• SM G965F • 24192e34f80c7ece • android-arm64 • Android 9 (API 28)
• No issues found!
如何解决? 附言我有
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
在我的gradle.properties中 另外,我不想更新我的Flutter版本