Search code examples
intellij-ideaintellij-pluginandroid-studio-4.2android-studio-plugin

Where did AndroidModuleModel.findProductFlavor go? My plugin throws NoSuchMethodError


I'm the author of this build variant plugin, and from Android Studio 4.1 to 4.2.1, a method I depend on seems to have been removed from the IDE API: ProductFlavorContainer com.android.tools.idea.gradle.project.model.AndroidModuleModel.findProductFlavor(String)

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?

The concrete exception I'm getting is on this line, with this text:

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.actions.AndroidModuleHelper.createMergedDimensionList(AndroidModuleHelper.kt:38)

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


Solution

  • Method had been replaced with new signature:

    public IdeProductFlavorContainer findProductFlavor(@NotNull String name) 
    

    The problem was getting IDEA to resolve that class when no new IDEA target library had been published for Android Studio 4.2.x. Solution: in build.gradle target your local installation by using intellij.localPath instead of intellij.version

    Thanks to Kuznetsov at Jetbrains in this thread