Hello everyone, I’m trying to implement an Android plugin in my game. The plugin comes ready to use and seems to be really easy to integrate outside Unity so it shouldn’t be a problem. Here is a link for the Plugin Docs: http://tools.bestcoolfunmobileads.com/static/html/documentation.html (check steps 3~6)
After lurking a little (never used java code other than Unity-Ready plugins in my apps) I did the following for testing purposes:
-
Created a new project
-
Switched to Android
-
Added the .jar > Plugins/Android/BFCGAdsLib.jar
-
Wrote a simple testing code:
void OnGUI () { if (GUI.Button(new Rect (15, 125, 450, 100), "Test")) { AndroidJavaObject jo = new AndroidJavaObject("com.bestcoolfungames.adsclient.BCFGAds", "this"); jo.Call("requestAd"); if (jo.Call<bool>("isReady")) { jo.Call("showAd", "BFCGAdsLibSampleActivity.this"); } } }
But running on Editor I get the following on the console:
JNI: Unable to find constructor method id with signature '(Ljava/lang/String;)V'
UnityEngine.AndroidJavaObject:.ctor(String, Object[])
CallJavaCode:OnGUI() (at Assets/CallJavaCode.cs:9)
JNI: Unable to find method id for 'requestAd'
UnityEngine.AndroidJavaObject:Call(String, Object[])
CallJavaCode:OnGUI() (at Assets/CallJavaCode.cs:10)
JNI: Unable to find method id for 'isReady'
UnityEngine.AndroidJavaObject:Call(String, Object[])
CallJavaCode:OnGUI() (at Assets/CallJavaCode.cs:11)
I understand the errors and I know I should not pass “this” as the parameter, but what should I pass then? What about the “BFCGAdsLibSampleActivity.this” parameter once I get my object working?
Would I get it to “work” or get any progress just running on Editor or I’ll need to test on actual device?
And finally, are there any steps I’m missing? Is it alright to just copy the .jar in that folder and everything will work?
If anyone with more experience think that would be easy to make this plugin work and would kindly create a .unitypackage I’d be really glad ;D