Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Lex · Sep 29, 2011 at 02:33 PM · androidpluginjavaandroidjavaobject

Using AndroidJavaObject properly

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:

  1. Created a new project

  2. Switched to Android

  3. Added the .jar > Plugins/Android/BFCGAdsLib.jar

  4. 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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Tiozao · Oct 26, 2011 at 01:49 PM

Actually they have an Unity plugin: http://push.bestcoolfungames.com/static/binary/BCFGAds_Unity.zip

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Problem in android java plugin 0 Answers

How do I override an Android Java class in Unity? 1 Answer

How do you access a custom Java class from Unity? 1 Answer

Android: Intent extras not being received when launching an already-open UnityPlayerNativeActivity 0 Answers

Android Plugin in Unity - No Return Value 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges