[The 58th part of the Flutter problem series] The solution to the Android engineering problem that cannot be opened by right-clicking the Flutter project in Android Studio

This is the [58th article in the Flutter problem series]. If you find it useful, please pay attention to the column.

Current development environment
Flutter version: 2.2.3, Dart version: 2.13.4, OS: macOS Catalina 10.15.7 i9, Android Studio version: Arctic Fox 2020.3.1 Pathc 4.

One: problem description

For a newly created Flutter project, right-click the Flutter project name to open the native project, and (Open Android module in Android Studio)find that there is only one ios option, as shown in the figure below,
insert image description here
or right-click the android folder, the Flutter option at this time is grayed out,
insert image description here
what should I do in this case? Woolen cloth?

Two: Solutions

Manually create xxx_android.imla where xxx represents the file name. Although it can be specified as any character that conforms to the naming convention, the name of the Flutter project is generally used as the file name.

Then copy the following content to the xxx_android.imlfile .

<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
  <component name="FacetManager">
    <facet type="android" name="Android">
      <configuration>
        <option name="ALLOW_USER_CONFIGURATION" value="false" />
        <option name="GEN_FOLDER_RELATIVE_PATH_APT" value="/gen" />
        <option name="GEN_FOLDER_RELATIVE_PATH_AIDL" value="/gen" />
        <option name="MANIFEST_FILE_RELATIVE_PATH" value="/app/src/main/AndroidManifest.xml" />
        <option name="RES_FOLDER_RELATIVE_PATH" value="/app/src/main/res" />
        <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/app/src/main/assets" />
        <option name="LIBS_FOLDER_RELATIVE_PATH" value="/app/src/main/libs" />
        <option name="PROGUARD_LOGS_FOLDER_RELATIVE_PATH" value="/app/src/main/proguard_logs" />
      </configuration>
    </facet>
  </component>
  <component name="NewModuleRootManager" inherit-compiler-output="true">
    <exclude-output />
    <content url="file://$MODULE_DIR$">
      <sourceFolder url="file://$MODULE_DIR$/app/src/main/java" isTestSource="false" />
      <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
    </content>
    <orderEntry type="jdk" jdkName="Android API 30 Platform" jdkType="Android SDK" />
    <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="library" name="Flutter for Android" level="project" />
  </component>
</module>

The effect diagram is as follows
insert image description here
Then the effect diagram when right-clicking the Flutter project name is as follows The effect diagram of
insert image description here
right-clicking the android folder is as follows.
insert image description here
You can see that the original Flutter button is gray, and the Android option is also displayed.

Has your problem been resolved? Welcome to leave a message in the comment area.

Give someone a rose, and there is a lingering fragrance in your hand. If you think the article is good, I hope you can give a one-click three-link, thank you.


concluding remarks

Google's Flutter is getting more and more popular. As of January 14, 2022, the GitHub star has reached 134K. Flutter is resolutely a trend, so as a front-end developer, there is no reason not to learn as soon as possible.

Whether you are a Flutter novice or have already started, you might as well pay attention first. I will write the common components in Flutter (including source code analysis, component usage and precautions) and possible problems in the CSDN blog. I hope While learning by yourself, you can also help more people.

Guess you like

Origin blog.csdn.net/qq_42351033/article/details/122501679