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.
Related
We use Xamarin Forms and I have been tasked with integrating a 3rd party AAR library from a business partner and I don't have control over the library or its dependencies. This library itself is distributed using Maven, which works great in Android Studio but is a pain in Xamarin, and it has many dependencies on both libraries that are standard in Android as well as other proprietary libraries.
Since I only need to interact with a small portion of the public API of the main library, I've created an Android library (AAR) wrapper project in Android Studio that only exposes the functionality I need and does not use any types that do not already have bindings.
I have created an Android binding project against the AAR wrapper library, and it compiles in Visual Studio without any warnings or errors.
I've created bindings for other libraries in the past and have the Xamarin binding documentation multiple times and searched online, but the part I'm missing is how to include the required/reference JAR/AAR files in the compilation process and the final Android application. Most of the standard libraries that I need already have NuGet packages (Androidx, Google Play Services, etc)., but the binding library compiles without complaint - so how do I include the other required libraries?
Do I really have to create a binding project for each required AAR/JAR and add as a reference? I don't need to interact with the types or resources in these libraries directly from Xamarin since I only interact with the the types/methods exposed in the wrapper AAR (e.g. I don't think I really need a Xamarin binding). Is there a way to simply have Xamarin process the required AARs and JARs without creating a Xamarin binding project for every library that doesn't already have a NuGet package? There are many many dependencies which makes this theoretically possible, but not in practice. There must be an easier way...
I noticed there is an AndroidLibrary build action that the documentation says can be used to directly reference an AAR/JAR file in a Android application, but I can find no examples of how to use this in practice. What does this build action do? How is it supposed to be used? https://learn.microsoft.com/en-us/xamarin/android/deploy-test/building-apps/build-items#androidaarlibrary
Thanks in advance for any help or direction on the best way to do this.
While working on my Xamarin cross-platform app I am using native apps and a PCL for shared code.
Unfortunately it does not seem possible for me to link the dependencies properly in my PCL.
For example: I use a bouncycastle DLL / dependency in my PCL. When I reference the PCL to my android / iOS app it requires me to link the same dependency / dll again, just inside the native project.
So now I have two dependencies in my native app which seems redundant:
NativeApp:
PCL
BouncyCastle
Is it possible that I only need the BC reference in the PCL?
Thanks.
PCLs use .NET portable (a subset of the whole .NET library) while standard libraries use the full .NET library Becaue of that PCLs cannot reference standard .NET Libraries because they use two different sets of .NET.
On top of that PCLs define the target platforms it is going to support. You can see this in the properties > Library > Targeting of your PCL.
PCLs can only reference libraries that are also PCLs that contain a collection of targets that contain ALL of the targets the PCL has itself.
If you want to make another library for your PCL to reference, make it a PCL itself and make sure it has all the same targets than the PCL that is going to reference it.
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.
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?
We have developed a web service and now are building an Android application to communicate with the web service. We use persistence in our web service and would also like to use persistence in our Android app. We figured that ORMLite was the way to go for persistency on Android and we are hoping that the javax.persistence support would be good enough for our app. I was hoping that I would be able to copy the web service's data model to the Android app and not having to modify the annotations.
So I tried copying the model classes and adding ormlite-android-4.41.jar and ormlite-core-4.41.jar to my Android project. Unfortunately this did not do the trick. My IDE can't find the classpaths for the javax.persistence annotations. Do I need additional libraries? I can't anything on that in the documentation.
If you are using maven. You can add this to your pom.xml:
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
Alternatively you can download the jar file straight from the maven repository here then add it to the classpath. By the way, the #Table(name = "table_name") is not supported. You should substitute it with #Entity(name="table_name").
Interesting question. If the javax.persistence annotations aren't in the Android JDK then I'm not sure you should be using them.
That said, if you want to use them, you should be able to get the java files from a JDK source jar and include them in your own project. Just copy the annotations that you actually use out of the source jar into the appropriate javax/persistence path.
The ORMLite support for the javax.persistence annotations is far from perfect. If you have any problems please let me know so I can improve them.