简体   繁体   English

Android Studio 未创建 main.dart 文件

[英]Android Studio not creating main.dart file

I'm new to programming so please be genetle.我是编程新手,所以请保持温和。 I'm handy with computers though and I've been sitting on this problem for a few weeks while learning flutter and dart虽然我对计算机很方便,但在学习 flutter 和 dart 时,我已经解决这个问题几个星期了

When I create a new flutter application in android studio, it does not create a main.dart file - the libs foder is empty, and I also see no IOS folder. When I create a new flutter application in android studio, it does not create a main.dart file - the libs foder is empty, and I also see no IOS folder. In fact, what I see looks VERY different from any tutorials I've seen !!事实上,我所看到的与我所看到的任何教程都非常不同!

What I do see is a bunh of.xml files, including one called activity main which runs a main activity function which almost seems like it is there instead of the main.dart file I'm looking for.我所看到的是一堆 .xml 文件,包括一个名为 activity main 的文件,它运行一个主要活动 function ,它几乎看起来就像它在那里而不是 main.ZBB14127678960FAE967D873950ZEA2 文件。

I have run flutter doctor, apparently everything is good.I have the dart and futter plugins installed.我已经运行了 flutter 医生,显然一切都很好。我安装了 dart 和 futter 插件。 It is not a case of selecting "project" from the drop down menu instead of "Android" which is a common answer online.这不是从下拉菜单中选择“项目”而不是“Android”的情况,这是在线常见的答案。 Not sure what I'm missing !!不知道我错过了什么!

Any help would be really really appreciated as I'm learning to code to open my next business and I am struggling to get over the first hurdle.... at leasr I am proficient wit dartpad now though:P任何帮助都会非常感激,因为我正在学习编写代码以打开我的下一个业务并且我正在努力克服第一个障碍....至少我现在精通 dartpad:P

EDIT:编辑:

When I click on 'file > new > new flutter project', I don't see an option for "flutter application".当我单击“文件 > 新建 > 新建 flutter 项目”时,我没有看到“颤振应用程序”选项。 This is what I see... enter image description here这就是我所看到的...在此处输入图像描述

If I create a flutter project at this point, this is what Android Studio looks like for me... enter image description here如果我此时创建一个 flutter 项目,这就是 Android Studio 对我来说的样子......在此处输入图像描述

If you have properly created a Flutter project in Android studio, main.dart file should be very easy to locate.如果您在 Android 工作室中正确创建了 Flutter 项目,那么 main.dart 文件应该很容易找到。 It is located in project_name -> lib -> main.dart, as follows:它位于project_name -> lib -> main.dart,如下:

在此处输入图像描述

I am sharing steps to create flutter project in android studio: Step 1: Open the IDE and select Start a new Flutter project. I am sharing steps to create flutter project in android studio: Step 1: Open the IDE and select Start a new Flutter project.

在此处输入图像描述

Step 2: Select the Flutter Application as the project type.步骤2:Select Flutter Application 作为项目类型。 Then click Next.然后单击下一步。

在此处输入图像描述

Step 3: Verify the Flutter SDK path specifies the SDK's location (select Install SDK… if the text field is blank).第 3 步:验证 Flutter SDK 路径指定了 SDK 的位置(如果文本字段为空白,请选择安装 SDK...)。

Step 4: Enter a project name (for example, myapp).第 4 步:输入项目名称(例如,myapp)。 Then click Next.然后单击下一步。

在此处输入图像描述

Step 5: Click Finish.第五步:点击完成。 在此处输入图像描述

Step 6: Wait for Android Studio to install the SDK and create the project.第6步:等待Android Studio安装SDK并创建项目。

Note: When creating a new Flutter app, some Flutter IDE plugins ask for a company domain name in reverse order, something like com.example. Note: When creating a new Flutter app, some Flutter IDE plugins ask for a company domain name in reverse order, something like com.example. The company domain name and project name are used together as the package name for Android (the Bundle ID for iOS) when the app is released.应用发布时,公司域名和项目名称一起用作 Android 的 package 名称(iOS 的 Bundle ID)。 If you think that the app might be released, it's better to specify the package name now.如果您认为应用程序可能会发布,最好现在指定 package 名称。 The package name can't be changed once the app is released, so make the name unique. package 名称在应用发布后无法更改,因此请确保名称唯一。

The above steps create a Flutter project directory called flutter_app that contains a simple demo app that uses Material Components.上述步骤创建了一个名为 flutter_app 的 Flutter 项目目录,其中包含一个使用 Material Components 的简单演示应用程序。

Running the application:运行应用程序:

Follow the below steps to run the flutter application that was structured above:按照以下步骤运行上述结构的 flutter 应用程序:

Step 1: Locate the main Android Studio toolbar:第 1 步:找到 Android Studio 主工具栏:

在此处输入图像描述

Step 2: In the target selector, select an Android device for running the app.第 2 步:在目标选择器中,select 和 Android 设备用于运行应用程序。 If none are listed as available, select Tools> Android > AVD Manager and create one there.如果没有列出可用,select Tools> Android > AVD Manager 并在那里创建一个。 For details, see Managing AVDs.有关详细信息,请参阅管理 AVD。

Step 3: Click the run icon in the toolbar, or invoke the menu item Run > Run.第 3 步:单击工具栏中的运行图标,或调用菜单项运行 > 运行。

After the app build completes, you'll see the starter app on your device.应用构建完成后,您将在设备上看到入门应用。

在此处输入图像描述

as per screen shot shared by you click on flutter , hopefully this will create a new flutter project.根据您共享的屏幕截图,单击flutter ,希望这将创建一个新的 flutter 项目。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM