How to simplify Apache Avro? - android

I am developing an Android project with Apache Avro, but it depends on two Jackson libs(core-asl.jar and mapper-asl.jar). Unfortunately, these two libs are too large for an Android application. I wonder if there is any way to simplify the Avro source code, or can I replace Jackson with org.json directly?

Related

How do I use included Android dependencies from within the NDK?

I am trying to use SQLCipher within Android. They made it very easy to integrate by adding the dependency:
implementation 'net.zetetic:android-database-sqlcipher:4.2.0#aar'
They have nice and simple examples of then using this in Java, but my application is c++ and I am using the NDK. SQLCipher is primarily C code so I know that this is linking against some compiled C code. Are the headers available for use? Where are these dependencies being installed. I am an iOS developer new to Android so I feel like this should simple but I am just missing something.
There's currently no support for consuming C/C++ dependencies from an AAR. We're working on this here: https://github.com/android-ndk/ndk/issues/916
But I should note that even when that is complete, sqlcipher does need to choose to expose that library. The AAR would not currently contain includes, and it may not be a stable API so they may choose not to expose it.
For a library to be usable directly by ndk, you'd need a .so version of it to link against. If you're including the library like this, you'd use JNI to access it via Java.
I'd recommend against hacking something up to access their .so files directly. Its quite possible their Java code has business logic that prevents errors or initialized things that are not set up properly if you go right against their .so file.

Android Studio - Add shared library (.so) file and header (.h) file to project

I am currently working on an android project that requires me to make use of functions included in a shared library (.so). I also only have header (.h) files for the library provided to me.
Is it possible to work with just these two files? Or do I need to create my own implemenations via c++ codes?
I am using Android Studio intend to use CMake.
Regards,
Philip
Most Android apps are written in Java. Google has released the Native Developer Kit (NDK) in order to allow developers to write libraries in C++. However, these libraries are usually very low level and called from the Java code which defines the UI and higher-level app logic. Most likely you will need to write a wrapper for the library so that you can call it from Java code. Looks like this blog is a good place to start.

How do you include a networking library within another library?

I am working on writing an SDK for a client. Part of the SDK requires me to interface with a good 20-30 endpoints. How I have always done this in the past is simply used Retrofit and OkHttp for the API interface. I recently discovered, however, that you cannot use 'nested' library references within a library.
My question is, how do I go about using Retrofit in this current library I am making so that it can be used on other devices? Do I just need to clone the repo, copy the code into my project and go from there? Or is there a simpler method?
Thanks all.
Your can use maven transitive dependency.
Or AAR have no problems with nested jar files. From documentation
A library module can include a JAR library
You can develop a library module that itself includes a JAR library; however you need to manually edit the dependent app modules's build path and add a path to the JAR file.
I use this approach for okhttp.

Shared classes for Android and Spring MVC projects

I've a client-side Android project and a server side Spring MVC project. Some classes defining rest messages exchanged between client and server are common, and could be useful to define a common project to share the classes.
For now I duplicated all the classes in both projects. Client-side classes use Android library (principally Parcelable) and others like jackson for JSON and simpleframework for XML. Server-side classes use Jackson for Json, JAXB for XML and Hibernate for ORM.
I know about how to import these classes in Android Project, it simply need to include hibernate annotation and others in the android libraries, but i'm a little confused about importing an Android project in Spring MVC.
How i have to define this shared project: as a normal Java project, as an Android project? And it's correct/possible to import the Android library in a Spring project or there will be conflicts with the Java library? How to solve?
As last possibility I'm considering to remove the Android dependency substituting Parcelable with Serializable, but I prefer to use Parcelable for its better performances.
I'm using Eclipse Spring Tool Suite with Android Development Tool plugin and Maven.
Including the android project in a Spring MVC project doesnt make sense
You should build a standalone standard java project (that compiles and is built to a JAR file) that contains all the code that is shared between the android and springmvc project.
This common JAR file should then be included in both the android project and Spring MVC project. Pretty simple really :)
If you are using Maven you can include it as a dependency (Which will be the cleanest approach) if not then just manually include the JAR in each of the projects.

Having Android Problems with Sun javax jars

I have been working on a Android Web Services program that uses a number of classes from Sun's javax libraries. The eclipse IDE is barking "Attempt to include a core class (java.* or javax.* ) in something other than a core library." My application is an Android application and I am not creating a core library. I am using several .jars; javax.xml.ws, javax.xml.bind, javax.xml.soap, javax.xml.rpc, and javax.jws. I believe I cannot use these java bytecode .jars directly. I will have to use the dx tool to convert them to delvik bytecode or .dex files. I have done some additional research and have found that use of any javax.* classes in an android application are forbidden. Can someone explain why? Are their practical programming work arounds?
Thanks,
Steve
That's because those jars use core core libraries. Android does not support the complete J2SE, but rather a subset of it: http://developer.android.com/reference/packages.html
Thus, you cannot use Java core libraries because they don't belong to the Android SDK.
You need to use an alternate library to handle SOAP in Android - the Sun provided libraries do not work.
One popular alternative is KSOAP2.
Start with an enhanced version of kSOAP called ksoap2-android:
http://code.google.com/p/ksoap2-android/
Then add a tool that generates kSOAP stubs based on a WSDL called wsdl2ksoap:
http://code.google.com/p/wsdl2ksoap/
Not quite as advanced as wsimport, but this gets you pretty darn close.

Categories

Resources