How to create a jar library (not aar) in android studio? - jar

how can i create a jar binary library project in android studio that can be used in other projects (meaning - an sdk)?
if it is possible, i want it to contain both java files and native cpp code (java files will start audio listening and cpp files for analysis).
there is no resources/layouts in the library.
if i add an android library module, its ouput is an aar file and not jar.
i read that eclipse does not support aar and so that is why i want it to be jar.
thanks a lot!

What you need to do is to put aside the Android "nature" of Android Studio and just write and build a normal Java/C++ project with Gradle. Your first stops will be Java quickstart and Native support documentation of Gradle.

In gradle find command "createFullJarDebug"
This command will generate jar file under build\intermediates\full_jar\debug\createFullJarDebug\full.jar
then you could use it.

Related

Creating Javafx jar files

I have a a Javafx (fxml) application that I need to deploy as a jar file (using Intellij). However, this apparently cannot be done in later versions of Javafx. You need third party tools to create Javafx jars. The problem: I cannot seem to get any sources on-line that will list downloadable tools to create jars from Javafx apps. Any recommendations will be greatly appreciated!
To make your life easier, you can use this awesome plugin Java Packager that can create jar, .exe, and executable installer for Mac, Windows & Linux with just 1 command line mvn package

Package and execute jar file from react-native app

I have a jar library which I want to be able to use from my react-native app. Currently I'm working on an android project and I want to be able to execute the jar from based on some user interactions. Is this possible and if it is, how can I do this? Bonus points if it's possible for iOS as well.
To use a jar library within a react-native app, you can follow these steps:
Copy the jar file somewhere inside android folder
Declare the jar file as a dependency of the android app project
compile files('<path_to_jar_file>.jar')
Create a native module (https://facebook.github.io/react-native/docs/native-modules-android), call to your jar file classes inside the java code and expose the functionalities via javascript module
You can also make a library from that jar file and your native module code (https://github.com/frostney/react-native-create-library)
Unfortunately, you cannot directly use the jar file for ios.
You can find a similar library for ios and create the ios native module and expose the same interface so your js module is cross-platform.

How do I get Android Studio to include resources in a .jar file?

I'm using Unity 5. It still expects java plugins to be a .jar file built with JDK 1.6.
I had this working under Unity 4, but they changed something. Now I get this error while building the apk from Unity:
OBSOLETE - Providing Android resources in Assets/Plugins/Android/res
is deprecated, please move your resources to an Android Library. See
"Building Plugins for Android" section of the Manual.
How do I get AS to put the resources into classes.jar? The "Building Plugins for Android" doesn't mention resources.
Additional information about my project:
The project references Google Play Services, so I need version.xml in there
<integer name="google_play_services_version">6587000</integer>
Which contains the version number for the reference in the Manifest.
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
But if I include this file in res/values in my AS library project, it's still output as an xml file in res/values next to the classes.jar.
Incidentally, I'm digging the .jar file out of
/ApplicationName/build/intermediates/exploded-aar/ProjectName/LibararyName/unspecified/classes.jar
after building the project.
First of all, this is a warning and not an error.
Providing resources in Unity in Assets/Plugins/Android/res/ folder is not recommended, because it can cause resource conflicts.
When you provide resources in an Android library, they are correctly merged during build process.
Basically, you have three options:
convert your plugin into an Android library. Or you can init an empty library, add your .jar file to bin/, your resources to res/ (there should be a manifest and android.library=true in project.properties). You can do this by calling android create lib-project (more details)
if you compile your plugin directly using gradle or in Android Studio, you can use .aar file produced, given that you have set your project up as a library (apply plugin: 'com.android.library' in your build.gradle file). Just put it in any folder of your project, it should automatically be detected as Android-only plugin.
continue providing resources in res/ and wait for it to be completely unsupported by Unity.
Hope this helps.

IDEA: create jar artifact from Android

I am building an Android app, and I would like to repackage some of its classes as a .jar library.
I have tried the "build artifact" from IDEA, but I get a jar that also contains the unsigned APK and all the classes.
What is the correct way of generating a Jar file out of a folder of classes?
Do I need to create a separate project for the library classes?
It's recommended to have a separate module with the library code and make your Android app depend on this module. Building artifact from this module output classes will not have any extra files.

How to add a jar library into another jar library

i am doing a java library that is using jaybird jar.
I want my library to be a jar with the jaybird in it so when I have to use it, I only import my jar.
How can this be done? I'm using Eclipse Version: Indigo Service Release 2.
Thanks in advance!
It can be done, but requires a special launcher using a specific classloader to extract the inner jar from the outer jar.
I would simply use the standard way of doing: deliver both jars, along with a startup .bat/.sh file used to start the application, the whole being packed into a simple zip file.

Resources