在Kotlin Multiplatform应用中使用Flutter模块

发布于 2025-02-06 16:50:44 字数 1572 浏览 3 评论 0 原文

我使用Kotlin MultipLatform创建了一个应用程序,现在我希望使用Flutter一次开发UI。我跟随 tutorial 在已经存在的Android应用程序中的扑波-Modules-source-code“ rel =“ nofollow noreferrer”>选项b 一步一步地编译所有内容。

第一个麻烦是在主机应用程序中将“颤音”模块作为子标记包括:在Kotlin Multiplatform项目中,我必须重命名 settings.gradle.kts to settings.gradle 。然后,我还有另一个错误,我无法摆脱:引起的:要自定义主机应用程序名称,请设置'org.gradle.project.flutter.hostappprojectName =< project-name>'在gradle.properties ..表达式:( appProject!= null)。值:appProject = null

我了解错误的含义:使用Kotlin MultiplAtform,该项目未称为 App ,而是该应用程序的名称,在我的情况下,在我的情况下 MusicTraining 。因此,正如Kotlin文档中提到的那样:

提示:默认情况下,主机应用程序提供:应用程序Gradle项目。要更改此项目的名称,请在Flutter模块的gradle.properties文件中设置Flutter.hostappProjectName。最后,将此项目包括在主机应用程序的设置中。

因此,在颤音模块的gradle.properties文件中,我尝试添加行:

  • flutter.hostappprojectName =“ musicTraining”
  • flutter.hostappprojectname =“:musicTraining”

我仍然有一个相同的错误。

我尝试使用vscode将所有实例:app 更改为:MusicTraining ,但无效。我仍然有同样的错误。

正如错误提及的那样,我尝试添加行

  • org.gradle.project.project.flutter.hostappprojectName =“ musicTraining”
  • org.gradle.project.flutter.flutter.hostappprojectname =“代码>

在Flutter模块的gradle.properties文件中,但仍然存在相同的错误。

如何在Kotlin Multiplatform应用中集成颤音模块?

I created an application with kotlin multiplatform and I want now to use flutter to develop the UI once. I followed the tutorial to integrate flutter in an already existing Android app and I choose option B to compile everything in one step.

The first trouble is including the Flutter module as a subproject in the host app: in the kotlin multiplatform project, I have to rename the settings.gradle.kts to settings.gradle. Then I have another error I can't get rid of: Caused by: java.lang.AssertionError: Project :app doesn't exist. To custom the host app project name, set 'org.gradle.project.flutter.hostAppProjectName=<project-name>' in gradle.properties.. Expression: (appProject != null). Values: appProject = null

I understand what the error means: with kotlin multiplatform, the project is not called app but the name of the app, in my case MusicTraining. So as mentioned in the kotlin documentation:

Tip: By default, the host app provides the: app Gradle project. To change the name of this project, set flutter.hostAppProjectName in the Flutter module’s gradle.properties file. Finally, include this project in the host app’s settings.gradle file mentioned below.

So, in the flutter module's gradle.properties file I tried to add the lines:

  • flutter.hostAppProjectName="MusicTraining"
  • flutter.hostAppProjectName=":MusicTraining"

I still have the same error.

I tried with vscode to change all instances of :app to :MusicTraining but nothing works. I still have the same error.

As the error mention, I tried to add the line

  • org.gradle.project.flutter.hostAppProjectName="MusicTraining"
  • org.gradle.project.flutter.hostAppProjectName=":MusicTraining"

in the flutter module's gradle.properties file, but still the same error.

How can I integrate a flutter module in a kotlin multiplatform app?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

熊抱啵儿 2025-02-13 16:50:45

尝试添加 flutter.hostappprojectName = musicTraining in gradle.properties文件,带有flutter模块和您的root项目。

注意: 运行您本机应用程序,如果您运行Main.dart,您仍然会遇到此错误

我遇到同样的问题,这对我有用。

Try to add flutter.hostAppProjectName=MusicTraining into gradle.properties file with both Flutter module and you root project.

Notice: run you native application, If you run main.dart, you still get this error

I face the same problem, this works for me.

垂暮老矣 2025-02-13 16:50:45

如果您已经有了Kotlin Multiplatform项目,我将使用JetBrains构成乘数而不是颤动。撰写与Flutter非常相似,您将避免使用技术。

If you already have a Kotlin multiplatform project, I'd use Jetbrains Compose multiplatform instead of Flutter. Compose is very similar to Flutter and you would avoid the technology split.

https://www.jetbrains.com/de-de/lp/compose-mpp/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文