4

I'm building a standard java project, not an android project.

It is using the Gson library from Google. Is there a way to create a JAR file for this project, while maintaining dependencies to the Gson library? Please correct me if I'm framing the question wrong.

The build.gradle for my module looks like this:

apply plugin: 'java'

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile  'com.google.code.gson:gson:2.3'
}

I used the instructions here to create a JAR file but when I run it from the command line using "java -jar myproject.jar" I get this error:

no main manifest attribute, in myproject.jar

I tried looking for a solution and it seems there isn't a way to create a JAR file with dependencies, although the link above is pretty new. Seems that I have to make an AAR file in this case.

But since mine is a java project rather than android does this still apply?

Thanks.

EDIT: According to this video my Manifest.MF file is missing the line "Main-Class:MyMainClassName". Modifying the file from the JAR corrupts it. And I can't edit the manifest file from within android studio. And idea on how I can change this?

fractal5
  • 2,034
  • 4
  • 29
  • 50

0 Answers0