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

javacv not working on nativescript #584

Closed
matart15 opened this issue Oct 14, 2016 · 6 comments
Closed

javacv not working on nativescript #584

matart15 opened this issue Oct 14, 2016 · 6 comments

Comments

@matart15
Copy link

matart15 commented Oct 14, 2016

Please, provide the details below:

Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?

yes

Tell us about the problem

Nativescript android javacv not working

Please provide the following version numbers that your issue occurs with:

  • CLI: 2.3.0
  • Cross-platform modules: "2.3.0"
  • Runtime(s): "2.3.0"

Did the error happen while the app was being constructed? (buildtime error)

No

Did the error happen while the app was executing? (runtime error)

Yes

java.lang.UnsatisfiedLinkError: org.bytedeco.javacpp.avutil
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:309)
at org.bytedeco.javacpp.Loader.load(Loader.java:413)
at org.bytedeco.javacpp.Loader.load(Loader.java:381)
at org.bytedeco.javacpp.avcodec$AVPacket.<clinit>(avcodec.java:1650)

Please tell us how to recreate the issue in as much detail as possible.

I successfully called simple android Activity with button from Nativescript. I exported aar and imported it as plugin.

Then i tried to call custom camera Activity from Nativescript.
this activity https://github.com/CrazyOrr/FFmpegRecorder

animationsFinished: function () {
    const intent = new android.content.Intent(com.tns.NativeScriptApplication.getInstance().getApplicationContext(), java.lang.Class.forName("com.tns.NativeScriptActivity"))
    intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
    com.tns.NativeScriptApplication.getInstance().startActivity(intent);
}

Activity opens with black camera and then gives me this error

java.lang.UnsatisfiedLinkError: org.bytedeco.javacpp.avutil
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:309)
at org.bytedeco.javacpp.Loader.load(Loader.java:413)
at org.bytedeco.javacpp.Loader.load(Loader.java:381)
at org.bytedeco.javacpp.avcodec$AVPacket.<clinit>(avcodec.java:1650)

It works without problem from android studio. But not working with tns run android

camera, external storage permissions are given and on for application


I did the trick from bytedeco/javacv#133 : moved *.so files to "app/src/main/jniLibs/armeabi-v7a" and "app/src/main/jniLibs/armeabi" folders and it seems not working

@petekanev
Copy link
Contributor

petekanev commented Oct 14, 2016

@matart15
JavaCV uses JavaCPP, which in turn uses JNI under the hood, so in theory all this should work. The explanation of your approach to reproduce the issue is a bit unclear, so let's see if I understand the problem correctly.
You include the FFmpegRecorder(JavaC) library in your NS project. In a button tap callback you create an intent and fire it, and that's where the application breaks?

@matart15
Copy link
Author

matart15 commented Oct 14, 2016

@Pip3r4o yes i created aar library and called its class from {N}.

const intent = new android.content.Intent(com.tns.NativeScriptApplication.getInstance().getApplicationContext(), java.lang.Class.forName(activityName))
        intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
        com.tns.NativeScriptApplication.getInstance().startActivity(intent);

It worked. Camera displayed. Then it fails to load aar dependency with above error.

I googled few hours and found out that aar dependency must be imported together like transitive=true. But it did not work either.

this library seem to using something like this.
https://github.com/mkloubert/nativescript-social-login/blob/master/plugin/platforms/android/include.gradle#L31

But can't understand why mine does not work.
Maybe it's because i am including my aar from local lib directory

picture here is
JavaCV.jar -> FFmpegRecorder.aar -> my nativescript

@matart15
Copy link
Author

Ok I made it work by manually copying *.so files into platform/android directory.
http://stackoverflow.com/questions/33737385/does-nativescript-supports-so-file-in-android-platform

@petekanev
Copy link
Contributor

@matart15 glad to learn you got it working!

@matart15
Copy link
Author

interestingly copying *.so files into plugin/lib directory also worked.

@petekanev
Copy link
Contributor

@matart15 yes, it's the standard android structure, we ourselves pack the .so dependencies in the .aar's lib dir. Normally there will be another folder inside lib for each supported architecture.

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

2 participants