简体   繁体   中英

Android, how to import Gradle library into eclipse (ANT)

I am trying to use the new Abode Creative SKD but using Eclipse and not Android Studio.

How can I add the following Libraries in my eclipse project:

4.1 Adding the library dependency
In the build.gradle file of the app add the required library as a dependency.
EX: If you need to use authentication library you will need to add the below path under dependencies:
compile 'com.adobe.creativesdk.foundation:auth:0.2.10'
You can choose all or any of this according to your project requirements:
Authentication : 'com.adobe.creativesdk.foundation:auth:0.2.10'
Asset Browser : 'com.adobe.creativesdk.foundation:assets:0.2.10'
Behance : 'com.adobe.creativesdk:behance:0.2.10'
Image : 'com.adobe.creativesdk:image:4.0.0'
Note: com.adobe.creativesdk.foundation:auth is a basic requirement for any of the libraries.

from this link

I already have this file in my project: build:grade

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
    }
}


allprojects {
    apply plugin: 'maven'

    tasks.withType(JavaCompile) {
        options.incremental = true
    }

    repositories {
        mavenCentral()
        jcenter()

        maven {
            url "${project.rootDir}/creativesdk-repo"  //ADD THE CORRECT LOCATION OF THE CREATIVESDK LIBRARY FILES
        }

    }
}

apply plugin: 'android'

dependencies {
    compile fileTree(include: '*.jar', dir: 'libs')
    compile 'com.adobe.creativesdk:behance:0.2.10'
    compile 'com.adobe.creativesdk.foundation:auth:0.2.10'
    compile 'com.adobe.creativesdk.foundation:assets:0.2.10'
}

android {
    compileSdkVersion "android-21"
    buildToolsVersion "21.1.1"

    defaultConfig {
        applicationId "com.adobe.creativesdk.sample"
        minSdkVersion 14
        targetSdkVersion 21
        versionName "1.0.0"
        versionCode 1
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
    }

    buildTypes {
        release {
            debuggable false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
    }

    lintOptions {
        abortOnError false
    }
}

Using ANT? No way. Of course, you can unzip aars, found in Abode Creative SKD and put the files so ANT will work with them. You can even make a library project with that files and include it (ANT style :) But it's inconvinient.

I've already done some investigation on simular problem - how to use aar in Eclipse with ANT. I finally ended up downloading Eclipse library project (there was that option - to choose aar or Eclipse Library Project) and adding it in Eclipse. All worked fine except the assets - they are needed to copy inside the project for apk (not library) itself.

And from myself, I don't recommend using ANT in the nearly future, because even android developers postponed it's support. There was a features summary table on android developers site (ask and I'll search for it), where it was clear that support of ANT is postponed, while Gradle direction is preffered one. I moved to Gradle not far ago and I can say, that it is much better than ANT. No nightmares with dependencies at all. And it is very important because modern libraries can have tens of dependencies to include. And searching, adding, versioning of them by hand is a nightmare.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM