flutter-intellij icon indicating copy to clipboard operation
flutter-intellij copied to clipboard

Android Studio indexing every 2 seconds

Open lwasyl opened this issue 8 years ago • 33 comments

In Android Studio 3.1 Beta 1 (and 3.2 Canary 1) indexing is triggered every 2 seconds, which makes e.g. code completion tooltips go away. Excerpt from the log (this continues forever):

2018-02-04 12:39:19,749 [e-1024-b01]   INFO - pl.ProjectRootManagerComponent - project roots have changed
2018-02-04 12:39:19,762 [ thread 11]   INFO - .diagnostic.PerformanceWatcher - Pushing properties took 1ms; general responsiveness: ok; EDT responsiveness: ok
2018-02-04 12:39:19,772 [ thread 11]   INFO - .diagnostic.PerformanceWatcher - Indexable file iteration took 10ms; general responsiveness: ok; EDT responsiveness: ok
2018-02-04 12:39:21,760 [e-1024-b01]   INFO - pl.ProjectRootManagerComponent - project roots have changed
2018-02-04 12:39:21,772 [ thread 12]   INFO - .diagnostic.PerformanceWatcher - Pushing properties took 0ms; general responsiveness: ok; EDT responsiveness: ok
2018-02-04 12:39:21,776 [ thread 12]   INFO - .diagnostic.PerformanceWatcher - Indexable file iteration took 4ms; general responsiveness: ok; EDT responsiveness: ok

This also happens when there's no tab with Flutter/Dart code.

Steps to Reproduce

  • Create new Flutter Project (in Android Studio 3.0, because of #1649);
  • open main.dart file
  • observe indexing

Version info

[✓] Flutter (on Mac OS X 10.13.3 17D47, locale en-PL, channel dev) • Flutter version 0.0.22 at /Users/wasyl/flutter • Framework revision 3001b3307d (5 days ago), 2018-01-30 11:37:15 -0800 • Engine revision 8f2d72b183 • Tools Dart version 2.0.0-dev.16.0 • Engine Dart version 2.0.0-edge.7af4db0ea091dddca6b2da851e6dda8d7f9467e8

[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3) • Android SDK at /Users/wasyl/Library/Android/sdk • Android NDK at /Users/wasyl/Library/Android/sdk/ndk-bundle • Platform android-27, build-tools 27.0.3 • ANDROID_HOME = /Users/wasyl/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)

[-] iOS toolchain - develop for iOS devices ✗ Xcode installation is incomplete; a full installation is necessary for iOS development. Download at: https://developer.apple.com/xcode/download/ Or install Xcode via the App Store. Once installed, run: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer ✗ libimobiledevice and ideviceinstaller are not installed. To install, run: brew install --HEAD libimobiledevice brew install ideviceinstaller ✗ ios-deploy not installed. To install: brew install ios-deploy ✗ CocoaPods not installed. CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your plugin usage on the Dart side. Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS. For more info, see https://flutter.io/platform-plugins To install: brew install cocoapods pod setup

[✓] Android Studio • Android Studio at /Applications/Android Studio 3.2 Preview.app/Contents • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

[✓] Android Studio • Android Studio at /Applications/Android Studio 3.1 Preview.app/Contents • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

[✓] Android Studio (version 3.0) • Android Studio at /Applications/Android Studio.app/Contents • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-915-b08)

[-] IntelliJ IDEA Community Edition (version 2017.3.3) ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. • For information about installing plugins, see https://flutter.io/intellij-setup/#installing-the-plugins

[-] Connected devices • None

lwasyl avatar Feb 04 '18 11:02 lwasyl

This is in android studio 3.1 (not in the stable android studio)?

This looks suspicious:

INFO - pl.ProjectRootManagerComponent - project roots have changed

but I'm not sure what would be causing it. This:

This also happens when there's no tab with Flutter/Dart code.

Makes me think that this is an issue with Android Studio itself, and not necessarily the Dart or Flutter plugins. Perhaps re-file this issue here: https://developer.android.com/studio/report-bugs.html ?

devoncarew avatar Feb 04 '18 21:02 devoncarew

I don't have much time, so will investigate later, but regular (big) Android project doesn't trigger indexing, and I've been working on 3.1 for a long time now, and never had this problem.

I've tinkered a bit with the project, removing things one by one, and at some point indexing stopped and seemed to work after I restored all the files. But as soon as I restarted Android Studio, indexing is resumed, and removing things from iml file doesn't seem to work.

Things I've tried that seem to help (sometimes) is removing and readding contents of configuration tag in .._android.iml project. This triggers autogeneration error and indexing stops, but I'm not sure whether everything works normally afterwards

lwasyl avatar Feb 05 '18 10:02 lwasyl

Fixed in https://github.com/flutter/flutter-intellij/pull/1908

stevemessick avatar Mar 19 '18 15:03 stevemessick

I just updated to Android Studio 3.1 and have the same problem. How do I convert my existing project to get rid of this constant refreshing?

The workaround of @lwasyl worked until I restarted Android Studio, when the issue came back.

geiszla avatar Mar 27 '18 13:03 geiszla

