How do I understand generated java bindings

I went through the current tutorial on the website https://doc.multi-os-engine.org/multi-os-engine/4_create_ui/2_with_storyboard/with_storyboard.html, I can generate the bindings file, it generates a lot of java code. Is all the generated code needed? There are a lot of methods that are generated that are not eve in my “.h” file. The tutorial and documentation is out of date, I am currently on Android Studio 2.3.3 and Multi-OS 1.3.2. When I go through both the Kotlin and Java samples, I don’t see any generated bindings code, it looks like the view controller code is manually created.

In short, is there a way to better understand all the generated code created from generating a bininding?
Is all that code needed or can I delete what is not used?
When will the documentation and tutorial be updated to handle MOE 1.3.2?

Any help or information on this would be greatly appreciated.

Thanks

Hi Adam,

yes, the documentation needs an update – it is in progress, but not yet ready.

Probably the source of your confusion is that you can use MOE in many different ways.

For example:

  • You can write your ViewControllers in Java, and generate Objective-C stubs from your Java code to use it in Xcode Storyboards.
  • You could also create the skeleton of your ViewControllers in Objective-C, and generate Java bindings for them (and also extend the generated Java bindings in your Java code!)

The old documentation talks about the second option. The generated code includes methods that are required by he Objective-C runtime (and/or Nat/J).

If you have any more questions, just go ahead, we are happy to answer.

Best Regards,
Gergely

I have generated bindings for Google Ads for my project. I can answer one of your questions that the generated code is all you need. Check the original documentation of the third party library to find the method you want. The generated code will have a similarly named method. Trial and error and code completion will help you here.

For example, the code to display an interstitial ad of google ads. This is the code in Obj C:

self.interstitial = [[DFPInterstitial alloc] initWithAdUnitID:@"/6499/example/interstitial"];
[self.interstitial loadRequest:[DFPRequest request]];

Using the moe generated bindings, it will be like this in Java:

dfpInterstitial = DFPInterstitial.alloc().initWithAdUnitID("/6499/example/interstitial");
DFPRequest dfpRequest = DFPRequest.request();
dfpInterstitial.loadRequest(dfpRequest);

This was the thread I created when I had trouble with the generate binding option. If it helps.

Hi @kisg

I’m looking for an example/tutorial/documentation about the first option, but I found none.
I created java codes like this:

> @Selector("tableView")
> @Property
> @IBOutlet
> public native UITableView getTableView();

And I was hoping it would magically appear in the Storyboard “Connections inspectors”, but it didn’t. Do you have any idea of what I’m missing?

@kisg

My bad. I was selecting the component itself while in the Storyboard, not the ViewController…
It works XD