IDEA: create jar artifact from Android - jar

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.

Related

Javafx project deployment - how to handle assets/resources?

I recently finished my first JavaFX project and am ready for deployment. I found that when I create the jar file for my project my ide creates a folder with the jar and other necessary files. I noticed that when I run the jar in the file everything works fine. However, when I take the jar our of that folder and place it as a desktop icon, various resources no longer become available - I am assuming this is because the jar file and the various resource files are no longer in the same file path/folder. - Is this the correct assumption to make?
Regardless, I wanted to ask what is the standard method of getting JavaFX resources and the accompanying jar file to work when the resources are not located in the same folder?
Essentially, I want to have a clickable desktop icon that launches the app, which the jar file fulfills. But if I put that jar file in a folder with its resources to get the project to work properly then the user will have to press the folder and then the jar file in order to get the project to launch - which is very counterintuitive.
Any ideas on how this issue is handled?
The best way to do this is to create a shortcut to your jar file not copy it to another location. The jar file depends on these resources to execute especially if you used external libraries.
The other alternative would be to export your jar file with the libraries included in the jar. This however would make your jar very huge depending on the number of libraries you have.
I hope this helps.

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.

import play framework module as jar into java project

I have created a play module, how I can import the exported jar to normal java project(not play project)?
When I tried it it gives error:
The type play.libs.F$Promise cannot be resolved. It is indirectly referenced from required .class files
You need to include the play libs as well. Have a look at the deployment documentation. activator dist allows you to create a standalone distribution for your entire play-app.
You can also search the jars in the output for the one which contains the classes you need and just add this one jar to your project.
Or: use sbt/maven to manage your dependencies and add the entire play-framework. (seems to be a bit of an overkill though)

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.

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