0

I'm working on an android plugin for unity and need to generate a jar file. To do so I followed the steps at https://stackoverflow.com/a/20446513/3742608 , set my build variant to release, rebuild the project and executed makeJar. However, my project does have the folder gradle uses only in another folder 'intermediates':

Project Structure

I changed some things to the following, but it doesn't matter, the jar file is not generated.

task clearJar(type: Delete) {
    delete 'build/libs/myCompiledLibrary.jar'
}

task makeJar(type: Copy) {
    from('build/intermediates/bundles/release/')
    into('build/libs/')
    include('classes.jar')
    rename ('classes.jar', 'myCompiledLibrary.jar')
}

The bundles/release directory is empty, as are its underlying directories. The code also doesn't work if I reference classes/release instead of bundles/release.

Anyone an idea why the jar file is not generated?

P.S. the classes.jar in the directory libs is not generated by gradle, but just the classes.jar provided by Unity

Community
  • 1
  • 1
Joost Verbraeken
  • 883
  • 2
  • 15
  • 30
  • I have the same promble, I think it's cause by instant run, but I also have no idea to slove it. – Denny Aug 11 '16 at 02:57

1 Answers1

1

Last time I used Android Studio, I was told that it is not possible to generate jar file from Android Studio. I don't know if this has changed since then.

Now to answer your question, you don't need jar file to make your plugin work in Unity. Unity 5.0 added support for aar file. Simply compile your plugin as arr file and use it in your Unity 5 or above version and it should work.

Programmer
  • 121,791
  • 22
  • 236
  • 328