Tuesday 15 April 2014

Android Gradle Build System: Create Jar Not Library -


Currently I'm working in eclipse I want to migrate to Android studio but I have to find out first: I How do I create a jar for my project using the new Android Build system?

My project is setup as a library but only the Java files in the project do not require me to export it as a library or not. I want to export files as a .jar so that it can easily be dropped into another project.

Update Here is my gray file I I can not apply the line plugin javascript because it is incompatible with the Android plugin. Jar work is already included in the Android plugin.

  buildscript {{treasures mavenCentral ()} {dependence classpath 'com.android.tools.build:gradle:0.4'} 'Android' dependence {compile files ( 'libs / android- support v4.jar ')} Android {compileSdkVersion 17 buildToolsVersion "17.0.0" defaultConfig {minSdkVersion 7 targetSdkVersion 16}} {sourceSets main {{Java srcDir:} apply plugin' Src / main / java '}}} function I am running the script:  gradle clean jar  I run the work, nothing happens ... why? What am I missing?  

Update 2

Below is the new grading build file I am using. Report changes to the gradle version due to the latest updates from Android Studio. Even with a simple clean construction I get this error: Project Directory '& lt; My_workspace_path & gt; \ Core2Project \ build.gradle 'is not a directory This is the only error. The build does not happen in the studio when I run from the IDE, I am also running on this issue along with another project. When I specify the name of the file to be used in Build Studio, I get this error.

  buildscript {repositories {mavenCentral ()} dependency {classpath 'com.android .tools.build: Gradle :. Android 'dependence {compile files (' libs / android- support v4.jar ')} Android {compileSdkVersion 17 buildToolsVersion "17.0.0" defaultConfig {minSdkVersion: 0.5 +'}} apply plugin '7 targetSdkVersion 16} sourceSets {{Main Java {src.dir 'src / main / Java'}}}} Working jar (type: jar) {from android.sourceSets.main.java}    

Gradual and Android Grade Plugin, you can get your build.gradle :

  job jar (Type: jar) {android.sourceSets.main.java.srcDirs} to   

and run the gradle ComplereleaseJa Va jar

On older versions of the Gradle plugin, your sourceSets element should be inside android :

 < code> Android {compileSdkVersion 17 buildToolsVersion "17.0.0" defaultConfig {minSdkVersion 7 targetSdkVersion 16} sourceSets {{main Java {srcDir 'src / main / java'}}}}   

However, Your jar will need to refer to android.sourceSets :

  working jar (type: jar) {android.sourceSets.main .java} to    

No comments:

Post a Comment