Flutter App 在 Android Studio 3.5 之后不会构建 appbundle/APK 或在 Android 上运行



基本上,我的应用程序在iOS上运行和构建,但在我将Android studio更新到3.5版本后,就不再在Android上运行了,我真的需要能够在playstore上发布一个版本。

我尝试了很多方法,但都没有成功。我期待着有人能给我解决问题的方法!我绝望了!

这是我的扑动医生-v日志:

[✓] Flutter (Channel unknown, v1.9.1+hotfix.5, on Mac OS X 10.15 19A602, locale en-FR)
• Flutter version 1.9.1+hotfix.5 at /Users/axel/flutter
• Framework revision 1aedbb1835 (6 days ago), 2019-10-17 08:37:27 -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/axel/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, 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_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.1, Build version 11A1027
• CocoaPods version 1.8.4
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 40.2.2
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] VS Code (version 1.39.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.5.1
[✓] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
• No issues found!

你只需要在android>app>build.gradle中修改build.gradle:

buildTypes {
release {
signingConfig signingConfigs.release
//minifyEnabled true
//useProguard true
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

那么你可以:

flutter clean
flutter build appbundle --release

Mypubspec.yaml

name: [secret]
description: [secret]
https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.1.43
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
cupertino_icons: ^0.1.2
shared_preferences: ^0.5.2
cached_network_image: ^1.1.1
flutter_svg: ^0.13.1
rflutter_alert: ^1.0.3
flutter_bloc: ^0.11.1
equatable: ^0.1.6
flutter_secure_storage: ^3.2.1
local_auth: ^0.6.0+1
http_auth: ^0.2.5
firebase_core: ^0.4.0+9
firebase_messaging: ^5.1.6
validate: ^1.7.0
kiwi: ^0.1.0
image_picker: ^0.6.1
flutter_crashlytics: ^1.0.0
flutter_sticky_header: ^0.4.0
dio: ^2.1.0
auto_size_text: ^1.1.1
flutter_masked_text: ^0.8.0
permission_handler: '^3.2.0'
path_provider: ^0.5.0+1
flutter_email_sender: ^2.0.0
flutter_swiper: ^1.1.6
contacts_service: ^0.2.8
geolocator: ^5.1.1+1
google_maps_flutter: ^0.5.20+1
url_launcher: ^5.0.2
qr_mobile_vision: ^0.2.2
qr_flutter: ^2.0.0+51
csv: ^4.0.3
share_extend: ^1.0.8
country_pickers: ^1.1.0
diacritic: ^0.1.1
recase: ^2.0.1
keyboard_visibility: ^0.5.6
flutter_worldpay:
path: ../flutter_worldpay/
dev_dependencies:
flutter_test:
sdk: flutter
uses-material-design: true
fonts:
- family: Lato
fonts:
- asset: assets/fonts/Lato.ttf
- asset: assets/fonts/Lato-Light.ttf
weight: 300
- asset: assets/fonts/Lato-Bold.ttf
weight: 700
- family: Nunito
fonts:
- asset: assets/fonts/Nunito.ttf
- asset: assets/fonts/Nunito-Light.ttf
weight: 300
- asset: assets/fonts/Nunito-Bold.ttf
weight: 700

最后是我的flutter构建appbundle的结果——verbose:

[   +1 ms] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_crashlytics-1.0.0/android/src/main/java/com/kiwi/fluttercrashlytics/Utils.java:11: warning: [unchecked] unchecked cast
[   +2 ms]         final List<Map<String, Object>> traces = (List<Map<String, Object>>) exception.get("trace");
[        ]                                                                                           ^
[ +157 ms]   required: List<Map<String,Object>>
[        ]   found:    Object
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_crashlytics-1.0.0/android/src/main/java/com/kiwi/fluttercrashlytics/FlutterCrashlyticsPlugin.java:52: warning: [unchecked] unchecked cast
[        ]                         final List<Object> info = (List<Object>) call.arguments;
[        ]                                                                      ^
[        ]   required: List<Object>
[        ]   found:    Object
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_crashlytics-1.0.0/android/src/main/java/com/kiwi/fluttercrashlytics/FlutterCrashlyticsPlugin.java:87: warning: [unchecked] unchecked cast
[        ]                 final Map<String, Object> exception = (Map<String, Object>) call.arguments;
[  +15 ms]                                                                                 ^
[        ]   required: Map<String,Object>
[        ]   found:    Object
[        ] 3 warnings
[+4221 ms] > Task :flutter_email_sender:compileReleaseKotlin
.
.
.
.
[        ] /Users/axel/Documents/CSC/flutter_worldpay/android/src/main/java/com/corsicoin/flutter_worldpay/FlutterWorldpayPlugin.java:55: warning: [unchecked] unchecked conversion
[        ]             final HashMap<String, String> args = (HashMap) call.arguments;
[  +33 ms]                                                  ^
[        ]   required: HashMap<String,String>
[        ]   found:    HashMap
[        ] 1 warning
[ +597 ms] > Task :google_maps_flutter:compileReleaseJavaWithJavac
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_flutter-0.5.20+1/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java:244: warning: [unchecked] unchecked cast
[        ]           markersController.addMarkers((List<Object>) markersToAdd);
[        ]                                                       ^
[        ]   required: List<Object>
[        ]   found:    Object
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_flutter-0.5.20+1/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java:246: warning: [unchecked] unchecked cast
[        ]           markersController.changeMarkers((List<Object>) markersToChange);
[        ]                                                          ^
[  +11 ms]   required: List<Object>
[        ]   found:    Object
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_flutter-0.5.20+1/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java:248: warning: [unchecked] unchecked cast
[        ]           markersController.removeMarkers((List<Object>) markerIdsToRemove);
[        ]                                                          ^
[        ]   required: List<Object>
[        ]   found:    Object
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_flutter-0.5.20+1/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java:255: warning: [unchecked] unchecked cast
[        ]           polygonsController.addPolygons((List<Object>) polygonsToAdd);
[        ]                                                         ^
[        ]   required: List<Object>
[        ]   found:    Object
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_flutter-0.5.20+1/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java:257: warning: [unchecked] unchecked cast
[        ]           polygonsController.changePolygons((List<Object>) polygonsToChange);
[        ]                                                            ^
[        ]   required: List<Object>
[        ]   found:    Object
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_flutter-0.5.20+1/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java:259: warning: [unchecked] unchecked cast
[        ]           polygonsController.removePolygons((List<Object>) polygonIdsToRemove);
[  +10 ms]                                                            ^
[        ]   required: List<Object>
[        ]   found:    Object
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_flutter-0.5.20+1/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java:266: warning: [unchecked] unchecked cast
[        ]           polylinesController.addPolylines((List<Object>) polylinesToAdd);
[        ]                                                           ^
[        ]   required: List<Object>
[        ]   found:    Object
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_flutter-0.5.20+1/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java:268: warning: [unchecked] unchecked cast
[        ]           polylinesController.changePolylines((List<Object>) polylinesToChange);
[ +319 ms]                                                              ^
[        ]   required: List<Object>
[        ]   found:    Object
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_flutter-0.5.20+1/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java:270: warning: [unchecked] unchecked cast
[        ]           polylinesController.removePolylines((List<Object>) polylineIdsToRemove);
[        ]                                                              ^
[        ]   required: List<Object>
[        ]   found:    Object
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_flutter-0.5.20+1/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java:277: warning: [unchecked] unchecked cast
[  +72 ms]           circlesController.addCircles((List<Object>) circlesToAdd);
[        ]                                                       ^
[        ]   required: List<Object>
[        ]   found:    Object
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_flutter-0.5.20+1/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java:279: warning: [unchecked] unchecked cast
[        ]           circlesController.changeCircles((List<Object>) circlesToChange);
[        ]                                                          ^
[        ]   required: List<Object>
[        ]   found:    Object
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_flutter-0.5.20+1/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java:281: warning: [unchecked] unchecked cast
[ +285 ms]           circlesController.removeCircles((List<Object>) circleIdsToRemove);
[        ]                                                          ^
[        ]   required: List<Object>
[        ]   found:    Object
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_flutter-0.5.20+1/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java:573: warning: [unchecked] unchecked cast
[        ]     this.initialMarkers = (List<Object>) initialMarkers;
[        ]                                          ^
[        ]   required: List<Object>
[        ]   found:    Object
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_flutter-0.5.20+1/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java:585: warning: [unchecked] unchecked cast
[ +142 ms]     this.initialPolygons = (List<Object>) initialPolygons;
[        ]                                           ^
[        ]   required: List<Object>
[        ]   found:    Object
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_flutter-0.5.20+1/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java:597: warning: [unchecked] unchecked cast
[        ]     this.initialPolylines = (List<Object>) initialPolylines;
[        ]                                            ^
[        ]   required: List<Object>
[        ]   found:    Object
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_flutter-0.5.20+1/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java:609: warning: [unchecked] unchecked cast
[ +457 ms]     this.initialCircles = (List<Object>) initialCircles;
[        ]                                          ^
[        ]   required: List<Object>
[        ]   found:    Object
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_flutter-0.5.20+1/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java:352: warning: [unchecked] unchecked cast
[        ]       interpretInfoWindowOptions(sink, (Map<String, Object>) infoWindow);
[        ]                                                              ^
[        ]   required: Map<String,Object>
[        ]   found:    Object
[        ] 17 warnings
[        ] 
.
.
.
.
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/qr_mobile_vision-0.2.2/android/src/main/java/com/github/rmtmckenzie/qrmobilevision/QrCameraC1.java:6: warning: [deprecation] Camera in android.hardware has been
deprecated
[        ] import android.hardware.Camera;
[        ]                        ^
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/qr_mobile_vision-0.2.2/android/src/main/java/com/github/rmtmckenzie/qrmobilevision/QrCameraC1.java:7: warning: [deprecation] Camera in android.hardware has been
deprecated
[        ] import android.hardware.Camera.Size;
[        ]                        ^
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/qr_mobile_vision-0.2.2/android/src/main/java/com/github/rmtmckenzie/qrmobilevision/QrCameraC1.java:7: warning: [deprecation] Camera in android.hardware has been
deprecated
[ +108 ms] import android.hardware.Camera.Size;
[        ]                        ^
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/qr_mobile_vision-0.2.2/android/src/main/java/com/github/rmtmckenzie/qrmobilevision/QrCameraC1.java:7: warning: [deprecation] Camera.Size in Camera has been
deprecated
[        ] import android.hardware.Camera.Size;
[        ]                               ^
[        ] 4 warnings
[        ] > Task :qr_mobile_vision:transformClassesAndResourcesWithPrepareIntermediateJarsForRelease
[        ] > Task :share_extend:processReleaseJavaRes NO-SOURCE
[        ] > Task :share_extend:transformClassesAndResourcesWithPrepareIntermediateJarsForRelease
[        ] > Task :shared_preferences:generateReleaseBuildConfig
[  +48 ms] > Task :shared_preferences:prepareLintJar
[        ] > Task :shared_preferences:generateReleaseSources
[        ] > Task :shared_preferences:javaPreCompileRelease
[ +138 ms] > Task :shared_preferences:compileReleaseJavaWithJavac
[        ] > Task :shared_preferences:processReleaseJavaRes NO-SOURCE
[        ] > Task :shared_preferences:transformClassesAndResourcesWithPrepareIntermediateJarsForRelease
.
.
.
.
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.1.2/android/src/main/java/io/flutter/plugins/urllauncher/WebViewActivity.java:42: warning: [deprecation] shouldOverrideUrlLoading(WebView,String) in
WebViewClient has been deprecated
[   +1 ms]         public boolean shouldOverrideUrlLoading(WebView view, String url) {
[        ]                        ^
[        ] /Users/axel/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.1.2/android/src/main/java/io/flutter/plugins/urllauncher/WebViewActivity.java:47: warning: [deprecation] shouldOverrideUrlLoading(WebView,String) in
WebViewClient has been deprecated
[   +1 ms]           return super.shouldOverrideUrlLoading(view, url);
[        ]                       ^
[        ] 2 warnings
[+1308 ms] > Task :app:compileReleaseKotlin
[        ] > Task :app:prepareLintJar
[        ] > Task :app:generateReleaseSources
[  +88 ms] > Task :app:javaPreCompileRelease
[+4599 ms] > Task :app:compileReleaseJavaWithJavac
[        ] > Task :app:validateSigningRelease FAILED
[        ]          *********************************************************
[        ] WARNING: This version of firebase_core will break your Android build if it or its dependencies aren't compatible with AndroidX.
[        ]          See [somelink] for more information on the problem and how to fix it.
[        ]          This warning prints for all Android build failures. The real root cause of the error may be unrelated.
[        ]          *********************************************************
[        ] 335 actionable tasks: 334 executed, 1 up-to-date
[ +460 ms] Running Gradle task 'bundleRelease'... (completed in 322.4s, longer than expected)
[   +7 ms] "flutter appbundle" took 338,203ms.
Gradle task bundleRelease 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      buildAppBundle (package:flutter_tools/src/android/app_bundle.dart:43:10)
<asynchronous suspension>
#4      BuildAppBundleCommand.runCommand (package:flutter_tools/src/commands/build_appbundle.dart:47:11)
<asynchronous suspension>
#5      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:490:18)
<asynchronous suspension>
#6      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:407:33)
<asynchronous suspension>
#7      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154: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:153:18)
<asynchronous suspension>
#13     FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:397: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:402:21)
<asynchronous suspension>
#16     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154: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:153: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:63: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:61:18)
<asynchronous suspension>
#33     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154: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:153:18)
<asynchronous suspension>
#39     runInContext (package:flutter_tools/src/context_runner.dart:59:24)
<asynchronous suspension>
#40     run (package:flutter_tools/runner.dart:50:10)
#41     main (package:flutter_tools/executable.dart:65:9)
<asynchronous suspension>
#42     main (file:///Users/axel/flutter/packages/flutter_tools/bin/flutter_tools.dart:8:3)
#43     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:303:32)
#44     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)

对我来说,解决方案是完成以下步骤:


1。将此行:signingConfig signingConfigs.release添加到您的安卓>应用程序>build.gradle--andorid>buildTypes>release

android {

...

buildTypes{
release{
...
signingConfig signingConfigs.release
...
}
}

...

}

2.关闭并再次打开android工作室。PS:如果你在前几天或几个月完成了第一步


希望它能有所帮助!

相关内容

  • 没有找到相关文章

最新更新