• 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
Question by dorpeleg · Jun 06, 2017 at 03:42 PM · androidpluginpluginsandroidpluginjni

Getting byte[] or ByteBuffer[] from native Java

Hello,

I have a native Android plugin that has a method that does somet$$anonymous$$ng and returns ByteBuffer[]. I could change it to possibly return byte[].

My problem is that I can't seem to call that method from Unity..... I have triad to to t$$anonymous$$s in the following way:

 classInstance.Call<AndroidJavaObject>("methodName", 0);

or

 classInstance.Call<byte[]>("methodName", 0);

The Java method looks somet$$anonymous$$ng like:

 public static byte[] methodName(int index){
     byte[] b = w/e
     return b;
 }

I have triad making the method static or not static. In all cases, I get the following error:

AndroidJavaException: java.lang.NoSuchMethodError: no static method with name='methodName' signature='(I)Ljava/lang/Object;' in class Ljava.lang.Object;

Any ideas as how I can t$$anonymous$$s t$$anonymous$$s to work? (getting the ByteBuffer[] is preferred but getting byte[] is also ok)

Thanks!

Comment

People who like this

0 Show 2
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 ShadyProductions · Jun 06, 2017 at 08:47 PM 0
Share

You should use AndroidJavaClass if you are calling a static

avatar image dorpeleg ShadyProductions · Jun 06, 2017 at 10:13 PM 0
Share

@ShadyProductions I prefer it not to be static.... I changed it in the hopes that it will make it work. I had the same error when it was not static.

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by gnp89 · Jun 07, 2017 at 05:18 PM

It's a static method, so NoSuchMethodError makes sense, you're trying to call instance method "methodName".

Remove the 'static' modifier if you can, otherwise try using AndroidJavaClass and CallStatic:

 AndroidJavaClass myClass = new AndroidJavaClass("com.myPackage.myClass");
 byte[] result = myClass.CallStatic("methodName", 0); 

Comment

People who like this

0 Show 0 · 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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

127 People are following this question.

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

Related Questions

How do I make an Android plugin for unity? 0 Answers

Not rendering camera when using Unity as library on Android Studio 0 Answers

Can´t found android.support.v4.content.ContextCompact 0 Answers

Android Multi-Plugins 0 Answers

android time cheat plugin problem with broadcastreceiver 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