You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
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
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:
The text was updated successfully, but these errors were encountered: