Closed DonaldTrump88 closed 7 years ago
Thanks. But it'd be better to discuss it here cause people will not understand why mitsoko is being discussed in embeddedRest
repo
I felt so. So I opened this issue. For for background of following discussion, you may refer https://github.com/fnc12/embeddedRest/issues/4
What do you mean release of created string? Dalvik garbage collector releases all local variables once it decides to do so.
If it goes to Dalvik then its garbage cleaner will delete it. But it depends on usage of create. I am not sure, how it is used. What about GetStringUTFChars string? Shouldn't it be released? https://www3.ntu.edu.sg/home/ehchua/programming/java/JavaNativeInterface.html https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#GetStringUTFChars
Yes, GetStringUTFChars
gotta be released probably but I don't do it. We gotta add release of them. Also it would be great to add auto release of local variables cause local variables pool is limited to 512. Once Mitsoko/JNI creates 513th one app crashes. Local variables can be released explicitly but it is optional. Also it is good to create global reference class to keep global vars in JNI. Now the only way to create global ref is to call JNI env directly using java::lang::JNI::Env()->NewGlobalRef(...);
. BTW java::lang::JNI::Env()
returns JNIEnv
pointer used for pure JNI functions. So you can use it. JNIEnv
pointers are stored in a static map one per thread. The map is guarded by mutex cause it's very important and can be accesses in different threads (I met data races - it's hard to debug it on android).
Yes, you are correct.
Oh I forgot one thing about dependencies - you also gotta include mitsoko-template/proj.android/app/src/main/jni/
dir with its contents cause this is a folder with C++ compilation scripts and NI.cpp
source that has java native
functions implementation.
And what about LOCAL_LDLIBS += -llog -ldl -landroid
?
Good morning, I think, you need log lib due to __android_log_write in AndroidUtil.hpp. I did not find its usage in the library itself. Is it possible to add preprocessor directive to make it enableable it, e.g ENABLE_ANDROID_LOG or atleast DISABLE_ANDROID_LOG?
you can log with LOGI
macro like LOGI("name = %s", name.c_str());
.
Also cout
is redirected to android log so just <<
data to cout
to see it in logcat.
Thanks, there is also libandroid.so used for linking. But there no header include in Mitsoko from https://developer.android.com/ndk/guides/stable_apis.html . May I know why Mitsoko does need libandroid.so?
libandroid.so
is required for CrystaX
NDK https://www.crystax.net
Interesting. What do you do with it? I saw that you have used APP_STL := gnustl_static also.
CrystaX has better implementation of std lib. E.g. google ndk hasn't std::to_string
implementation but CrystaX ndk has.
APP_STL
doesn't matter. I used all of options and it compiles well.
Good, so can I stay with Android NDK instead of CrystaX? I think, it should work.
You can try. But I cannot guarantee it will work. Anyway it's easy to switch NDK - just download it and set path in the project in properties.local
file
I read its features from https://www.crystax.net/en/android/ndk. Unfortunatelly, they does not offer me any additional value over standard NDK.
https://github.com/fnc12/Mitsoko/blob/master/Url/Request.cpp Mitsoko::Url::Request::performAsync<std::vector<char>>
function
Closing the issue.
I added this issue for people who want to discssion about the library. https://github.com/fnc12/embeddedRest/issues/4