Building plugins that depends on android using gradle plugin

Is there a place to download automated build for the android.jar plugin? I'd like to add that to the gradle plugin for intellij plugins.

Currently I must manually download  intellij community source code and build it after running the get plugins script in the root folder, and manually copying the android/android/..../android.jar file into my project.

Should I try and use the same URL as the IDE when installing a new plugin? That may not be optimal since I guess it won't be able to specify a specific jar version, but that's plan b.

Obviously the optimal choice would be that the gradle plugin had an option for adding that, but the docs don't mention it. My plan is to eventually extend the plugin and submit a PR in the long run.

14 comments
Comment actions Permalink
Official comment

Hi Fabio,

Sorry for delay. I've recreated the problem, but the thing is that I cannot find LaunchUtils and AndroidDevice classes neither in Android Studio 1.5.1 SDK nor in IntelliJ IDEA 15.0.3. I believe these classes were added later. You can use `144-SNAPSHOT` as an intellij version instead or one of build from 144 branch. Full list of available builds can be found here: https://www.jetbrains.com/intellij-repository/releases

Comment actions Permalink

Yes. It's able to download the required version of Intellij and use it as a dependency, but I still miss the android plugin aka android.jar when building. Maybe it can be added as a compile dependency as usual but I wouldn't know Its artifact name or in which repo to look for it. The repo that let's me download intellij is from jetbrains and it's not browseable or searchable.

Also today I had a weird problem, I could build just fine using the console but when doing the same on the IDE I had some missing classes, apparently they're new ones but I'm not sure.

0
Comment actions Permalink

1. What's the version of plugin are you using?
2. How did you configure the plugin?
3. Have you tried to use `plugins` setting of the plugin configuration?

Like

intellij {
  ...
  plugins 'android'
  ...
}

0
Comment actions Permalink

I wasn't and added that. I agree that should suffice but somehow there are some classes not found when compiling that were available when downloading and building intellij. I'll check if they come from versions after 15.0.1 or what other strange things are happening. At least now I get the same errors in intellij and console.

If you want to have a look at it here's the source code:


git clone git@github.com:fmatosqg/adb-idea.git
cd adb-idea
git checkout 8aa36f6
./gradlew buildPlugin


BTW I see intellij.plugins in the documantation but there's no clue as what values it can have or the syntax when you want more than one, they'd be nice for freshman plugin developers.

0
Comment actions Permalink

Thanks for project sample, I'll try to recreate the issue

0
Comment actions Permalink

Good news is that I could totally compile it with a small tweak, which was downloading Android Studio preview 2.1 and copying its own version of android.jar  that had those missing classes and everything else I needed. 

Bad news is that it's still not working, it's failing to do something important at run time. Since it's a fork from another github project I'll be contacting the primary developer for more insight. 

Is there a way for this plugin to ditch ALL idea IC dependencies and replace them with Android Studio ones, even if I was to have a local repository built by myself (which is the way it was done in the fork before I started migrating over the plugin). That would be the same as overriding the remote repository with a local repository and package Android Studio and make it look like an Idea IC package? Ideally it could just suck the linux zip build available for example here http://tools.android.com/download/studio/builds/2-1-preview-3 but a) I'm not sure how to do it and b) if it will work at all.

And since I'm having a runtime issue is there a way to debug it live?

0
Comment actions Permalink

oh found the intellij.alternativeIdePath option which will be very handy. Looking forward to using it.

0
Comment actions Permalink

Hi Fabio,

Sorry for the late response. I couldn't compile your project, but I couldn't find missing classes/methods in Android Studio sources as well.

> Is there a way for this plugin to ditch ALL idea IC dependencies and replace them with Android Studio ones

 

No and it shouldn't be needed. You just should use the same IntelliJ Platform build, so android.jar file would be the same for IDEA and Android Studio. Since Android Studio is built on top of 143.* platform builds you have to use IDEA 15.0.* as a dependency. Full list of available platform versions you can find here: https://www.jetbrains.com/intellij-repository/releases and here: https://www.jetbrains.com/intellij-repository/snapshots

 

> Bad news is that it's still not working, it's failing to do something important at run time.

 

Runtime issue should be fixed by using alternativeIdePath option.

 

0
Comment actions Permalink

This fork is too much trouble, fortunately I found another project that is very similar in what I want to do, and it's already on this plugin (ADB Wifi).

 

For the record, I think part of the problem may be because the build was targeted against Android Studio previews, so it's really bleeding edge. That explains the part where I had to copy android.jar over - I wouldn't expect those missing new classes to be available on IDEA 15 for a long time. But I think it brings into discussion that there's no way to develop against things that didn't come into the latest IDEA release, so it's kinda limiting the potential for the plugin.

I don't know about the fork model for AS and Idea, do they have their own branches that get merged to each other from time to time or is it only having IDEA code going into AS? And what about the android plugin, does it get the same development flow?

Either way it's a great piece of code, I think the very existence of this is extremely helpful. Keep up the amazing work here!

 

0
Comment actions Permalink

> I don't know about the fork model for AS and Idea, do they have their own branches that get merged to each other from time to time or is it only having IDEA code going into AS?

Android Studio is based on some IntelliJ Platform branch and JetBrains periodically merges android-specific changes from Android Studio into android-plugin of that branch. There is no guarantees that there is a release build with merged android-specific changes. So it's possible that you can't use some android API that wasn't merged yet. It also means that if you built your plugin against Android Studio there is no guarantees that it will work in IntelliJ IDEA.

The only solution for plugin-developers who want to use gradle-intellij-plugin and to build plugins agains AndroidStudio is to have maven-repository with Android Studio binary/source like we have for IDEA: https://www.jetbrains.com/intellij-repository/releases. If there is one you can just define `intellij.intellijRepo` property in your `build.gradle` to use it. It's better to ask at https://code.google.com/p/android/issues/list whether Google can do such repository.

0
Comment actions Permalink

Hi Alexander, how are you?

Firstly, nice to meet you.

I noticed you have a lot of experience with IntelliJ. 0/

I'm facing some problems to develop a plugin that depends of Android plugin. Initially, I was able to download the IDEA source code and create a single plugin (according the tutorial). I deployed the plugin and installed on Android Studio without problems.

Now, I'm trying to create a plugin to use some Android libraries (AndroidBridge, AndroidSdkUtils, etc). Could you help me?

In addition, I've also tried to create this plugin using Gradle, but I'm having problems to do it. I'm using the official tutorial, but it's not working.

Please, let me know if you could help. Your help will be essential to me.

Thank you so much.

Regards,

Robert Melo.

 

0
Comment actions Permalink

Hi Robert,

Nice to meet you too. I this I can help you to create a plugin using gradle-intellij-plugin. Feel free to ask questions about implementing IDE-plugins with Gradle in plugin's gitter or issue tracker

0
Comment actions Permalink

Hi Alexander! Sure. I'll move our thread conversation to the gitter.

Thanks a lot for you quick reply!

Cheers,

Robert.

0

Please sign in to leave a comment.