为flutter添加sqflite插件时无法构建APK

问题描述

我正在使用Flutter构建应用。我的应用程序中需要sq(f)lite插件。当我运行应用程序(使用真实设备)时没有错误。但是,当我尝试构建apk(Flutter build apk)时,我得到了错误

肯定使用了我以前使用过的sq(f)lite插件-可能是因为SDK BUILD TOOLS(?)是idk。原因是当我再次构建应用程序(Flutter build apk)时,肯定没有sq(f)lite插件,我没有收到错误;运行正常。

我的构建APK错误txt

Preparing "Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)".
Warning: Trying to install into C:\Android\tools\build-tools\28.0.3\ but package "Android SDK Tools" already exists at C:\Android\tools\. It must be deleted or moved away before installing into a child directory.
Checking the license for package Android SDK Platform 28 in C:\Android\tools\licenses
License for package Android SDK Platform 28 accepted.
Preparing "Install Android SDK Platform 28 (revision: 6)".
Warning: Trying to install into C:\Android\tools\platforms\android-28\ but package "Android SDK Tools" already exists at C:\Android\tools\. It must be deleted or moved away before installing into a child directory.


FAILURE: Build Failed with an exception.

* What went wrong:
A problem occurred configuring root project 'sqflite'.
> Failed to install the following SDK components:
      build-tools;28.0.3 Android SDK Build-Tools 28.0.3
      platforms;android-28 Android SDK Platform 28
  Install the missing components using the SDK manager in Android Studio.


* 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 35s

The plugin sqflite Could not be built due to the issue above.

我的构建APK详细错误txt

[   +5 ms] Running Gradle task 'assembleAarRelease'... (completed in 3.8s)
[   +2 ms] √ Built build\app\outputs\repo.
[   +1 ms] Building plugin sqflite...
[   +5 ms] Running Gradle task 'assembleAarRelease'...
[   +1 ms] gradle.properties already sets `android.enableR8`
[   +3 ms] Using gradle from C:\\Android\\Flutter\\.pub-cache\\hosted\\pub.dartlang.org\\sqflite-1.3.1+1\\android\gradlew.bat.
[   +1 ms] C:\\Android\\Flutter\\.pub-cache\\hosted\\pub.dartlang.org\\sqflite-1.3.1+1\\android\gradlew.bat mode: 33279 rwxrwxrwx.
[   +1 ms] executing: [C:\\Android\\Flutter\\.pub-cache\\hosted\\pub.dartlang.org\\sqflite-1.3.1+1\\android/]
C:\\Android\\Flutter\\.pub-cache\\hosted\\pub.dartlang.org\\sqflite-1.3.1+1\\android\gradlew.bat
-I=c:\Android\Flutter\packages\Flutter_tools\gradle\aar_init_script.gradle -PFlutter-root=c:\Android\Flutter
-Poutput-dir=C:\Users\rafikbojes\Documents\hitung_paketan\build\app -Pis-plugin=true -PbuildNumber=1.0 -Pverbose=true -Pfont-subset=true
-Ptarget-platform=android-arm,android-arm64,android-x64 assembleAarRelease
[+4081 ms]
                    > Configure project :
                    Observed package id 'tools' in inconsistent location 'C:\Android\tools' (Expected 'C:\Android\tools\tools')
                    Observed package id 'tools' in inconsistent location 'C:\Android\tools' (Expected 'C:\Android\tools\tools')
                    Checking the license for package Android SDK Build-Tools 28.0.3 in C:\Android\tools\licenses
                    License for package Android SDK Build-Tools 28.0.3 accepted.
                    Preparing "Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)".
                    Warning: Trying to install into C:\Android\tools\build-tools\28.0.3\ but package "Android SDK Tools" already exists at
                    C:\Android\tools\. It must be deleted or moved away before installing into a child directory.
                    Checking the license for package Android SDK Platform 28 in C:\Android\tools\licenses
                    License for package Android SDK Platform 28 accepted.
                    Preparing "Install Android SDK Platform 28 (revision: 6)".
                    Warning: Trying to install into C:\Android\tools\platforms\android-28\ but package "Android SDK Tools" already exists at
                    C:\Android\tools\. It must be deleted or moved away before installing into a child directory.


                    FAILURE: Build Failed with an exception.

                    * What went wrong:
                    A problem occurred configuring root project 'sqflite'.
                    > Failed to install the following SDK components:
                          build-tools;28.0.3 Android SDK Build-Tools 28.0.3
                          platforms;android-28 Android SDK Platform 28
                      Install the missing components using the SDK manager in Android Studio.


                    * 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 3s
[   +7 ms] Running Gradle task 'assembleAarRelease'... (completed in 4.1s)
[   +1 ms]
           > Configure project :
           Observed package id 'tools' in inconsistent location 'C:\Android\tools' (Expected 'C:\Android\tools\tools')
           Observed package id 'tools' in inconsistent location 'C:\Android\tools' (Expected 'C:\Android\tools\tools')
           Checking the license for package Android SDK Build-Tools 28.0.3 in C:\Android\tools\licenses
           License for package Android SDK Build-Tools 28.0.3 accepted.
           Preparing "Install Android SDK Build-Tools 28.0.3 (revision: 28.0.3)".
           Warning: Trying to install into C:\Android\tools\build-tools\28.0.3\ but package "Android SDK Tools" already exists at
C:\Android\tools\. It must be deleted or moved away before installing into a child directory.
           Checking the license for package Android SDK Platform 28 in C:\Android\tools\licenses
           License for package Android SDK Platform 28 accepted.
           Preparing "Install Android SDK Platform 28 (revision: 6)".
           Warning: Trying to install into C:\Android\tools\platforms\android-28\ but package "Android SDK Tools" already exists at
C:\Android\tools\. It must be deleted or moved away before installing into a child directory.

[   +2 ms]
           FAILURE: Build Failed with an exception.

           * What went wrong:
           A problem occurred configuring root project 'sqflite'.
           > Failed to install the following SDK components:
                 build-tools;28.0.3 Android SDK Build-Tools 28.0.3
                 platforms;android-28 Android SDK Platform 28
             Install the missing components using the SDK manager in Android Studio.


           * 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 3s

[   +8 ms] "Flutter apk" took 123,394ms.
[   +9 ms] The plugin sqflite Could not be built due to the issue above.
[   +2 ms]
           #0      throwToolExit (package:Flutter_tools/src/base/common.dart:14:3)
           #1      buildpluginsAsAar (package:Flutter_tools/src/android/gradle.dart:804:7)
           #2      _asyncErrorWrapperHelper.errorCallback (dart:async-patch/async_patch.dart:91:64)
           #3      _rootRunBinary (dart:async/zone.dart:1214:47)
           #4      _CustomZone.runBinary (dart:async/zone.dart:1107:19)
           #5      _FutureListener.handleError (dart:async/future_impl.dart:157:20)
           #6      Future._propagatetoListeners.handleError (dart:async/future_impl.dart:708:47)
           #7      Future._propagatetoListeners (dart:async/future_impl.dart:729:24)
           #8      Future._completeError (dart:async/future_impl.dart:537:5)
           #9      _AsyncAwaitCompleter.completeError (dart:async-patch/async_patch.dart:47:15)
           #10     buildGradleAar (package:Flutter_tools/src/android/gradle.dart)
           #11     _rootRunUnary (dart:async/zone.dart:1198:47)
           #12     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
           #13     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
           #14     Future._propagatetoListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
           #15     Future._propagatetoListeners (dart:async/future_impl.dart:725:32)
           #16     Future._completeWithValue (dart:async/future_impl.dart:529:5)
           #17     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
           #18     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
           #19     _DefaultProcessUtils.run (package:Flutter_tools/src/base/process.dart)
           #20     _rootRunUnary (dart:async/zone.dart:1198:47)
           #21     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
           #22     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
           #23     Future._propagatetoListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
           #24     Future._propagatetoListeners (dart:async/future_impl.dart:725:32)
           #25     Future._completeWithValue (dart:async/future_impl.dart:529:5)
           #26     Future.wait.<anonymous closure> (dart:async/future.dart:414:23)
           #27     _rootRunUnary (dart:async/zone.dart:1198:47)
           #28     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
           #29     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
           #30     Future._propagatetoListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
           #31     Future._propagatetoListeners (dart:async/future_impl.dart:725:32)
           #32     Future._completeWithValue (dart:async/future_impl.dart:529:5)
           #33     Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:567:7)
           #34     _rootRun (dart:async/zone.dart:1190:13)
           #35     _CustomZone.run (dart:async/zone.dart:1093:19)
           #36     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
           #37     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
           #38     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
           #39     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
           #40     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
           #41     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)


