当我运行flutter build apk -v时,我看到以下输出:
[ +1 ms] *********************************************************
[ ] WARNING: This version of shared_preferences will break your Android build if it or its
dependencies aren't compatible with AndroidX.
[ +1 ms] See ---(google url)--- for more information on the problem and how to fix it.[ +1 ms] This warning prints for all Android build failures. The real root cause of the
error may be unrelated.
[ +5 ms] *********************************************************
[ +7 ms] 197 actionable tasks: 7 executed, 190 up-to-date
[ +370 ms] Running Gradle task 'assembleRelease'... (completed in 46.8s)
[ +5 ms] "flutter apk" took 53,500ms.
[ ] "flutter apk" took 53,500ms.
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:507:5)
<asynchronous suspension>
#2 buildGradleProject (package:flutter_tools/src/android/gradle.dart:346:14)
<asynchronous suspension>
#3 buildApk (package:flutter_tools/src/android/apk.dart:34:9)
<asynchronous suspension>
#4 BuildApkCommand.runCommand (package:flutter_tools/src/commands/build_apk.dart:79:11)
<asynchronous suspension>
#5 FlutterCommand.verifyThenRunCommand
(package:flutter_tools/src/runner/flutter_command.dart:478:18)
<asynchronous suspension>
#6 FlutterCommand.run.<anonymous closure>
(package:flutter_tools/src/runner/flutter_command.dart:383:33)
<asynchronous suspension>
#7 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:29)
<asynchronous suspension>
#8 _rootRun (dart:async/zone.dart:1124:13)
#9 _CustomZone.run (dart:async/zone.dart:1021:19)
#10 _runZoned (dart:async/zone.dart:1516:10)
#11 runZoned (dart:async/zone.dart:1463:12)
#12 AppContext.run (package:flutter_tools/src/base/context.dart:152:18)
<asynchronous suspension>
#13 FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:375:20)
#14 CommandRunner.runCommand (package:args/command_runner.dart:197:27)
<asynchronous suspension>
#15 FlutterCommandRunner.runCommand.<anonymous closure>
(package:flutter_tools/src/runner/flutter_command_runner.dart:396:21)
<asynchronous suspension>
#16 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:29)
<asynchronous suspension>
#17 _rootRun (dart:async/zone.dart:1124:13)
#18 _CustomZone.run (dart:async/zone.dart:1021:19)
#19 _runZoned (dart:async/zone.dart:1516:10)
#20 runZoned (dart:async/zone.dart:1463:12)
#21 AppContext.run (package:flutter_tools/src/base/context.dart:152:18)
<asynchronous suspension>
#22 FlutterCommandRunner.runCommand
(package:flutter_tools/src/runner/flutter_command_runner.dart:356:19)
<asynchronous suspension>
#23 CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:112:25)
#24 new Future.sync (dart:async/future.dart:224:31)
#25 CommandRunner.run (package:args/command_runner.dart:112:14)
#26 FlutterCommandRunner.run
(package:flutter_tools/src/runner/flutter_command_runner.dart:242:18)
#27 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:22)
<asynchronous suspension>
#28 _rootRun (dart:async/zone.dart:1124:13)
#29 _CustomZone.run (dart:async/zone.dart:1021:19)
#30 _runZoned (dart:async/zone.dart:1516:10)
#31 runZoned (dart:async/zone.dart:1500:12)
#32 run.<anonymous closure> (package:flutter_tools/runner.dart:60:18)
<asynchronous suspension>
#33 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:29)
<asynchronous suspension>
#34 _rootRun (dart:async/zone.dart:1124:13)
#35 _CustomZone.run (dart:async/zone.dart:1021:19)
#36 _runZoned (dart:async/zone.dart:1516:10)
#37 runZoned (dart:async/zone.dart:1463:12)
#38 AppContext.run (package:flutter_tools/src/base/context.dart:152:18)
<asynchronous suspension>
#39 runInContext (package:flutter_tools/src/context_runner.dart:56:24)
<asynchronous suspension>
#40 run (package:flutter_tools/runner.dart:51:10)
#41 main (package:flutter_tools/executable.dart:62:9)
<asynchronous suspension>
#42 main (file:///C:/src/flutter/packages/flutter_tools/bin/flutter_tools.dart:8:3)
#43 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#44 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
当我这样更改(android \ app)build.gradle时,将显示相同的输出。
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
我认为androidx有问题,但我不知道该怎么办。
我第一次成功迁移androidx时就尝试了迁移,但是当我再次尝试时,他们说项目中未找到任何用法,因此我不能再做一次
其他信息: 我使用了android studio,并升级了所有内容。 gradle,sdkversion(到29)distrubuturl(到5.4.1)并还添加了android.useAndroidx = true