-->

Idea intellij plugin not working in android studio

2019-02-25 15:07发布

问题:

I'm developing a test plugin for android studio, my plugin works (The actions created are visible ) in Android studio 1.5 when added using "install plugin from disk". But the same jar file is not working in Android studio 1.5.1. Below is the plugin.xml file. Please help.

<idea-plugin version="2">
<id>com.test.android.studio.plugin</id>
<name>test Android Studio Plugin</name>
<version>1.0</version>
<vendor email="test@test.com" url="http://www.test.com">test test Services Pvt. Ltd.</vendor>

<description>
Android Studio plugin to integrate test SDK
</description>

<change-notes>
 Release 0.0.1: Initial release.
</change-notes>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
<idea-version since-build="131"/>

<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
     on how to target different products -->
<!-- uncomment to enable plugin in all products-->
<depends>com.intellij.modules.lang</depends>

<extensions defaultExtensionNs="com.intellij">
    <!-- Add your extensions here -->
</extensions>

<actions>
    <!-- Add your actions here -->
    <group id="Test" class="org.test.plugin.actions.TestMainActionGroup" text="Test" description="Main Test invocation Action"
           popup="true">
        <add-to-group group-id="MainMenu" anchor="last"/>

        <action id="testMode" class="org.Test.plugin.actions.TestModeAction" text="Test Mode" description="Test mode action">
            <keyboard-shortcut keymap="$default" first-keystroke="ctrl k"/>
        </action>
        <action id="invocationCode" class="org.Test.plugin.actions.InvocationCodeAction" text="Invocation Code"
                description="Test mode action">
        </action>
        <action id="onlineDoc" class="org.Test.plugin.actions.OnlineDocAction" text="Online Documentation"
                description="Test mode action">
        </action>
        <action id="aboutUs" class="org.Test.plugin.actions.AboutUsAction" text="About Us" description="Test mode action">
        </action>
    </group>

</actions>

回答1:

As the other answer already pointed out the problem is caused by using a custom group class for the action group.

When you may need custom action group?

A Custom action group is needed only if you have some custom logic that controls the behavior of your group of actions, such as the group should be enabled on some selection in the editor,or on mouse hover ,or if you want to add actions dynamically to the group etc.

If the purpose of group is to group the predefined actions and display it in a particular location the default action group is all that you need and it can be easily accomplished by following lines

 <group id="Test" text="Test" description="Main Test invocation Action"
       popup="true">
    <add-to-group group-id="MainMenu" anchor="last"/>
    <!--List of predefined actions here  -->
</group>

Note that the class attribute from the group tag is removed. Now the IDE considers its group as Default Action Group.



回答2:

The problem is caused by using a custom group class for the action group you add to the main menu. This is not supported in some versions of IntelliJ IDEA/Android Studio.