[Mono-list] Android - Assertion: should not be reached at mini.c:2244

robot9706 robot9706 at gmail.com
Fri Oct 23 21:25:50 UTC 2015


I tired to call the "DoString" function from the following C# code using
embedded Mono on Windows and Android:

namespace testlib
{
    public class MainClass
    {
        public static string DoString()
        {
            int i = GetA() + GetB();

            return i.ToString();
        }

        private static int GetA()
        {
            return 4;
        }

        private static int GetB()
        {
            return 6;
        }   
    }
}

On Windows it runs fine and returns the expected result ("10"). But on
Android when I try to invoke the "DoString" method I get the following
error: "Assertion: should not be reached at mini.c:2244".

On Windows I'm using the latest Mono that I downloaded from github and
compiled it using Visual Studio 2015, but I don't have a Linux based
computer so I can't build Mono for Android (I tired to build Unity's Mono
for Android but all the articles about building Mono for ARM are based on
Linux tools). So in my Android project I tried to use "libmono.so" from a
Unity game which works fine except the "Assertion error".

So my question is: The assertion error is happens because I'm using Unity's
Mono pr I'm doing something wrong in my Android NDK code?

This is my Android NDK test code:

#include "libmonotest.h"
#include <android/log.h>
#include <jni.h>
#include "Main.h"
#include <mono/jit/jit.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/mono-debug.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/object.h>
#include <mono/metadata/threads.h>
#include <mono/metadata/environment.h>
#include <mono/metadata/mono-gc.h>
#include <mono/metadata/mono-config.h>
#include <mono/metadata/assembly.h>

#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO,
"libmonotest", __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN,
"libmonotest", __VA_ARGS__))

extern "C" {
    void Java_com_example_com_mono_test_Native_native_1call(JNIEnv* env,
jclass cls) {
        mono_debug_init(MONO_DEBUG_FORMAT_MONO);
        mono_config_parse(NULL);
        mono_register_bundled_assemblies(bundled);

        MonoDomain* domain = mono_jit_init_version("MonoApplication",
"v4.0.30319");
        MonoAssembly* dll = mono_domain_assembly_open(domain,
"testlib.dll");
        MonoImage* img = mono_assembly_get_image(dll);

        MonoClass* mClass = mono_class_from_name(img, "testlib",
"MainClass");
        MonoMethodDesc* mthdsc =
mono_method_desc_new("testlib.MainClass::DoString()", false);
        MonoMethod* mMethod = mono_method_desc_search_in_class(mthdsc,
mClass);
        MonoString* ms = (MonoString*)mono_runtime_invoke(mMethod, NULL,
NULL, NULL);

        char* c = mono_string_to_utf8(ms);
        LOGI("Invoke result: %s", c);

        mono_jit_cleanup(domain);
    }
}
The "bundled" variable in the "mono_register_bundled_assemblies(bundled);"
line is an array of "MonoBundledAssembly" which contains the data generated
by the "mkbundle" tool. I uploaded the "Main.h" which contains the "bundled"
varaible to pasebin because it contains too much data:  LINK
<http://pastebin.com/qffZHVKs>  



--
View this message in context: http://mono.1490590.n4.nabble.com/Android-Assertion-should-not-be-reached-at-mini-c-2244-tp4666813.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list