Generating Java Bindings in 1.3 beta - How to do so?

Dear Eugene,

I don’t think your missing anything. In MOE 1.3.0-beta-2 the changes to NatJGen included 2 major things:

  • +initialize and +load methods are no longer bound (you met the issue with +initialize)
  • Support for ObjC classes in Swift was added (you also met this in the form of “Binding class refers to class BarChartView, but it can not be found. Fallback to indirect super class.” messages)

The issue your having with valueFormatter is not a bug. NatJGen generates bindings with best effort and sometimes it will fail to give the perfect ones, but it will still try to fallback on lesser bindings and only if everything fails will it decide not to generate it. This is why we have the @Generated annotation. If you choose to modify a binding and want NatJGen to leave it as-is on the next run, simply remove the @Generated annotation.

Does this answers your questions?

Best Regards,
Kristóf

Kristóf, thank you for an explanation. Though I still find it confusing… The java class was generated using IChartValueFormatter name, but it seem like binding generator was trying to find IValueFormatter (note a different name) when it was trying to resolve references to swift’s IValueFormatter type, and because there is no IValueFormatter.java it silently generated Object type instead.

It is a big issue, because there are no any notification/warnings that Object type wasn’t the true source type and it was hard to manually find all the places where it wasn’t been able to resolve a proper type. It would be really useful to either add some special annotation (and put the source type in value there, so you can just search all occurrences of that annotation in the Java IDE) or at very least dump list of all the places into a Console view (source file name, line and column, as well as unresolved type name).

Thank you again for a great support. I wad really amazed that I’ve been able to get the Charts pod work in iOS app, with my more than sparse knowledge of iOS development. You guys are fantastic!

We created an issue for tracking this:

https://github.com/multi-os-engine/multi-os-engine/issues/84#

As you can see from the issue, there are cases that cannot be easily represented in Java (e.g. if there are multiple interfaces / protocols specified). Simple cases (like this one) should however use the concrete type.

Kristóf, thank you for that. I found another issue. The chart.chartDescription class has a property textAlign which wasn’t generated.

Is that because of a NSTextAlignment type not found? Do I need to manually include Foundation and CoreGraphics?

What bugs me most is that binding generator is being silent for all those issues. Warnings on a console or special warning annotations in generated java code would go a long way…

Dear Eugene,

we couldn’t reproduce this issue. We have also created a Charts-based sample and used MOE 1.3.0-beta-2 for generating bindings. We also had to correct some issues manually, but this wasn’t one of them.

In the project’s root you can find the nbc file we used.

I would recommend re-generating the bindings for Charts if the following happened:

  1. You generated bindings for Charts, but got a lot of errors because of the missing UIKit import
  2. You added import UIKit to nbc
  3. You generated again without removing the previous bindings.

In this case NatJGen might not work as intended and may not fix incorrect bindings.

Best Regards,
Kristóf

Hey Kristof. I am facing issue in integrating Crashlytics framework. I tried the method which is given in this link. Also tried what you suggested here to get the pods. But nothing is working. After installing pod, the whole project is getting screwed up. It won’t even run once. Please help me. I am stuck with this from past 3 days. I tried to generate JAR from the pod as well as framework by using the given link. But both are giving the following error “/Users/santhoshlaxminarayana/.moe/moe-sdk-1.3.0-beta-2/tools/–pod/Users/santhoshlaxminarayana/Desktop/Podfile/–output-file-path”
Please Please Please help me.

Did you update your project’s build.gradle to work with Xcode workspaces (required by CocoaPods)? Can you share your project (or a test project you create that has this issue) so we can take a look?

Thanks a lot for the reply Gergely. Here i am giving the link for my project. I have implemented as specified by Kristof on Jan 6 in the same thread.
http://jmp.sh/fYAnGSm

Gergely, Kristof

Do you still plan to have a tutorial in the 1.3 release for how to generate bindings from pods using whatever method you officially suggest?

Mike

1 Like

Hi,

yes.

Also, we are working now on our official moe-bindings repository that will contain the projects in the structure that we recommend.

Best Regards,
Gergely

Is there any chance that Firebase will be included in that official bindings repository?

Mike

Sure, we will include it. I will create an issue on GH to track this

Hi Gergely/Kristof. Could you go through my code? I am completely stuck with this. Please help me.

Dear Santhosh,
this is the process you need to follow:

  • Open project in xcode
  • Remove debug, release custom cunfiguration, set to none
  • cd …/ios-moe/xcode
  • pod install
  • add include to pod xconfigs: #include “…/…/…/ios-moe/custom.xcconfig”

The extra steps are required because it is a libgdx project, that has a slightly different configuration. I attached the fixed project with the generated bindings.

Best Regards,
Roland

Thank you very much Vighr. I will try this.
I am afraid, you forgot to attach the project.

Sorry!

https://drive.google.com/file/d/0BxaA-mVsTwv5RTFRN2M0dDRyYlE/view?usp=sharing

Thanks a lot. I am trying it.

Thank you very much Vighr. It is working like a charm.
But i have another problem here. I am not able to generate bindings for the same. I created .nbc file and kept it inside the ios-moe folder (root folder). Went to Android Studio, right clicked on the project, Multi-OS Engine Actions -> Generate Bindings. It opened a popup asking for the package. I gave ‘Crashlytics’. But it is not generating the bindings. Please help me how to do this. Here is my .nbc file.
Crashlytics.nbc (294 Bytes)

From the menu item you describe, I am pretty sure you are not using the correct IDE plugin (1.3 beta 2), but the 1.2 one, because this menu item no longer exists. Please follow the instructions in the blog post

Thanks a lot Gergely. It is working fine now. Thank you very much.