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
2
Question by FarshidAbz · Dec 09, 2016 at 05:08 PM · androidandroid-sdkunity-androidandroidjavaobject

AndroidJavaProxy no such method exception,AndroidJavaProxy no such proxy method error

I'm trying to create a plugin that allows me to access an SDK from my game. I can call SDK methods just fine using AndroidJavaObject and I can pass data to them with no issue. But there are some SDK methods that require an interface to be passed.

After searching to how to use interfaces in unity i found AndroidJavaProxy, and i follow this tutorial and this is my code:

 class DailyBudgetCallback : AndroidJavaProxy
     {
         public DailyBudgetCallback() : base("ir.ordibehesht.sdk.sdk.playservices.interfaces.DailyBudgetCallback") { }
         public void onDailyBudgetResponse(DailyBudget dailyBudget) {                
             Debug.Log("daily budget response ");
         }
     }

After running application and calling my method i get this error : Unity: Exception: No such proxy method : DailyBudgetCallback.onDailyBudgetResponse(UnityEngine.AndroidJavaObject)

what's my problem ? can any body help me please ?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by liortal · Dec 09, 2016 at 09:10 PM

The first thing to do is read the documentation for AndroidJavaProxy to give you a basic concept of what this class does and what it should be used for.

Typically, you would use this class when you need to callback from Java code back to your Unity C# code. It helps by removing some of the "messy" code you have to write to achieve that.

In order to use AndroidJavaProxy, you must have a Java interface that you wish to implement. You then declare a new class derived from AndroidJavaProxy that should define the methods that will be called back from Java.

Optionally, you can define a C# interface that matches the Java interface so you don't forget to implement any of the required methods (this is not a must, in case there's no interface defined, Unity will try to match the methods by name).

Now to your code in question:

 class DailyBudgetCallback : AndroidJavaProxy
 {
     public DailyBudgetCallback()
         : base("ir.ordibehesht.sdk.sdk.playservices.interfaces.DailyBudgetCallback")
     {
     }
 
     public void onDailyBudgetResponse(DailyBudget dailyBudget)
     {                
         Debug.Log("daily budget response ");
     }
 }

You defined a new class that is derived from AndroidJavaProxy, passing the name of the required Java interface in its constructor. So far so good.

The callback method onDailyBudgetResponse receives a parameter called DailyBudget. You didn't specify what this object is.

If this is an object that is defined in Java, your C# code knows nothing about it (even if you created a matching type in your C# code).

If that is the case, you should declare it as a AndroidJavaObject type. What this means is that effectively your callback is called, passing a reference to a Java type that you can interact with, using the AndroidJavaObject object instance.

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
avatar image
0

Answer by iceherosubzero · Jan 16, 2020 at 06:36 AM

Hello @liortal,

In your response to @FarshidAbz you said:

The callback method onDailyBudgetResponse receives a parameter called DailyBudget. You didn't specify what this object is.

If this is an object that is defined in Java, your C# code knows nothing about it (even if you created a matching type in your C# code).

If that is the case, you should declare it as a AndroidJavaObject type. What this means is that effectively your callback is called, passing a reference to a Java type that you can interact with, using the AndroidJavaObject object instance.

Can you please elaborate more on this as to where do we need to declare AndroidJavaObject in our unity c# callback parameter or at the java end?

Also can you show us an small code snippet explaining what you meant.

That would be a really great help for all.

Regards,

Iceheros.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

I want to know how to access an external USB camera connected to my Android smartphone. 0 Answers

Unity to Android: passing CameraCharacteristics.Key values from Unity to Android cameraCharacteristics.get? 1 Answer

Finish UnityPlayerActivity in android unity project 0 Answers

Bugsense in unity(android) 1 Answer

Unity won't accept Android SDK Location 1 Answer


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