JNI crash issue

I am trying to make a JNI call to allow the user to send an email on android
But my app crash on startup with this exception:

E/HXCPP   (12932): Called from Contact::boot Contact.hx line 11
E/HXCPP   (12932): Called from lime.system.JNI::createStaticMethod lime/system/JNI.hx line 120
E/Exception(12932): JNI Exception
E/ActivityManager( 2344): Invalid thumbnail dimensions: 0x0

in my Contact.hx haxe class I have:

private static inline var JNI_PATH:String = "tbdlab/Social";
	
	#if android
	private static var __contactEmail : String->String->String->Void = openfl.utils.JNI.createStaticMethod(JNI_PATH, "emailShare", "(Ljava/lang/String;Ljava/lang/String;)V");
	#end

public static function contactEmail(text:String, subject:String)
{
	try{
		#if android
			__contactEmail(text, subject, Constants.CONTACT_EMAIL);
		#end
	}catch(e:Dynamic){
		trace("Email Contact Exception: "+e);
	}
}       

in ext/java/dbdlab/Social.java

package tbdlab;

import android.content.Intent;
import android.app.Activity;
import android.content.pm.ResolveInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageItemInfo;
import android.content.pm.PackageInfo;
import android.net.Uri;
import android.text.TextUtils;
import java.util.ArrayList;
import java.util.List;
import java.net.URL;
import java.net.URLConnection;
import org.haxe.extension.Extension;
//import org.haxe.lime.GameActivity;

public class Social
{
    public static void emailShare(final String text, final String subject, final String toemail) {
            Intent email = new Intent(Intent.ACTION_SEND);
    		//email.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            if(subject!=null && subject!="") email.putExtra(Intent.EXTRA_SUBJECT, subject);
            if(text!=null && text!="") email.putExtra(Intent.EXTRA_TEXT, text);
    		if(toemail!=null && toemail!="") email.putExtra(Intent.EXTRA_EMAIL, toemail);
            email.setType("message/rfc822");

            Activity currentActivity = Extension.mainActivity; //GameActivity.getInstance();
            currentActivity.startActivity(Intent.createChooser(email, "Choose an Email client:"));
          }
}

in project.xml
<java path="ext/java" if="android" />

The Social.java file seems to be correctly found by the compiler (I there is an error in this file, it complains), so I guess the issue is probably the JNI_PATH in Contact.hx that is wrong. But I couldn’t figure which one should be the correct one… I someone could help? Thanks

Perhaps "(Ljava/lang/String;Ljava/lang/String;)V" should be "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"?

Yes just found the error myself. Was trying to delete this post but didn’t found how :wink: .
Thanks for your help though. You can close or delete this post.

You might prefer to use macros for this. The macro will figure out what the JNI arguments look like, so you won’t make this kind of mistake anymore.

It’s been on my list to improve lime.system.JNI to support @:jni meta and a build macro (similar to lime.system.CFFI), do you think we should talk to shoebox about allowing intheboxmacros (or portions of the code) to become merged with Lime, or, do you think we should just create something similar?

I think this style of syntax is much better

I haven’t found Shoebox to be very responsive, but go ahead and ask. Otherwise, I’d be happy to help with the implementation.