Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erorr : jnr.ffi.provider.jffi.Provider #310

Open
2246sam20 opened this issue Oct 14, 2022 · 0 comments
Open

Erorr : jnr.ffi.provider.jffi.Provider #310

2246sam20 opened this issue Oct 14, 2022 · 0 comments

Comments

@2246sam20
Copy link

Hello! I am trying to run native Functions on Android mobile using android studio
I am using Android studio and took reference from the JNR docs and

implementation("com.github.jnr:jnr-ffi:2.2.12") adding jnr as dependency in build.gradle file

public class HelloWorld {
    public interface LibC {
        int setenv(@In String name, @In String value, @In boolean overwrite);

        int unsetenv(@In String name);

        String getenv(@In String name);
        int clearenv();
        int puts(String s);
    }
    public static void main(String[] args) {
        Map<LibraryOption, Object> libraryOptions = new HashMap<>();
        libraryOptions.put(LibraryOption.LoadNow, true);
        libraryOptions.put(LibraryOption.IgnoreError, true);
        String libName = Platform.getNativePlatform().getStandardCLibraryName();

        LibC libc = LibraryLoader.loadLibrary(
                LibC.class,
                libraryOptions,
                libName
        );
        final String pwdKey = "PWD"; // key for working directory
        final String shellKey = "SHELL"; // key for system shell (bash, zsh etc)

        libc.puts("Hello World!");
        // even the special "_" environment variable is now null
    }
    
This is my  MainActivity.kt file
    override fun onCreate(savedInstanceState: Bundle?) {
       super.onCreate(savedInstanceState)
       setContentView(R.layout.activity_main)
  
       var args: Array<String> = arrayOf("shutdown");
       HelloWorld.main(args)

}

And I m checking this android app on a mobile phone for now
After I Run the app it quickly crashes

Below is the error m getting:

AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.hdmitest_v2, PID: 5869
    java.lang.UnsatisfiedLinkError: could not load FFI provider jnr.ffi.provider.jffi.Provider
        at jnr.ffi.provider.InvalidProvider$1.loadLibrary(InvalidProvider.java:49)
        at jnr.ffi.LibraryLoader.load(LibraryLoader.java:420)
        at jnr.ffi.LibraryLoader.loadLibrary(LibraryLoader.java:174)
        at jnr.ffi.LibraryLoader.loadLibrary(LibraryLoader.java:192)
        at com.example.hdmitest_v2.HelloWorld.main(HelloWorld.java:44)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant