简体   繁体   English

如何将Gradle项目编译为可以在Android应用程序中使用的jar文件

[英]How to compile gradle project to a jar file I can use in my Android application

I have an Android application that I've written in Eclipse. 我有一个用Eclipse编写的Android应用程序。 I like working with eclipse better than Android Studio. 与Android Studio相比,我更喜欢使用Eclipse。

I found a nice control on Github that I would like to use in my project https://github.com/pedant/sweet-alert-dialog 我在我的项目https://github.com/pedant/sweet-alert-dialog中使用了Github控件

And it depends on the following project: https://github.com/pnikosis/materialish-progress 它取决于以下项目: https : //github.com/pnikosis/materialish-progress

I tried compiling with gradle but with no luck. 我尝试用gradle编译,但是没有运气。 What I need is a JAR file that I can use in my eclipse project. 我需要的是可以在Eclipse项目中使用的JAR文件。 So I first tried to compile the sweet-alert-dialog project and I found out that I need to first somehow include the materialish-progress. 因此,我首先尝试编译了“ sweet-alert-dialog”项目,然后发现我首先需要以某种方式包括实质性进展。

How can I compile those projects into a JAR file that I can drop in my eclipse project and use? 如何将这些项目编译为可以放入Eclipse项目并使用的JAR文件?

Eclipse use apklib and gradle aar for packaging libraries. Eclipse使用apklib和gradle aar来打包库。 Aar is the recommended format to use by google but if you need to generate apklib from gradle you can add this code in your build.gradle Aar是Google推荐使用的格式,但是如果您需要从gradle生成apklib,则可以在build.gradle中添加此代码

task apklib(type: Zip) {
    appendix = extension = 'apklib'

    from 'AndroidManifest.xml'
    into('res') {
        from 'res'
    }
    into('src') {
        from 'src'
    }
}

Then you could use this task by calling gradle apklib. 然后,您可以通过调用gradle apklib使用此任务。 You may have to adapt this snippet for your project. 您可能需要针对您的项目修改此代码段。

source 资源

Try to download *.aar files from http://mvnrepository.com/artifact/cn.pedant.sweetalert/library/1.3 and http://mvnrepository.com/artifact/com.pnikosis/materialish-progress/1.0 , extract class jars from them (they are just archives) and put to your libs folder. 尝试从http://mvnrepository.com/artifact/cn.pedant.sweetalert/library/1.3http://mvnrepository.com/artifact/com.pnikosis/materialish-progress/1.0提取类中的* .aar文件将它们中的jar(只是存档)保存到您的libs文件夹中。 May be some resources will need to be copied from archives, too.. But I haven't managed it yet. 可能有些资源也需要从存档中复制。.但是我还没有管理它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在我的 gradle 项目中创建单个可执行文件 jar - How can I create single executable jar in my gradle project 如何在项目中使用.jar文件并在没有IDE的情况下进行编译? - How do I use a .jar file in my project and compile it without an IDE? 如何增加应用程序可执行jar文件中的JVM堆大小? 项目类型为Maven Project - How can I increase JVM heap size in my application executable jar file? The project type is Maven Project 我无法在我的 android studio 项目中找到 .jar 文件 - I can't fin the .jar file in my android studio project 如何在Ewon项目中使用外部jar文件? - How can I use external jar files in my Ewon project? 如何将整个Android项目编译为JAR以在Delphi应用程序中使用? - How to compile a whole android project as JAR for using in Delphi application? 如何为java项目生成jar文件并在android项目中使用jar - How to generate a jar file for a java project and use the jar in an android project 如何获取运行时依赖项以及 Gradle 项目的坐标和 JAR 文件? - How can I get a the runtime dependencies along with the coordinates and the JAR file of a Gradle project? 如何将处理 core.jar 添加到 gradle 项目? - How can I add the processing core.jar to a gradle project? 如何使用Gradle将jar文件添加到libgdx项目 - How can I add jar files to a libgdx project with Gradle
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM