flutter intellij plugin: java language support?

后端 未结 2 1306
执笔经年
执笔经年 2021-01-14 00:25

In my setup the Intellij Flutter plugin doesn\'t support Java code. It treats Java classes like text files.

Is there any way I could get Intellij to support me with

2条回答
  •  囚心锁ツ
    2021-01-14 00:42

    It's possible by opening the Android app folder within your Flutter app directory in a second IntelliJ window: So one window for your Dart/Flutter code, another one for the Android Java code.

    Here is how it works: Make sure Android support is installed: File -> Settings -> Plugins -> Android Support.

    Now do the following steps (tested on Linux):

    1. Open the android folder of your Flutter app into a new project window. IntelliJ will detect that there is Android support, click on configure to use the existing manifest file.
    2. You might get a warning: "Failed to sync Gradle project 'android'. Click "Migrate to Gradle wrapper and sync project".
    3. If you get a Gradle error like: "Flutter SDK not found". Open the local.properties file in your Android project folder, and add the following configuration to it: flutter.sdk=/home/user/dev/flutter (using the correct folder on your system).

    There should be 3 entries in the local.properties file:

    sdk.dir=/home/raju/Android/Sdk
    flutter.sdk=/home/raju/dev/flutter
    flutter.buildMode=debug
    

    Now the Gradle build should run through.

    When you open the MainActivity.java in folder android/app/src/main/java/com.yourcompany.hello there should be full Java/Android support with autocomplete, etc.

    You can launch the Flutter app out of the Android project window, but then you will not have hot reload support active. So always use the project window with the Flutter project to launch. Or flutter run from the command line, if you prefer that.

提交回复
热议问题