• Stars
    star
    129
  • Rank 269,559 (Top 6 %)
  • Language
    Groovy
  • License
    Apache License 2.0
  • Created about 9 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Gradle plugin to use Android AAR libraries on Eclipse.

gradle-eclipse-aar-plugin

Build Status Coverage Status Maven Central

Gradle plugin to use Android AAR libraries on Eclipse.
With this plugin, you can manage dependencies with Gradle and build app on Eclipse.

Android Studio has been officially released, but some of you still want/are forced to use Eclipse ADT for some reasons. Android Studio has much better build system by integrating Gradle, and many of the remarkable features are unavailable in Eclipse. In particular, many Android libraries are provided with AAR format recently, so it's now big disadvantage for Eclipse to manage these dependencies. This plugin will explode AAR libraries and create "Android Library Project"s or copy JARs for your project by executing just one command, and you just import these projects in Eclipse.

Originally I was inspired by this article, then rewrote almost all of it and added many improvements to automate conversion process and to cover several dependency/project conditions.

How it works

Prerequisites

Eclipse ADT is no longer maintained by Google, and it's forked into the Andmore project.

This plugin is tested under these conditions.

For the original Eclipse ADT Plugin developed by Google, the plugin is tested under the following conditions.

Usage

Prepare build.gradle

If your project already uses Gradle and Android Studio, just apply this plugin.

Gradle 2.1+:

buildscript {
    repositories {
        mavenCentral()
        // or jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
    }
}

plugins {
    id 'com.github.ksoichiro.eclipse.aar' version '0.3.1'
}

apply plugin: 'com.android.application'

Gradle 2.0 and former:

buildscript {
    repositories {
        mavenCentral()
        // Enable this if you use SNAPSHOT
        //maven {
        //    url uri('https://oss.sonatype.org/content/repositories/snapshots/')
        //}
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
        classpath 'com.github.ksoichiro:gradle-eclipse-aar-plugin:0.3.1'
    }
}

apply plugin: 'com.android.application'

// Apply this plugin
apply plugin: 'com.github.ksoichiro.eclipse.aar'

And configure it in eclipseAar closure.

repositories {
    mavenCentral()
}

// Write your dependencies
dependencies {
    compile 'com.android.support:appcompat-v7:21.0.2'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.melnykov:floatingactionbutton:1.0.7'
    compile 'com.github.ksoichiro:android-observablescrollview:1.5.0'
}

// Configure eclipse-aar plugin
eclipseAar {
    // See "Configurations" for details
    androidTarget = 'android-21'
    aarDependenciesDir = 'aarDependencies'
    // Set to true if you use Andmore. Default is false
    andmore = true
}

// Configure android plugin
// (Even if you don't develop with Gradle, write following at least)
android {
    compileSdkVersion 1

    // Source directory is 'src/main/java' by default.
    // This will be added as a classpath entry in .classpath file.
    // If you'd like to set src directory other than that,
    // override it with sourceSets.main.java.srcDirs like this.
    sourceSets {
        main {
            java.srcDirs = [ 'src' ]
        }
    }
}

Migrate from Eclipse ADT to Andmore

If you're going to migrate from Eclipse ADT to Andmore, please check the following notes.

Remove or edit meta data files

Please remove the meta data files (.classpath and .project) in your app project
or edit them manually before executing tasks.

Those files are slightly different between ADT and Andmore - package has been changed
from com.android.ide.eclipse.adt to org.eclipse.andmore - and
if they're not changed, Andmore does not recognize the projects.

Perhaps this plugin can/should overwrite those files in the future,
but currently it respects the existent contents.

Set andmore flag

Set eclipseAar.andmore option to true to generate the meta data files (.classpath and .project) for Andmore.

Prepare Gradle or Gradle wrapper

Install Gradle 2.2.1+.

Or copy Gradle wrapper files into your project. If you use Gradle wrapper, you don't have to install Gradle.

  • gradle\wrapper\
  • gradlew
  • gradlew.bat

Generate dependencies

$ ./gradlew generateEclipseDependencies

JAR dependencies will be copied to libs directory,
and AAR dependencies will be exploded and copied to aarDependencies directory by default.

Import projects to Eclipse and build app

  1. Launch Eclipse.
  2. Select File > Import.
  3. Select General > Existing Projects into Workspace and click Next.
  4. Click Browse and select project root directory.
  5. Check Search for nested projects.
  6. Select all projects and click next.
    Note that if you've imported projects in Eclipse before, there might be bin directories and they might be recognized as projects, but don't select them.
  7. Some warning messages might be generated, but ignore them and wait until build finishes.

Run the app

  1. Confirm your device is connected.
  2. Right click your main project and select Run As > Android Application.

project.properties?

Eclipse ADT plugin uses project.properties file to manage library project dependencies.

If you don't have project.properties file, this plugin will create it.
If you have project.properties file but don't have the required AAR dependency entries in it, this plugin will add these entries, too.
Therefore you don't have to care about them.

But please note that if you have file dependencies (libs/xxx.jar), you should manually add entries for them to project.properties file.

.classpath files?

Eclipse has .classpath files to manage dependencies.
For Android apps, each library projects must be declared as <classpathentry> tags in .classpath file.

If you don't have .classpath file, this plugin will create it.
If you have .classpath file but don't have <classpathentry>s for the required libraries in it, this plugin will add these entries, too.
Therefore you don't have to care about them.

But please note that if you have file dependencies (libs/xxx.jar), you should manually add entries for them to .classpath file.

Note that .classpath file generated by ADT is not recognized by Andmore.
To develop with Andmore, set eclipseAar.andmore to true.

.project files?

Eclipse has .project files to manage project description.
If you don't have .project file, this plugin will create it, so you don't have to care about them.

Note that .project file generated by ADT is not recognized by Andmore.
To develop with Andmore, set eclipseAar.andmore to true.

Configurations

Configurations for this plugin are written in eclipseAar closure.

Configuration Default Description
androidTarget android-21 target value in dependency projects' project.properties
aarDependenciesDir aarDependencies Directory to explode AARs
jarDependenciesDir (null) Directory to locate JAR.
projectNamePrefix (Empty) Project name prefix for AAR dependencies
projectName (Target project name) Base project name for AAR dependencies
cleanLibsDirectoryEnabled false Set to true if you want libs directory to be cleaned before files are generated.
andmore false Set to true if you use Andmore.
targetConfigurations ['compile', 'debugCompile'] Configurations that dependency JAR/AAR will be aggregated from

Samples

See samples directory.

Each projects refer to samples/repo directory as a Maven repository. You must generate it before using samples with following command:

$ cd /path/to/this/project/root/
$ ./gradlew clean assemble uploadArchives

After that, you can try this plugin in each projects.
Example:

$ cd ./samples/example/
$ ./gradlew generateEclipseDependencies

License

Copyright 2015 Soichiro Kashima

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

Android-ObservableScrollView

Android library to observe scroll events on scrollable views.
Java
9,658
star
2

awesome-gradle

A curated list of awesome Gradle plugins and resources for a better development workflow automation.
446
star
3

gitlab-i18n-patch

Unofficial Japanese translation for GitLab Community Edition.
JavaScript
95
star
4

SimpleAlertDialog-for-Android

Library for Android DialogFragment.
Java
80
star
5

AndroidFormEnhancer

Form validation library for Android applications.
Java
74
star
6

dockerfiles

Dockerfile examples.
Shell
54
star
7

gradle-console-reporter

Gradle plugin to report various kinds of summaries to console.
Groovy
53
star
8

rdotm

Objective-C resource definition generator like Android app's R.java.
Go
42
star
9

RichButtons

'RichButtons' is a set of button styles for Android applications.
Java
39
star
10

gradle-build-info-plugin

Gradle plugin to include build information such as Git commit ID to your JAR. It can be used to show Git commit information with Spring Boot Actuator.
Groovy
38
star
11

material-design-colors

Palette for Android Material Design colors.
Go
30
star
12

