Forum Xamarin.Android

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Java Binding Project Surprise

CaptainXamtasticCaptainXamtastic GBUniversity ✭✭✭

Hi!

I've got a Java Binding project that compiles, but when I reference the .dll to my Xamarin.Android project, and build that, I get an error that surprisingly, if I click on it, I go through to Java code, not the autogenerated C# code:

RedactedImplementor.java(8,8): Error JAVAC0000:  error: RedactedImplementor is not abstract and does not override abstract method onNewValue(RedactedValue) in RedactedListener
public class RedactedListenerImplementor
 (JAVAC0000) (MyXamarinAndroidProjectName) javac

How do I approach an issue like this?

Kind regards,

Anthony

Answers

  • David_HollowellDavid_Hollowell USXamarin Team Xamurai
    edited March 2020

    It looks like RedactedImplementor is extending an abstract class or interface. That abstract class has a member onNewValue that should be implemented by RedactedImplementor. Is RedactedImplementor something you wrote?

  • CaptainXamtasticCaptainXamtastic GBUniversity ✭✭✭
    edited March 2020

    @David_Hollowell said:
    Is RedactedImplementor something you wrote? Is it extending an abstract class or interface, but not implementing the abstract method definitions?

    Hi David!

    It was written by the end client and extends an interface but doesn't implement the method.

    The method itself doesn't show in the disassembler as being marked abstract, despite that the error message says so.

    (Where I've used the word redacted in the code above, I've merely hidden the client's product identity.)

    Does this need to be / is capable of being fixed in the Java?

    Or does the transform (or other) tooling give me some scope for resolving it without editing the Java?

    I had thought about decompiling it, modifying the class, and recompiling it - but then there is the dilemma of what purpose the override would have.

    We can get the original source, if need be.

    Here's a skeleton with explanation:

    The Xamarin.Android Java Binding Library takes .jar and .aar files, and the .aar files, which are zip files, contain compiled java classes.

    The following is an example of a class that implements and interface, however you'll notice that the interface has not been implemented.

    The interface itself follows the class.

    Class extending interface but not implementing method defined in interface:

    package part1.part2;
    // RedactedListenerImplementor.java
    public class RedactedListenerImplementor
        extends java.lang.Object
        implements
            mono.android.IGCUserPeer,
            part1.part2.RedactedListener
    {
        public RedactedListenerImplementor()
        {
        }
    
    (with the mono.android.IGCUserPeer implementations here only)
    }
    

    Interface:

    package part1.part2;
    
    public interface RedactedListener {
      void onNewValue(Redacted);
    }
    
  • CaptainXamtasticCaptainXamtastic GBUniversity ✭✭✭
    edited March 2020

    @David_Hollowell How would you approach resolving the above in a Java Binding Library? Is editing the actual java and recompiling it the only possibility, or does the Java Binding Library tooling offer another approach?

  • CaptainXamtasticCaptainXamtastic GBUniversity ✭✭✭
    edited March 2020

    Ah, it looks like these java files were generated as part of the build, to handle interop!

    Edit: Yes, they were, thanks for your help, I'll close the issue, I overlooked the matter that the java errors were in generated code and not in the original .aar libraries, a simple remove-node solved it. What a week! I hadn't found a single case of .java code throwing errors, and if there is a lesson here, when java errors occur, first look at the path of the java file, as it turned out it was deep in the Xamarin.Android app under thew obj directory, I hope this helps anyone else with java errors!

Sign In or Register to comment.