How would you write a library to be used on android? - android

I've already written a game engine in java using eclipse and opengl es, I had one project (an android project) which contained both of my packages
com.logic.engine
com.logic.testapp
I wanted a way to keep my engine and test app seperate, I've made an earlier post about how this is done, and I figured out how to reference one project in the build path of another (or just creating a jar file).
My problem is that, lets say I now have my engine all wrapped up in an android project com.logic.engine, and now someone would like to use this engine to create a game, so they create an android project com.someclient.game, well now because we have one android project referencing another, it crashes everytime.
Now obviously i need the android sdk in my engine package in order to reference things, but its also required on the client app, since the activity is what is actually being run by android.
I guess my question is, how can i create a project for my game engine without it being an android project, but still referencing the android sdk, and without causing it to crash the client app using it?
edit:
note: the client app utilizes the engine flawlessly when its in the same project folder, it isn't until the engine is referenced from another project containing the android sdk that it crashes, so im 99.9% positive it has nothing to do with my code

Your game engine project should be an Android library project. See Working with library projects.

Use an Android library project.

Just a fix for the two links above that no longer work
Android Library Project
Example Library Tut

Related

Problem with Integration of an Existing Android Library When Building an Android Library

I need to build an Android library for use inside a Unity project. There's nothing different about the build process itself and I managed to build a simple plugin library I can use and I can see commands going in and information coming out.
But now I need to include an external library. I know the library works because I have a demo project, an app, that runs on the required device and does what it's supposed to do. But the instructions to integrate it into a project assume that it is an app and so, do not make much sense in my case.
I have scrolled through a dozen manuals about integrating android libraries but none of them seem to work. I would appreciate a set of instructions about how to integrate an external library in an android project, considering the project is, itself, a library, with respect to the latest Android Studio and build tools.

How to create a class library based on MonoGame to be used from UWP, iOS, and Android

I've installed VisualStudio 2015, Xamarin, and MonoGame 3.5. I'm going to build my XNA app for Windows UWP, iOS, and Android.
I've some libraries based on XNA... and I need to build them for the three target systems (Windows UWP, iOS, and Android), but no way to create a library for Windows UWP. I've tried to create a MonoGame Windows 10 Universal Project, but such a project cannot be converted to generate a DLL.
I've also tried to create a Class Library (Universal Windows) project, but then I was unable to add MonoGame.Framework to the references.
I've the same problem when creating a MonoGame Android Project... no way to switch to a library project. The only MonoGame project that can be modified to be a library project is MonoGame iOS Project.
That said, how can I create a class library based on XNA (MonoGame) to be used from UWP, iOS, and Android?
As far as I know you've only got 2 options here.
Portable Class Libraries
Shared Projects
I haven't really used Shared Projects much. The way I understand them is that they allow you to share code between multiple projects as if it lives in a library but it actually gets compiled directly into the referencing project. They can be thought of like advanced file linking.
Portable Class Libraries are a bit of a different beast. I've used them in the MonoGame.Extended project with great success, but it wasn't always easy. The way they work is to provide a subset of functionality that works on all target platforms. They compile to a DLL that can be referenced by any of the projects and you can be confident the code will be the same.
There are a couple of downsides of using a PCL:
you can only use a subset of functionality. Surprisingly, this doesn't get in the way too often.
if the PCL references another library, it also has to be a PCL.
The second point is where things get a little tricky with MonoGame. Typically, MonoGame isn't shipped as a PCL, but a PCL version has been published on NuGet that can be used.
As it stands right now, the NuGet package is a version behind the official release but surprisingly that doesn't really matter because it's a bait and switch PCL which essentially means it just provides the interface to the real DLL that gets used at runtime. In other words, your game will still happily reference version 3.5 even if the PCL is version 3.2 so long as the interface hasn't changed.
There is some talk about improving this situation in version 3.6.
I noticed MonoGame projects are built using .Net 4.5 by default. Regular class libraries default to the latest installed version of .Net which in my case was 4.5.2. I was able to reference a regular class library by going to its project properties and setting the target framework to 4.5. Hope this helps.

How do I begin working on the Project Tango?

