生成JAR文件与Android Studio和摇篮 [英] Generating JAR file with Android Studio and Gradle

查看:213
本文介绍了生成JAR文件与Android Studio和摇篮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作是应该成为SDK库,其他开发商将在他们的Andr​​oid项目整合的项目。我想生成并导出我在Android Studio项目的Andr​​oid模块之一的罐库。该SDK模块包含javadoc注释,我的愿望是生成包含此的javadoc用户友好的jar文件。

I'm working on a project that supposed to become SDK library that other developers will integrate in their Android project. I want to generate and export a Jar library of one of my Android modules from Android studio project. This sdk module contains javadoc comments and my wish is to generate user friendly jar file that contains this javadoc.

我如何可以使用Android工作室出口商这个JAR文件?

How can I export this JAR file using Android Studio?

我发现几种类型的答案:

I found few types of answers:


  • 答案描述不工作gradle这个脚本的使用

  • 使用classes.jar文件 - 使用这个答案,我无法找到一个方法来显示每个方法的输入参数的名称(中,增加了罐子的依赖我得到的项目中使用自动完成时奇怪的方法名(字符串S1,串S,字符串S3),而不是方法名(用户名字符串,字符串密码,字符串国家)

  • Answers that describes usage of not working gradle scripts
  • Use the classes.jar file - using this answer I couldn't find a way to show the name of the input parameters of each of the methods (when using autocomplete in the project that adds the jar as dependency I'm getting weird methodName(String s1,String s3, String s3) and not methodName(String userName, String password,String country).

请告诉我怎么...

顺便说一句,我使用Android的工作室0.5.8。

By the way, I'm using Android Studio 0.5.8.

推荐答案

如果您的lib目录包含Android的资源或依赖于包含Android的资源,你应该发布AAR文件,而不是jar文件等moduls。

if your lib contains android-resources or dependencies to other moduls that contain android-resources you should publish aar files instead of jar files.

我DONOT知道如何在Android的工作室做这些,但是从命令行,你可以这样做:

i donot know how to do these in android-studio but from commandline you can do this:

如果您已经创建了一个Android lib模块也可以生成使用gradle这个assembleDebug或gradle这个assembleRelease的lib。它是建立在build / lib文件夹。

if you have created an android-lib module you can generate the lib using gradle assembleDebug or gradle assembleRelease. it is build in the build/lib folder.

要学习的gradle什么可以为你做,你可以使用gradle这个--gui

to learn what gradle can do for you you can use gradle --gui

[更新]

我不认为日食可以消耗AAR文件(但我可能是错的)

i dont think that eclipse can consume aar files (but i may be wrong)

如果您添加

task jar(type: Jar, dependsOn: 'compileReleaseJava') {
   // with gradle2.2+/androidStudio1+/BuildTools1+ add sourcecode to jar
   // from android.sourceSets.main.java.srcDirs 

   // with older gradle/androidStudio/BuildTools add compile-result to jar
   // from android.sourceSets.main.java 

   // for gradle 2.2 and buildTools com.android.tools.build:gradle:1+ / androidStudio1.0
   from "$buildDir/intermediates/classes/release/" 
}

你的文件的gradle你会得到一个罐子的任务,即建立一个罐子你。
这样的Gradle调用罐子将建立罐子你

to your gradle file you will get a jar task, that builds a jar for you. so calling gradle jar will build the jar for you

这篇关于生成JAR文件与Android Studio和摇篮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