[ +270 ms] ensureAnalyticsSent: 266ms
[  +11 ms] Running shutdown hooks
[   +3 ms] Shutdown hooks complete
[   +7 ms] exiting with code 1

我的../ android / app / build.gradle

.. android { 编译版本28 sourceSets { main.java.srcDirs + ='src / main / kotlin' }

lintOptions {
    disable 'InvalidPackage'
}

defaultConfig {
    // Todo: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.example.xxx.xxx"
    minSdkVersion 16
    targetSdkVersion 28
    versionCode FlutterVersionCode.toInteger()
    versionName FlutterVersionName
}

signingConfigs {
   release {
       keyAlias keystoreProperties['keyAlias']
       keyPassword keystoreProperties['keyPassword']
       storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
       storePassword keystoreProperties['storePassword']
   }    }    buildTypes {
   release {
       signingConfig signingConfigs.release
   }    } } ...

我的../ android / build.gradle

buildscript { ext.kotlin_version ='1.3.50' 储存库{ 谷歌() jcenter() }

dependencies {
    classpath 'com.android.tools.build:gradle:3.5.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
} }

allprojects { 储存库{ 谷歌() jcenter() }

我的gradle.wrapper.properties

#Fri Jun 23 08:50:38 CEST 2017 distributionBase = GRADLE_USER_HOME distributionPath = wrapper / dists zipStoreBase = GRADLE_USER_HOME zipStorePath =包装器/ dists distributionUrl = https://services.gradle.org/distributions/gradle-5.6.2-all.zip

我扑扑的医生-v

[√] Flutter(Microsoft Windows上的Channel master,1.21.0-7.0.pre [版本10.0.18362.1016],语言环境为英语) •Flutter 1.21.0-7.0.pre版位于c:\ Android \ Flutter •框架修订版c748f1a7aa(6周前),2020-07-31 17:45:18 -0700 •发动机版本280bbfc763 •Dart版本2.10.0(内部版本2.10.0-2.0.dev bd528bfbd6)

[√] Android工具链-为Android设备开发(Android SDK 版本28.0.3) •位于c:// Android的Android SDK •平台android-29,构建工具28.0.3 •ANDROID_HOME = C:\ Android •ANDROID_SDK_ROOT = C:\ Android \ tools •Java二进制文件位于:C:\ Program Files \ Android \ Android Studio \ jre \ bin \ java •Java版本OpenJDK运行时环境(内部版本1.8.0_202-发行-1483-b03) •接受所有Android许可。

[√] Visual Studio-Windows开发(Visual Studio Community 2019 16.3.10) •位于C:\ Program Files(x86)\ Microsoft Visual Studio \ 2019 \ Community的Visual Studio •Visual Studio社区2019版本16.3.29519.87 •Windows 10 SDK版本10.0.17763.0

[√] Android Studio(版本3.5) •位于C:\ Program Files \ Android \ Android Studio的Android StudioFlutter插件版本41.1.2 •Dart插件版本191.8593 •Java版本OpenJDK运行时环境(内部版本1.8.0_202-发行-1483-b03)

[√] VS Code,64位版本(1.48.2版) •C:\ Program Files \ Microsoft VS代码中的VS代码Flutter扩展版本3.14.1

我的@R_781_5025@ager --list

路径|版本| 描述位置-------
| ------- | ------- | ------- 构建工具; 27.0.3 | 27.0.3 | Android SDK Build-Tools 27.0.3 |构建工具\ 27.0.3 \ build-tools; 28.0.3 | 28.0.3 | Android SDK Build-Tools 28.0.3 |生成工具\ 28.0.3 \ 仿真器| 30.0.26 | Android模拟器|模拟器\
extras; google; google_play_services | 49 |谷歌 游玩服务| extras \ google \ google_play_services \ extras; google; market_licensing
| 1 | Google Play许可库| extras \ google \ market_licensing \
Extras; intel; Hardware_Accelerated_Execution_Manager | 7.5.6 |英特尔 x86 Emulator Accelerator(HAXM安装程序)| extras \ intel \ Hardware_Accelerated_Execution_Manager \ patcher; v4
| 1 | SDK Patch Applier v4 | patcher \ v4 \ platform-tools | 30.0.4 | Android SDK平台-工具| platform-tools \ platform; android-20
| 2 | Android SDK平台20 | platform \ android-20 \ platforms; android-21
| 2 | Android SDK平台21 | platform \ android-21 \ platforms; android-22
| 2 | Android SDK平台22 | platform \ android-22 \ platforms; android-23
| 3 | Android SDK平台23 | platform \ android-23 \ platforms; android-24
| 2 | Android SDK平台24 | platform \ android-24 \ platform; android-25
| 3 | Android SDK平台25 | platform \ android-25 \ platforms; android-26
| 2 | Android SDK平台26 | platform \ android-26 \ platform; android-27
| 3 | Android SDK平台27 | platform \ android-27 \ platforms; android-28
| 6 | Android SDK平台28 | platform \ android-28 \ platforms; android-29
| 5 | Android SDK平台29 | platform \ android-29 \来源; android-20
| 1 | Android 20的来源| 来源\ android-20 \来源; android-21
| 1 | Android的来源21 | 来源\ android-21 \来源; android-22
| 1 | Android的来源22 | 来源\ android-22 \来源; android-23
| 1 | Android 23的来源| 来源\ android-23 \来源; android-24
| 1 | Android 24的来源| 来源\ android-24 \来源; android-25
| 1 | Android 25的来源| 来源\ android-25 \来源; android-26
| 1 | Android的来源26 | 来源\ android-26 \来源; android-27
| 1 | Android的来源27 | 来源\ android-27 \来源; android-28
| 1 | Android的来源28 | 来源\ android-28 \来源; android-29
| 1 | Android的来源29 | 来源\ android-29 \
system-images; android-27; google_apis_playstore; x86 | 3 |谷歌 播放Intel x86 Atom系统映像| system-images \ android-27 \ google_apis_playstore \ x86 \
系统映像; android-28;认; x86_64 | 4 |英特尔 x86 Atom_64系统映像| system-images \ android-28 \ default \ x86_64 \
system-images; android-28; google_apis_playstore; x86 | 9 |谷歌 播放Intel x86 Atom系统映像| system-images \ android-28 \ google_apis_playstore \ x86 \

我的gradle版本

5.6.1级

我的android sdk目录

my sdk directory

我的pubspec.yaml

...

环境:sdk:“> = 2.7.0

依赖项:Flutter_local_notifications:^ 1.4.4 + 4打开文件: ^ 3.0.1 downloads_path_provider:^ 0.1.0Permission_handler: ^ 4.4.0 + hotfix.2闪光:^ 1.1.1 fl_chart:^ 0.11.0 path_provider: ^ 1.6.11 awesome_dialog:^ 1.2.0 dio:^ 3.0.10 Flutter_svg:^ 0.18.0 国际:^ 0.15.8 sqflite:^ 1.2.0颤动: sdk:颤抖

cupertino_icons:^ 0.1.3

dev_dependencies:抽奖活动:^ 0.5.1 Flutter_test: sdk:颤抖

...

好,那是我当前的错误 我已经尝试解决此问题,例如@R_781_5025@ager更新等等。但是我很困惑阅读这样的所有stackoverflow问题:( 所以...您能给我一个提示/解决错误方法吗?

非常感谢,谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)