首页 > 解决方案 > android studio 3.5 之后 Flutter App 将无法构建 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!

标签: androidfirebaseandroid-studioflutterfirebase-cloud-messaging

解决方案


你只需要修改 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

推荐阅读