We're releasing a new version of the plugin shortly which will address this; thanks for your patience!

devoncarew avatar Mar 27 '18 13:03 devoncarew

For those who are curious, you need to change your android facet (in the module definition *.iml file) to include this:

<option name="ALLOW_USER_CONFIGURATION" value="false" />

That is required by a change in the Android Studio code that was made in 3.1. You can dig through #1908 for the details.

stevemessick avatar Mar 27 '18 16:03 stevemessick

@stevemessick where exactly do i put this in my .iml file(s)? I've tried in various spots and the indexing/insanity continues

acidjazz avatar Mar 28 '18 14:03 acidjazz

@acidjazz I've added that line in the <myproject>_android.iml file at the root (not in <myproject>.iml). It looks like this currently:

<?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="/android/gen" />
        <option name="GEN_FOLDER_RELATIVE_PATH_AIDL" value="/android/gen" />
        <option name="MANIFEST_FILE_RELATIVE_PATH" value="/android/AndroidManifest.xml" />
        <option name="RES_FOLDER_RELATIVE_PATH" value="/android/res" />
        <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/android/assets" />
        <option name="LIBS_FOLDER_RELATIVE_PATH" value="/android/libs" />
        <option name="PROGUARD_LOGS_FOLDER_RELATIVE_PATH" value="/android/proguard_logs" />
      </configuration>
    </facet>
  </component>
  <component name="NewModuleRootManager" inherit-compiler-output="true">
    <exclude-output />
    <content url="file://$MODULE_DIR$/android">
      <sourceFolder url="file://$MODULE_DIR$/android/app/src/main/java" isTestSource="false" />
      <sourceFolder url="file://$MODULE_DIR$/android/gen" isTestSource="false" generated="true" />
    </content>
    <orderEntry type="jdk" jdkName="Android API 27 Platform" jdkType="Android SDK" />
    <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="library" name="Flutter for Android" level="project" />
  </component>
</module>

lemonboston avatar Mar 28 '18 14:03 lemonboston

@acidjazz dude instead of waiting for someone else to fix - find a way. Download an older version of Android Studio, do some searching on StackOverflow, follow the instructions above. The longer you wait for someone else to solve your problems the more miserable you will become. Become your own hero.

SeaRoth avatar Mar 28 '18 15:03 SeaRoth

To fix the refresh issue on projects already open in 3.1 you need to close them then re-open them. Use the Welcome screen item named Open an existing Android Studio project. See #2017 for more info.

stevemessick avatar Mar 28 '18 15:03 stevemessick

@SeaRoth lol that's been the struggle.

@stevemessick closing and re-opening projects did not work.

I did finally find a way to stop the poltergeist was to kill my .idea folder completely and then re-activate the flutter and dart plugins, this was suggested by @tamcy here

acidjazz avatar Mar 28 '18 16:03 acidjazz

Thanks all for the feedback, and sorry for the indexing issues.

It sounds like from above, that deleting the .idea/ folder will work to address the re-indexing issue.

We're also looking to release a patch to the current release, which will disable the android studio setting (<option name="ALLOW_USER_CONFIGURATION" value="false" />) for each project once, as we open it.

devoncarew avatar Mar 28 '18 19:03 devoncarew

@devoncarew I'm sorry to be a bearer of bad news but that method didn't last long for me, see here

acidjazz avatar Mar 28 '18 19:03 acidjazz

Deleting the .idea/ folder works well for Android-Studio 3.1. Rollback Android studio to 2.3 also works :)

mt8024 avatar Apr 09 '18 03:04 mt8024

@stevemessick This is happening to me on a regular Android Java project - no Kotlin or Flutter involved. Deleting the .idea folder didn't solve the problem, nor did closing/re-opening the project or restarting the ide and even the computer.

I'm using Android Studio 3.1.1, Gradle 4.4 and Android Gradle plugin 3.1.1. My project is a multi-module project (not sure if it's related).

This causes the IDE to become unusable as it causes the UI to blink every second.

I've just noticed that this is a repo for flutter (arrived here from a Google search on AS indexing all the time) so this might not be the best place to post it. Sorry about that, but I couldn't find anywhere else where this issue was being discussed.

ifeins avatar Apr 23 '18 10:04 ifeins

I've submitted an Android Studio bug report - https://issuetracker.google.com/issues/78378464 Can you help investigate?

ifeins avatar Apr 23 '18 11:04 ifeins

Any stable solution yet? It seems to be unusable now.

Update: File -> Invalidate Caches / Restart.. helped me. Now don't see this problem with Android Studio 3.1.2

amitks2015 avatar Apr 30 '18 02:04 amitks2015

Hi - as per #2017 - if your comments are about continuous indexing when using Android Studio without it being a Flutter project, please follow up on the above Android Studio bug; thanks!

devoncarew avatar Apr 30 '18 02:04 devoncarew

File -> Invalidate Cache/ Restart... works for me

JotaFerreira avatar May 06 '18 20:05 JotaFerreira

not in this project ,I met this probrem more then one time, do it just clean project, and then is fine

andasl avatar May 25 '18 05:05 andasl