after a couple of weeks I have been unable to get the android set of tools to a functioning level with c++ before and have been given the opportunity of using a project tango, and though that sounds awesome and wondrous and would open a world of opportunity for working with VR... I feel like I am stuck at step -4. My understanding is limited, so bear with me.
I stumbled upon the PCL built for running algorithms on point cloud data, it was open source and appeared like a wonderful solution, it is written in C++ and I have a mild understanding of both c++ and java.
I have tried using Eclipse and the NDK and actually managed to get a project 'deployed' to the tango, however upon attempting to edit any file in the project, java or c++, it breaks and will never deploy again.
Now I am trying to use Android Studio, and after following about 5 conflicting tutorials on 'how to get C++/ndk working in android studio' I have yet to get a working environment.
So here is my question, and we can start at step one, any help is appreciated. How does one get c++ and the PCL working on a google project tango, is there a better way for someone of my skill level? The end result is a mapped 3d space with the project tango, with exportable data sets of manageable size. I have seen it done in demos on youtube, but thus far, like i said, I am stuck on step -4.
we are working on converting all project to android studio based, for now, here is the walk around to get you started:
Open Android Studio, import the project from the repo you just cloned.
Take the motion-tracking-jni-example as the example, copy tango-gl-render, tango-service-sdk, and third-party into the motion-tracking-jni-example/app/src.
Run ndk-build in the motion-tracking-jni-example/app/src/main folder.
ndk will generate the libs folder, rename it to jniLibs.
Go to Android Studio, in build.gradle(Module:app) file, add line 'sourceSets.main.jni.srcDirs = []' to the defaultConfig section.
Just click the run button in Android Studio.
What we did here is basically disabled the Android Stdio's JNI compile and manually built it using ndk.
Start with unity3d, its easy to get a working demo with a week with Unity3D.
And support is very good, documentation is top notch.
Hope this will help.
Tango NDK Tutorial Will help but the basic layout is
Setup a new project
Create your Java activity
Create a JNI file to bridge Java to the C++
Create your C++ logic
Setup your Makefiles and Gradle (probably the most annoying part)

Is it practical to start a Unity game from an Android app and revert back from Unity to the app?

I'm having an android project build in android native code[Java]. and one another game project build in unity. I wanna launch the game project from within android app and on exit or completion get back to the android app.
The unity? game project contains following file hierarchy, I don't have any taste of this unity thing. Well i'm not even sure, is this the unity based project ?
Screenshot of game project files http://img821.imageshack.us/img821/321/4ird.png
You should be able to have two activities in your app, one using your java code and another with the Unity game. Android is already pretty good at switching between activities.
Check out this: http://developer.android.com/training/basics/firstapp/starting-activity.html
You'll probably need to add your Java project as a plugin in Unity and override the AndroidManifest.xml in the Unity project to load the Java activity. Check out this documentation on extending android projects in Unity: http://docs.unity3d.com/Documentation/Manual/PluginsForAndroid.html

How to embed jars to make them usable in Xamarin cross-platform App

I am trying to port my Android Application, developed with Google Android ADT, in Xamarin to make it cross-platform and runnable on iOS devices.
I am ready to translate the needed code from Java to C# but I don't know the best way to manage external libraries.
I am using 3 jars in my App:
android-support-v4.jar
mysql-connector-java-3.0.17-ga-bin.jar
YouTubeAndroidPlayerApi.jar
I tried to embed them following these instructions:
http://docs.xamarin.com/guides/android/advanced_topics/java_integration_overview/binding_a_java_library_%28.jar%29
but I'm getting some compilation errors. Here's one of them:
'Com.Mysql.Jdbc.Util' in '[..]\AndroidHelloWorld\JavaBindingLibrary\obj\Release\generated\src\Com.Mysql.Jdbc.Util.cs'
is in conflict with
'Com.Mysql.Jdbc.Util' in '[..]\AndroidHelloWorld\JavaBindingLibrary\obj\Release\generated\src\Com.Mysql.Jdbc.Util.BaseBugReport.cs'
I don't know if it's worth going on trying to fix the errors or it's better to use native libraries for iOS.
As you'll have separate projects for each platform, I would just use the appropriate jars, as there can be differences in the way Youtube works, for example, that would make the android jar unusable in an iOS project.
But about the errors you encountered, it's worth reading this link thoroughly.
You won't be able to use any of your Android specific code or libraries on iOS.
You have two basic options for cross platform development, to create a Xamarin Forms project or create a iOS, Android and Shared project.
If you decide to go with Xamarin Forms you will need to:
* Extract your platform independent code into a shared PCL project
* Redevelop your front end in Xamarin Forms
If you decide to go with separate projects you will need to:
* Extract your platform independent code into a shared PCL project
* Develop an iOS front end project

Categories

Resources