Package and execute jar file from react-native app - jar

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.

Related

How do I embed CryptoSwift into WatchKit Extension target without build error?

I am trying to embed CryptoSwift as an embedded framework into a Watch app (watchOS3) - I would like to be able to use AES encryption and decryption from within the Watch app.
I start by creating a new clean Xcode project: watchOS application using "iOS App with WatchKit App" in a local git repository.
To add CryptSwift, I followed the installation guidance of CryptoSwift (https://github.com/krzyzanowskim/CryptoSwift#installation) by adding it as a git submodule (git submodule add https://github.com/krzyzanowskim/CryptoSwift.git) on the top level project folder. Then I dragged the CryptoSwift.xcodeproj into the clean Xcode project.
Then, I add the CryptSwift.framework into the Embedded Binaries of the iOS app target. Build was successful, and I could use import CryptoSwift, e.g., in ViewController.swift.
But when I add the CryptSwift.framework into the Embedded Binaries of the WatchKit Extension target. Hits Build, it fails: "clang: error: no such file or directory: '/Users/brian/Library/Developer/Xcode/DerivedData/TestCrypto2-bkzbizyfkacuctdwdngnvcrrewpi/Build/Products/Debug-watchsimulator/CryptoSwift.framework/CryptoSwift'". And I am not able to use import CryptoSwift in e.g. InterfaceController.swift in the WatchKit Extension.
I have tried a number of different approaches to add the CryptoSwift.framework to the WatchKit Extension, but none with success.
Does anyone know how to add this CryptoSwift framework to the WatchKit Extension the right way, if possible?
Xcode 8.1 (8B62)
iOS 10.1
watchOS 3.1

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 create a jar library (not aar) in android studio?

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.

Attaching javadoc to jar and link to Android Studio

I have javadoc documentation written for a .jar library that I want the user to be able to see right after he imports our jar into a project. In eclipse, I was able to do this by adding a libname.jar.properties file that points to where my javadoc directory is. This way when I import my jar into a project in eclipse I would be able to see the javadoc documentation when I hover over one of the api methods in my library.
Basically, I want to be able to have the same functionality in Android studio. Any help would be appreciated.

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.

Resources