Android-PageControl

Clickable PageControl for Android apps.
Kotlin
25
star
13

gradle-web-resource-plugin

Gradle plugin to use CoffeeScript, LESS and Bower libraries without Node.js/npm.
Groovy
23
star
14

gradle-android-git

Gradle plugin for Android apps to manage Git dependency (gag)
Groovy
22
star
15

export_icons

Inkscape Icon Export Script for Mobile Apps
Shell
21
star
16

rehype-img-size

rehype plugin to set local image size properties to img tag.
JavaScript
18
star
17

adbs

Small utility for adb(Android Debug Bridge) to choose device easily.
Go
14
star
18

android-snippets

Snippet codes for Android apps.
Java
14
star
19

node-archiver-zip-encryptable

An extension for archiver to zip with password encryption.
JavaScript
12
star
20

Android-CodingGuideline

Androidアプリのコーディングガイドライン
12
star
21

spring-boot-practice

Examples of Spring Boot apps.
Java
11
star
22

android-tests

Examples of Android tests.
Java
9
star
23

Android-ColorfulIcons

Application icons mainly for Android apps.
Java
8
star
24

i18n-patch

Replacing codes for i18n with patterns.
JavaScript
8
star
25

vagrant-templates

Vagrantfile and provisioning scripts templates.
Shell
8
star
26

gradle-replacer

Gradle plugin that provides a minimalistic template engine feature.
Groovy
6
star
27

gradle-plugin-template

Template project for Gradle plugin.
Groovy
6
star
28

md-slide-android

Android slide viewer app with Markdown
Java
5
star
29

fint

A lightweight, simple source code check tool.
Go
5
star
30

gradle-spelling-plugin

Gradle plugin to inspect spelling using custom blacklist.
Groovy
4
star
31

ability

Simple authorization library for Java.
Java
4
star
32

ui-showcase-for-android

UI pattern implementations for Android apps.
Java
3
star
33

gitlab-print

Chrome extension to adjust layout of GitLab pages for printing.
CoffeeScript
3
star
34

gradle-boilerplate

Boilerplate codes for Gradle.
JavaScript
2
star
35

zubhium.sample

Zubhiumを使用したAndroidアプリケーションのサンプルです。
Java
2
star
36

mocker

Mock up code generator for Android/iOS apps.
Go
2
star
37

ProjectTemplate-for-Android

Android application project template files for both Android Studio and Eclipse ADT.
Shell
2
star
38

homebrew-adbs

A Homebrew formula for ksoichiro/adbs
Ruby
1
star
39

Android-ChangeLog

Tiny change log Android library with Markdown.
1
star
40

homebrew-fint

A Homebrew formula for ksoichiro/fint
Ruby
1
star
41

gitlab-i18n-patch-box

gitlab-i18n-patchの動作確認用に使うVagrant Box
Shell
1
star
42

record

Sample app for my training.
Go
1
star
43

gradle-commit-checker-plugin

Gradle plugin to check commits in a branch to avoid large diff in a pull requests.
Groovy
1
star
44

gradle-summary-plugin

Gradle plugin to generate summary report from various kind of checks.
Groovy
1
star
45

sbac

Example to demonstrate admin console like app with Spring Boot.
Java
1
star
46

contactsaggregator.sample.list

Example of using Android Contacts API.
Java
1
star
47

memorandum

My blog resource
HTML
1
star
48

homebrew-rdotm

A Homebrew formula for ksoichiro/rdotm
Ruby
1
star
49

mariadb-spring-test

A tiny application powered by Spring Boot to test MariaDB.
Java
1
star
50

gh-pages-android-playground

Test project to publish docs to website via Travis CI with Android environment.
JavaScript
1
star
51

contactsaggregator.sample

Example of using Android Contacts API.
Java
1
star
52

fastroid

Framework for the Android (2.1 or upper).
Java
1
star
53

FancyIceCream

🍨 A Minecraft mod to add ice cream recipes
Java
1
star
54

wsls

Special 'ls' to list projects in your workspace.
JavaScript
1
star