0

I'm developing an Unity(Unity3D 5.3.5f1) project with using Java library converted into dll with IKVM 8.1 RC0 (Additionally using VS for c# development)

I converted several related jars into one dll file. There was no warning or error in converting sequence. And I put them in Assets folder in Unity project.

I tried to run my java code in C#.

This is my C# code where executes java logics (Actually shorten a lot)

using UnityEngine;
using com.mypackage.hierarchy1;
using com.mypackage.hierarchy2; // Same as the package name from Java

public class Test : MonoBehaviour {
    ...... // several variables
    private Class1 var1;
    private Class2 var2;
    // note that, Class1 and Class2 are the same name used in Java

    void Start() {
        var1 = new Class1();
        var2 = new Class2();
    }

    void Update() {
        method1(certain_param_in_int);
    }

    ......

    void method1(int param) {
         method2(param, param2, param3,...);
    }

    void method2(int param, string param2, int param3, int param4) {
        var1.method_v1(param, param2,...); // Works well with no problem
        var2.initialize("str", var1.getResult(), "anotherstr");
        var2.run(); // This method occurs the problem
    }
}

The problem is that when var2.run() is executed. method from var1 has no problem. I checked the result was correct. Anyway, var2.run() shows NullReferenceException as below

NullReferenceException: Object reference not set to an instance of an object
com.mypackage.hierarchy2.Class2.run ()
Test.method2 (Int32 param, System.String param2, Int32 param3, Int32 param4) (at Assets/Scripts/Test.cs:93)
Test.method1 (Int32 param) (at Assets/Scripts/Test.cs:66)
Test.Update () (at Assets/Scripts/Test.cs:33)

So, I tested whether it is null or not by checking var2 == null and also var2.Equals(null) with Debug.Log() just before calling val2.run(), but all of them showed 'False'. They are not null.

What is the problem? Should I change Java side code and re-generate dll?

Thanks.

p.s. My java side code uses java.util.logging.Logger and related with other java project. (which is also referenced when converting jar into dll, as I said in second sentence of the question)

p.s.2. I'm sorry but I can't open java codes here because it is confidential code

2
  • I converted several related jars into one dll file You don't convert jar file to dll. Leave it as it is and put it in Assets/Plugins/Android. I'm sorry but I can't open java codes here because it is confidential code. Make a replica of the Java plugin then change it to something that does something different than the original code, then post here. You also need to post your Class1 and Class2 scripts with your run() function. There is no way to help you if you don't have something that can be used to reproduce your problem. Right now, your code is in-complete and not enough get help. Commented Jul 12, 2016 at 6:26
  • @Programmer Leave it as it is and put it in Assets/Plugins/Android --> Then I only can use them when build target is Android, isn't it? I tried that already with Android activity included Commented Jul 12, 2016 at 6:30

1 Answer 1

0

I found that it was an error of our own code, but not java code itself. configurations.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.