How to import Android gradle dependencies in React Native - java

I have a React Native app that should use a Wi-Fi for connecting and getting some data. I have a custom Wi-Fi library written in Java and it was used for native Android apps. Now I want to use this library for my react-native app. How can I use it in my react-native app? Any detailed information would help me.
Thank you very much for your time and assistance in this matter.

If you have already written a library in java then you can use that library in android by following the steps mentioned in the link below:-
https://facebook.github.io/react-native/docs/native-modules-android.html
If you still have any issues then please let me know.
EDIT:-
You can use your native module after providing that in getPackages inside your react native components as below:-
Create a file and use your native module and export it so that you can use it inside your components:-
import {NativeModules} from 'react-native';
module.exports = NativeModules.ToastExample; //here ToastExample is the name of your native module.
Then import your module inside your component and you can use its further functions/methods as below:-
import ToastExample from './ToastExample';
ToastExample.show('Awesome', ToastExample.SHORT);

Related

JNI system loadlibrary

I am developing an app on Android using JNI.
My native code mylib.so depends on a.so.
When I use System.loadlibrary() I want to know do I need to load a.so too?
Thanks.
YL
I think this example on github that I had written way back for loading static linked library and its dependencies will give you some more idea. In general, you only have to specify the main lib [in my case it was curl lib] and the System.loadlibrary will take care of loading dependencies.

Replace android default sqlite build

I would like to replace android default sqlite build for a new one having rtree feature enabled. It looks like I have to use a java wrapper to accomplish that and the only one I found android compatible was sqlite4java. I prefer sticking with standards. Unfortunately I found out jdbc is not supported in dalvikvm (Androids VM) and native android.database.sqlite works with an rtree disabled build of sqlite.
Currently I have a new .so sqlite rtree enabled library compiled for android but would like to substitute androids native one without having to use a third party wrapper like sqlite4java. Any ideas? I was thinking about downloading android.database.sqlite package from android sdk and building a jar to substitute only the .so load withing my application context. Is that the best approach?
I was thinking about downloading android.database.sqlite package from android sdk and building a jar to substitute only the .so load withing my application context. Is that the best approach?
So long as you are willing to refactor all necessary classes into your own package, that is probably your only approach. For example, that is what SQLCipher for Android does. They cloned ~37 classes from android.database and android.database.sqlite and modified them to use their own SQLCipher-enabled build of SQLite.

how to connect to php parser in netbeans platform

I am writing a code completion plugin for a PHP library in Java / Netbeans Platform.
I need to find a way to obtain a reference to one of the PHP modules so I can interpret part of the source, anyone experience with this kind of problem?
How do I obtain a reference to the PHP module (for code completion plugin module)
What is the recommended approach to integrate a code completer with PHP module on the NetBeans platform?
Cheers and thanks in advance
Gabor
You would use the org.netbeans.modules.php.api and some other core stuff and implement a new CompletionProvider. (MyCompleter implements CompletionProvider)
import org.netbeans.modules.php.api.phpmodule.PhpModule;
import org.netbeans.modules.php.api.util.UiUtils;
import org.netbeans.modules.php.api.executable.PhpInterpreter;
and maybe Tokenizer and Completion could be usefull
Tokenizer
import org.netbeans.api.lexer.Token;
import org.netbeans.api.lexer.TokenSequence;
Completion
import org.netbeans.spi.editor.completion.CompletionProvider;
import org.netbeans.spi.editor.completion.CompletionResultSet;
import org.netbeans.spi.editor.completion.CompletionTask;
import org.netbeans.spi.editor.completion.support.AsyncCompletionQuery;
import org.netbeans.spi.editor.completion.support.AsyncCompletionTask;
In Netbeans, PHP support is initially chosen in the version you decide to download. However, you can add PHP support like you describe after the fact through Netbean's plugin functionality. Just go to Tools>Plugins and click on the Available Plugins tab at the top. There you will see a host of PHP related plugins, from Manual references to Framework specific helpers that you can install. You can also install individual plugins downloaded from here manually through another tab in the same menu interface.
See here to look at the table for download options... Notice the far right, with all the dots, that's All. Only way to start out with Java + PHP support is install support for all other languages too. A little hefty if you have focused development needs, which is probably why you skipped this.
Hope this helps!
Netbeans Downloads

How can I use Android with Java and a core made with Scala?

I made a small project using Scala (SBT + IntellijIDEA) that provides me a set of classes and other functions that I want to use in Android. I will call this project $core.
So, keeping that in mind I tried to first only use scala. I tried to create an Android Project using android-plugin and I got it.
But what I really want is to use my $core in an Android Project AND expand the $core classes using Java. $core provides an API that I would like more people to use and they probably don't know Scala so Java would be perfect. Besides, I need to go into a safe route with Android. I saw some info that scala takes a lot of time to compile into Android and has some limitations (like with parceblles).
I already tried to use the classes in eclipse with the import class folder option. I even tried to generate a jar so at least I would have a way to run it and no success. Always the NoClassDef error when I try to use one class from the $core. I have tried to import also the scala compiler library, but didn't work out aswell...
Core isn't finished yet and I would like to develop on a single environment that allowed me to debug on the android device. How can I setup all of this?
PS: Changing to eclipse now maybe is better? Never tried android on intellijIDEA and In scala I can't debug over there, at least using ScalaCheck...
Is it possible that you are getting an noclassdeffound error when working with Scala code from java because you didn't add the Scala library to the java project or at least included the party of it that it's used in the Scala code in the jar?
Could you post the rest of the error?
You could package the core to .jar together with Scala library, use Proguard to remove all unused Scala library classes from it, and then use that jar as a regular library.

Android: Adding a new framework

I am trying to add a new framework in Android Source code and call my applications using that framework.
I have included my framework files and called the functions. Makefile for the application includes the new framework. Everything compiles. But when I run my app it force closes. All the Xml layouts and java classes are fine. Manifest file includes
<user-library android:name="frameworkName">
My question is where to have the mapping for this "frameworkName" in android base code so that it is able to figure out the framework folder/path. Which looks like to be the main problem
What are the possible steps to make this work as I am unable to run my application(Force Close).
EDIT: Initially I was getting Runtime Exception:-Class Not Found for framework classes. Moreover that error was coming up when I missed the "user-library" tag. Now after adding the tag, my apk is not getting installed by the package manager as it is not able to figure out the the framework path.
Android Developers says this:- "the PackageManager framework won't let the user install the application unless the library is present on the user's device".
http://developer.android.com/guide/topics/manifest/uses-library-element.html
So which linking am I missing. Any guesses or help would be really helpful for me.
thanks
Instead of "frameworkName", you should put package name of your library (the one defined in the application name of your library).
If your classes (and R) are in com.example.myframework, then that's your library name.

Categories