- Home /
Integrating android jar file with Unity .?
I'm using Unity Basic version 4.2.2,
Is there any way to add the jar file (for advertisement ) to the simple project in unity.
Through docs , external jar file is supported only in Unity pro ..? then how can i use it in Unity basics. is there any way... kindly guide me here.
Project code was written in C# . kindly guide me how to integrate it with jar. ?
Thanks in Advance.
Answer by Trungdv · Nov 27, 2014 at 10:02 AM
"Integrating android jar file", do you mean "Plugin for Anroid"? ( http://docs.unity3d.com/Manual/PluginsForAndroid.html )
P/s: If your product is for Android/Iphone, Plugin feature is available in Unity Free. If your target is Pc, Mac, Linux, ... this feature is only available in Unity Pro.
thank you very much ..!!
I have an created a jar file for custom Advertisement , is there any way to integrate it with unity .?
Just copy that jar file into Assets/Plugins/Android in your project. If the folder does not exist, create a new one (folder name must be exactly).
Then in Unity C# code, to use your java code, follow this example:
//To create a object in java, for example a string
AndroidJavaObject jo = new AndroidJavaObject("java.lang.String", "some_string");
//To call a function in java code, for example hashCode() of string object
int hash = jo.Call<int>("hashCode");
For more details and code examples, you should read this link: http://docs.unity3d.com/$$anonymous$$anual/PluginsForAndroid.html I know it will cost time, but it's best method to understand about how to create a plugin in Unity.
Thanks ... i'll try this method and get back to you.
And how can i call some functions that contains parameters.
Use this:
public ReturnType Call(string methodName, params object[] args);
or this (for static function):
public ReturnType CallStatic(string methodName, params object[] args);
Example:
AndroidJavaObject jo = new AndroidJavaObject("java.lang.String");
string valueString = jo.CallStatic<string>("valueOf", 42.0);
For more details: http://docs.unity3d.com/ScriptReference/AndroidJavaObject.html
Great ..!! thank you, i'll try this and get back to you ... thank you once again..!!
Your answer
Follow this Question
Related Questions
Android Unity Integration 0 Answers
Integrating .jar file with unity 1 Answer
Facebook integration with the latest version of FB 1 Answer
What are the steps required to integrate StartApp's SDK for Unity? 0 Answers
Facebook apprequest problem 2 Answers