从 vs 代码中制作 APK

Sol*_*oft 0 android dart flutter flutter-dependencies

我面临着从 vs 代码中制作 APK 的问题。

我用来制作 APK 的命令。

flutter build apk --split-per-abi
Run Code Online (Sandbox Code Playgroud)

我尝试了大多数解决方案,例如检查 AndroidX 兼容性、Flutter Clean、pub get、pub update 等。我仍然在 vs 代码以及 android studio 中遇到以下错误,

请有人在这个过程中帮助我,我错过了一些东西。

Running Gradle task 'assembleRelease'...                                
                                                                
FAILURE: Build failed with an exception.                                                                           
                                                                                                                   
* What went wrong:                                                                                                 
Execution failed for task ':speech_recognition:verifyReleaseResources'.                                            
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade                  
   > 1 exception was raised by workers:                                                                            
     com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed                          
     /Users/company/.gradle/caches/transforms-2/files-2.1/fc785d3673ca7ec4009108d2721750b3/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/fontStyle not found.
                                                                                                                   
     /Users/company/.gradle/caches/transforms-2/files-2.1/fc785d3673ca7ec4009108d2721750b3/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/font not found.
                                                                                                                   
     /Users/company/.gradle/caches/transforms-2/files-2.1/fc785d3673ca7ec4009108d2721750b3/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/fontWeight not found.
                                                                                                                   
     /Users/company/.gradle/caches/transforms-2/files-2.1/fc785d3673ca7ec4009108d2721750b3/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.
                                                                                                                   
     /Users/company/.gradle/caches/transforms-2/files-2.1/fc785d3673ca7ec4009108d2721750b3/core-1.1.0/res/values/values.xml:142:5-173:25: AAPT: error: resource android:attr/ttcIndex not found.
                                                                                                                   
                                                                                                                   
                                                                                                                   
* Try:                                                                                                             
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.
                                                                                                                   
* Get more help at https://help.gradle.org                                                                         
                                                                                                                   
BUILD FAILED in 2m 49s                                                                                             
Running Gradle task 'assembleRelease'...                                                                           
Running Gradle task 'assembleRelease'... Done                     170.8s (!)
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
??  Creating `android/settings_aar.gradle`...                           
[!] Flutter tried to create the file `android/settings_aar.gradle`, but failed.
To manually update `settings.gradle`, follow these steps:

    1. Copy `settings.gradle` as `settings_aar.gradle`
    2. Remove the following code from `settings_aar.gradle`:

        def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
        def properties = new Properties()

        assert localPropertiesFile.exists()
        localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }

        def flutterSdkPath = properties.getProperty("flutter.sdk")
        assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
        apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"

Please create the file and run this command again.
Run Code Online (Sandbox Code Playgroud)

小智 9

对于调试 APK:

flutter build apk
Run Code Online (Sandbox Code Playgroud)

对于发布 APK:

flutter build apk --release
Run Code Online (Sandbox Code Playgroud)

对于应用程序包:

flutter build appbundle
Run Code Online (Sandbox Code Playgroud)