Flutter打包apk報錯:Your app isn't using AndroidX.

今天在學習Flutter開發的過程中,寫了一個基本的demo,想打個正式的安裝包apk,安裝在手機上體驗一下效果。

配置完了Android的簽名文件後,運行Flutter bulid app命令行,構建一個正式(release)包,在構建的過程中出現瞭如下的提示,但是可以構建成功。

<code>[!] Your app isn't using AndroidX.
 To avoid potential build failures, you can quickly migrate your app by following the steps on https://goo.gl/CP92wY./<code>


Flutter打包apk報錯:Your app isn't using AndroidX.

構建成功後的包在Android Studio IDE上是找不到的, 需要進入文件目錄中找到你的項目,打包好的項目就在:

打包好的APK位於/build/app/outputs/apk/app-release.apk。

但是有這個提示總是不爽的,是吧,想辦法解決掉它。

根據提示應該可以看出,當前咱們的的項目沒有使用AndroidX, 這個AndroidX是Android系統的極大的提升,所以說也是比較重要的。

<code>AndroidX is a major improvement to the original Android Support Library.
It provides the androidx.* package libraries, unbundled from the platform API. This means that it offers backward compatibility and is updated more frequently than the Android platform./<code>

在Flutter官網的說明中也專門提到了AndroidX Migration的遷移問題,通過問答的方式給出了一些對應的解決方案。

對於此項目構建Apk提示問題,只需要添加兩行代碼即可解決。

在gradle.properties中添加如下代碼即可:

<code>android.enableJetifier=true
android.useAndroidX=true/<code>
Flutter打包apk報錯:Your app isn't using AndroidX.

添加完之後,重新使用命令行:flutter build apk 就可以了,就不會出現上面那個提示了。

提示:

如果你已經在手機上安裝了調試版的APP,安裝正式版的APP之前要記得把原來debug的APP卸載掉。

歡迎關注我的公眾號:君偉說。


分享到:


相關文章: