Where did AndroidModuleModel.findProductFlavor go? My plugin throws NoSuchMethodError


I am the author of this plugin and it has been working well up until now. 

The method AndroidModuleModel.findProductFlavor() existed and works on Androd Studio 4.1, but when upgrading to 4.2.1 my users (and me) are experiencing an exception:

2021-06-16 23:04:54,348 [ 157042] ERROR - llij.ide.plugins.PluginManager - 'com.android.builder.model.ProductFlavorContainer com.android.tools.idea.gradle.project.model.AndroidModuleModel.findProductFlavor(java.lang.String)' 
java.lang.NoSuchMethodError: 'com.android.builder.model.ProductFlavorContainer com.android.tools.idea.gradle.project.model.AndroidModuleModel.findProductFlavor(java.lang.String)'
at com.nilsenlabs.flavormatrix.models.MyProductFlavor.findInModule(MyProductFlavor.java:18)

In the master branch for the source code for the android plugin of IDEA, it seems to still be there though! What's going on here?

Actually when I debug the code and run the line in the inspector using JAVA instead of KOTLIN, I'm getting that the code returns a object of type "IdeProductFlavorContainerImpl". However I can't find any way to reference that class in the source code. It does not resolve nor compile.

Please help. My plugin broke in production and I don't know how to fix it

My build environment is IntelliJ IDEA community edition 2020.2.4, Build #IC-202.8194.7

The original target version was Android Studio version 193.6911.18

I've tried updating the target version to 202.7660.26 (Android Studio 4.2.1) to no avail. I've also tried upgrading to org.jetbrains.intellij plugin to v1.0.


Hi Frode,


Excellent. What do you suggest for me as a resolution? Wait until 4.2.1 sources are merged and published? Or will changing to `intellij.localPath` fix it? (I tried briefly but met some hurdles with a ideaLocal-*.xml that it couldn't write to)


I suggest using intellij.localPath and building against real Android Studio distribution. This should fix your problem.

Android Studio and IDEA are two different products independently developed by two different companies (Google and JetBrains). In the context of current issue important difference is the following: IDEA always has the latest platform, but outdated Android plugin. Android Studio always has the latest Android plugin, but outdated platform. For example, IDEA 2020.2 has platform version 202, and android plugin version 4.0. Android Studio 4.2 has platform version 202 and Android plugin version 4.2, IDEA 2021.2 has platform version 212 and android plugin version 4.2.

The function in question has already changed in 4.2, there is no need to wait for 4.2.1 sources.

What kind of problems do you have with the localPath? Just for the record: intellij.version and intellij.localPath should not be specified at the same time.


I solved it by runing IDEA as administrator on Windows. Writing to "c:\program files" is a bit protected. The new classes resolve correctly now so I should be able to build and publish a new version. Thanks for great support!

For the record the error I got was:

Could not determine the dependencies of task ':prepareSandbox'.
> Failed to query the value of task ':prepareSandbox' property 'librariesToIgnore'.
> Could not write to file 'C:\Programfiler\android\Android Studio\ideaLocal-AI-202.7660.26.42.7351085-1-withKotlin.xml'.

I solved it by runing IDEA as administrator on Windows.

Thank you for information. Alternatively you can use "no-exe" installer (https://developer.android.com/studio#downloads), unpack the Studio to some place where writing is allowed, and use that instance for localPath variable.