Flutter 项目 &Android X 迁移问题 [英] Flutter Projects & Android X Migration Issues
问题描述
我刚刚创建了一个新的 flutter 项目,添加了一些插件,我正在将插件切换到 android x,因此我需要切换到 android x.我已经尝试了所有不同的移动到 android x 的方法,但到目前为止没有一个对我有用.现在我什至不知道该怎么办了,太令人沮丧了,为什么在自动创建新项目时不处理它.可能会在项目中使用 ionic.
I just created a new flutter project, added a few plugins and I'm getting the plugin switched to android x therefore i need to switch to android x. I've tried all the different ways of moving to android x and none has worked for me so far. Right now i don't even know what to do anymore, its so frustrating, why wouldn't flutter handle that when creating new projects automatically. Might be using ionic for the project.
推荐答案
在创建新项目时,只需按照 @harsh 's 回答,你就完成了.
As you are creating a new project, just follow @harsh 's answer and you're done.
但是,由于我最近升级了现有应用程序以使用新插件,因此我也必须迁移到 AndroidX……以及 官方说明 不起作用,这是使用 Android Studio 迁移项目 - 它说找不到用法!".
However, as I recently upgraded my existing app to use new plugins, I had to migrate to AndroidX as well... and the default procedure in the official instructions didn't work, which is using Android Studio to migrate the project - it said "No usages found!".
所以我所做的是:
- 将 Android Studio 更新至 3.3
- 尝试菜单重构 > 迁移到 AndroidX
- 得到未找到任何用法"(如果您设法在此处执行此操作,请停止!大功告成!...实际上,您可以给 这个答案 在继续之前先试一试)
- 打开
android/gradle.properties
并添加
- updated Android Studio to 3.3
- tried menu Refactor > Migrate to AndroidX
- got "No usages found" (if you manage to do it here instead, stop! you're done! ... actually, you can give this answer a try before continuing)
- opened
android/gradle.properties
and added
android.useAndroidX=true
android.enableJetifier=true
打开
android/build.gradle
并修改
com.android.tools.build:gradle
到版本3.3.0
com.google.gms:google-services
到版本4.2.0
com.android.tools.build:gradle
to version3.3.0
com.google.gms:google-services
to version4.2.0
打开android/app/build.gradle
和
- 将
compileSdkVersion
改为28
- 将
android.support.test.runner.AndroidJUnitRunner
替换为androidx.test.runner.AndroidJUnitRunner
- 将
com.android.support.test:runner
替换为androidx.test:runner:1.1.0
- 将
com.android.support.test.espresso:espresso-core
替换为androidx.test.espresso:espresso-core:3.1.0
- 就我而言,就是这样,但这里是 所需替换的完整列表
- changed
compileSdkVersion
to28
- replaced
android.support.test.runner.AndroidJUnitRunner
toandroidx.test.runner.AndroidJUnitRunner
- replaced
com.android.support.test:runner
toandroidx.test:runner:1.1.0
- replaced
com.android.support.test.espresso:espresso-core
toandroidx.test.espresso:espresso-core:3.1.0
- in my case that was it, but here's the complete list of required replacements
打开 android/gradle/wrapper/gradle-wrapper.properties
并将 distributionUrl
更改为 https://services.gradle.org/distributions/gradle-4.10.2-all.zip
(您可能必须使用 5.4.1,请参阅下面的更新)
opened android/gradle/wrapper/gradle-wrapper.properties
and changed distributionUrl
to https://services.gradle.org/distributions/gradle-4.10.2-all.zip
(you might have to use 5.4.1, please see update below)
执行了flutter clean
与我的预期相反,它奏效了!:)
And contrary to what I expected, IT WORKED! :)
更新我的应用程序以使其颤动 v1.9.1+hotfix.5
时,当我使用应用程序签名时,我遇到了错误 SigningConfig "release" is missing required property "storePassword"
最后是上面第 7 步的 gradle 版本.所以现在我按照 维基.
When updating my app to flutter v1.9.1+hotfix.5
, as I use app signing, I was stuck with the error SigningConfig "release" is missing required property "storePassword"
and in the end it was the gradle version from step 7 above. So now I'm using 5.4.1 as suggested in this wiki.
[android/gradle/wrapper/gradle-wrapper.properties]
distributionUrl=https://services.gradle.org/distributions/gradle-5.4.1-all.zip
这篇关于Flutter 项目 &Android X 迁移问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!