Flutter 项目 &Android X 迁移问题 [英] Flutter Projects & Android X Migration Issues

查看:16
本文介绍了Flutter 项目 &Android X 迁移问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚创建了一个新的 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!".

所以我所做的是:

  1. 将 Android Studio 更新至 3.3
  2. 尝试菜单重构 > 迁移到 AndroidX
  3. 得到未找到任何用法"(如果您设法在此处执行此操作,请停止!大功告成!...实际上,您可以给 这个答案 在继续之前先试一试)
  4. 打开android/gradle.properties并添加
  1. updated Android Studio to 3.3
  2. tried menu Refactor > Migrate to AndroidX
  3. 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)
  4. opened android/gradle.properties and added

android.useAndroidX=true
android.enableJetifier=true

  1. 打开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 version 3.3.0
  • com.google.gms:google-services to version 4.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 to 28
  • replaced android.support.test.runner.AndroidJUnitRunner to androidx.test.runner.AndroidJUnitRunner
  • replaced com.android.support.test:runner to androidx.test:runner:1.1.0
  • replaced com.android.support.test.espresso:espresso-core to androidx.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