pbreault / adb-idea

A plugin for Android Studio and Intellij IDEA that speeds up your day to day android development.
Apache License 2.0
2.11k stars 255 forks source link

Gradle build #43

Closed fmatosqg closed 8 years ago

fmatosqg commented 8 years ago

Work in progress.

Builds are good but runtime is failing to choose proper device.

Use intellij.alternativeIdePath = '/Users/fmatos/bin/astudio/Android_Studio_preview.app' to run with an alternative version of the IDE (not used at build time).

pbreault commented 8 years ago

@fmatosqg Awesome work so far, very excited about this!

I wasn't able to make it work but it looks like the problem is that we are bundling the android jar with the plugin. build/distributions/adb_idea-1.3.1.zip takes 7mb instead of 60k.

The solution seems to be to add the plugin as a provided dependency using something like this:

configurations {
    provided
}

sourceSets {
    main {
        resources {
            exclude 'website/adb_operations_popup.pn'
            exclude 'website/find_actions.png'
        }

        compileClasspath += configurations.provided
    }
}

In order to test with the correct plugins, I forced the whole plugin directory to be added:

dependencies {
    provided fileTree(dir: '/Applications/Android Studio Preview.app/Contents/plugins/android/lib', include: ['*.jar'])
}

Then I ended up with another dependency problem:

.../CanRunOnDeviceCompat.java:30: error: method canRunOnDevice in class LaunchCompatibility cannot be applied to given types;
        return LaunchCompatibility.canRunOnDevice(myMinSdkVersion, myProjectTarget, myRequiredHardwareFeatures, androidDevice);
                                  ^
  required: AndroidVersion,IAndroidTarget,EnumSet<HardwareFeature>,IDevice,IAndroidTarget
  found: AndroidVersion,IAndroidTarget,EnumSet<HardwareFeature>,AndroidDevice
  reason: actual and formal argument lists differ in length

Looking at the jars, it seems like this is warranted because the signature don't match. I'll take another stab at it soon.

fmatosqg commented 8 years ago

1- does this signature match Idea 15.0.5? Because it's also included in the dependencies. 2- I got the impression that you can compile without the "filetree..." chunk, can you confirm that? And if this is true, can you actually run it properly? I know it won't use the correct plugins, but this is the very part where I was stuck and couldn't get solved.

I'll try later when I get home

fmatosqg commented 8 years ago

I pushed commit 5429489, which I think is halfway to solve what you mentioned. It explicitly excludes all dependencies on Intellij jars (pushed down my throat by the intellij plugin) and totally replaced by android studio jars, which was enough to get everything compiled.

Still pending is using the 'provided' thing, since now we have a fat jar with android studio jars included instead of intellij.

For the record, I could get to this error when opening on Android Studio 2.1 preview 5. Can you tell us which preview version of android studio this code is compatible with? I'm not sure that's it but it may be a good way to steer clear of problems.

00:08:55 Plugin Error: ADB Idea threw an uncaught IllegalStateException. Disable Plugin 00:08:55 IllegalStateException: class with name 'com.developerphil.adbidea.action.QuickListAction' must be an instance of 'com.intellij.openapi.actionSystem.AnAction'; got null (null)

fmatosqg commented 8 years ago

@pbreault Fixed and working.

I think the next steps would be creating an .md file for plugin developers and squashing a couple of commits that were made for testing ideas that turned out bad.

pbreault commented 8 years ago

Great work! I was able to compile and deploy using Android Studio 2.1 Beta 3 and it worked flawlessly.

Here are the few things necessary for me to merge this PR:

I will take care of updating the documentation.

Thanks!

fmatosqg commented 8 years ago

Since rebasing was a nightmare and ended up messing with the latest master commits I manually re-did all changes from scratch on top of the latest master.

I did some quick testing and it's still working as before, but you may want to make some smoke testing.

If you copy gradle.properties.change_me as gradle.properties it should just work - depending on your environment of course.

pbreault commented 8 years ago

@fmatosqg Working awesomely, merging it right now. Thanks for your contribution!

fmatosqg commented 8 years ago

@pbreault Awesome

It's now allowed to have this project listed under https://github.com/JetBrains/gradle-intellij-plugin/blob/master/README.md, may I have your blessing?

pbreault commented 8 years ago

Of course, thanks :)