Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by SoylentGraham · Dec 19, 2014 at 07:04 PM · androidjni

Can I get a list of methods for a class with JNI?

I'm interfacing with the Android SDK and currently trying to call MediaCodec.getInputBuffer(int). I'm getting an error that the method/signature doesn't exist though;

 AndroidJavaObject InputByteBuffer = Codec.Call<AndroidJavaObject> ("getInputBuffer", BufferIndex);

My Codec class is fine (dequeBufferIndex gave me a valid index), but when I execute this line I get

 Exception:
 java.lang.NoSuchMethodError: no methid with name='getInputBuffer' signature='(i)Ljava/lang/Object;' in class Landoird/media/MediaCodec;

So, I'm presuming this function exists, but maybe I need to re-interpret ByteBuffer as a different type?... or perhaps call it manually with an explicit signature...

So what would really help is a way of seeing all the methods on a Java class... isthis possible?

Comment
Add comment · 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 ytrew · Oct 19, 2015 at 11:41 PM 0
Share

Hey @SoylentGraham,

Did you ever have any luck interfacing with the mediaCodec? I'm working on a project atm and would value your insight.

avatar image SoylentGraham · Oct 19, 2015 at 11:45 PM 0
Share

Yes, but mostly through the ND$$anonymous$$ (in a c++ plugin with JNI). I'm far far more educated in JNI now :) Feel free to send me a message, email, tweet etc if you need help with something

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Bunny83 · Dec 19, 2014 at 07:31 PM

Unity nor JNI provides any reflection interface. However, Java itself has reflection support. Though using Javas' reflection via JNI would probably be a pain. Also using reflection most likely wouldn't tell you more than the Android API documentaion can tell you. So getInputBuffer does exist and the signature should be:

 (I)Ljava/lang/Object;

I don't know why your signature has a lowercase "i" as parameter type. I'm not even sure if it makes a difference. What type has your BufferIndex variable? Unity's JNI wrapper detects and generates the signature based on what you pass to the method.

Comment
Add comment · Show 4 · 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 SoylentGraham · Dec 20, 2014 at 09:49 PM 0
Share

It was actually a capital i, couldn't copy & paste the error at the time

avatar image SoylentGraham · Dec 20, 2014 at 09:51 PM 0
Share

I verified the signature by calling this (in OSX ter$$anonymous$$al)

 javap -classpath android.jar -s android.media.$$anonymous$$ediaCodec

which is in fact

 (I)Ljava/nio/ByteBuffer;

But this didn't work either. I got the android API value at runtime to check it was up to date (19), but still refused to work.... strange.... never quite figured it out and just used the deprecated getInputBuffers

avatar image Bunny83 · Dec 21, 2014 at 06:41 AM 0
Share

(I)Ljava/lang/Object; should already be a valid signature since ByteBuffer is, like all objects, derived from Object. Unity uses Object for any class derived from Object. Can you post a bit more of your code? Especially how you get / create the instance of the $$anonymous$$ediaCodec class.

avatar image SoylentGraham · Dec 21, 2014 at 01:58 PM 0
Share

ah, I assumed the signature must be precise (this is my first time using JNI :) All the code is up here https://github.com/SoylentGraham/UnityAndroidVideoTexture/blob/master/Assets/$$anonymous$$ediaCodec.cs Though I've mostly abandoned this now (using the low level GL stuff is a pain with the external texture type) and just using a c++ plugin ins$$anonymous$$d. Though it would have been nice to get it working without a plugin.

avatar image
0

Answer by SoylentGraham · Jun 11, 2015 at 06:43 PM

Revisiting my own answer... don't forget

 cd $ANDROID_HOME/platforms/android-19

first, otherwise it won't find any classes

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Getting native Android String constants via JNI broken in Unity 2019.2.0? 3 Answers

Getting byte[] or ByteBuffer[] from native Java 1 Answer

Passing AndroidJavaObject to C++ method using JNI 0 Answers

What is the difference between AndroidJavaClass.Call and AndroidJavaObject.Call 2 Answers

JNI - local reference table overflow 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