Develop in C/C++

classic Classic list List threaded Threaded
33 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Develop in C/C++

mac actiaitalia
Hi everyone,

My company has to develop an API library (.so) in C / C ++ on the Android platform. The library can be incorporated into other Apps also written with different Framework (Xamarin, Flutter, Native Java / Kotlin etc.). The library will use to communicate with our external device in Bluetooth (BLE). I have not found an example to start to set up a C / C ++ project and to be able to access Bluetooth from here.
Do you have any suggestions?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/0f3030ca-963d-4602-9948-fd26f968d26do%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Develop in C/C++

Alias R. Cummins
Access to the bluetooth stack from native code is quite difficult. I'd suggest you call out to JNI for that, the Java/Kolin API will be much easier to use.

On Mon, 6 Jul 2020 at 17:38, mac actiaitalia <[hidden email]> wrote:
Hi everyone,

My company has to develop an API library (.so) in C / C ++ on the Android platform. The library can be incorporated into other Apps also written with different Framework (Xamarin, Flutter, Native Java / Kotlin etc.). The library will use to communicate with our external device in Bluetooth (BLE). I have not found an example to start to set up a C / C ++ project and to be able to access Bluetooth from here.
Do you have any suggestions?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/0f3030ca-963d-4602-9948-fd26f968d26do%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAP5h4q8FZZp2t-vfrv8LkjJ2C5hpKdiZjodMFbbE1rFhjOsrwQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Develop in C/C++

George Xian
In reply to this post by mac actiaitalia
Qt? 

There's a QBluetooth API inside Qt which will give you access to Bluetooth through a C++ interface (the Qt signals and slots is required for that to work though). My organization however just called Java methods through JNI.

On Tuesday, July 7, 2020 at 3:38:59 AM UTC+12 [hidden email] wrote:
Hi everyone,

My company has to develop an API library (.so) in C / C ++ on the Android platform. The library can be incorporated into other Apps also written with different Framework (Xamarin, Flutter, Native Java / Kotlin etc.). The library will use to communicate with our external device in Bluetooth (BLE). I have not found an example to start to set up a C / C ++ project and to be able to access Bluetooth from here.
Do you have any suggestions?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/07809b36-6345-45d1-a348-dbec69aeb28cn%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Develop in C/C++

mac actiaitalia
In reply to this post by Alias R. Cummins

Thank you for your suggestion. There is a link for tutorial or code example?

Regards


Il giorno lunedì 6 luglio 2020 23:54:28 UTC+2, Alias R. Cummins ha scritto:
Access to the bluetooth stack from native code is quite difficult. I'd suggest you call out to JNI for that, the Java/Kolin API will be much easier to use.

On Mon, 6 Jul 2020 at 17:38, mac actiaitalia <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="C24m-Y4WAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mac.act...@...> wrote:
Hi everyone,

My company has to develop an API library (.so) in C / C ++ on the Android platform. The library can be incorporated into other Apps also written with different Framework (Xamarin, Flutter, Native Java / Kotlin etc.). The library will use to communicate with our external device in Bluetooth (BLE). I have not found an example to start to set up a C / C ++ project and to be able to access Bluetooth from here.
Do you have any suggestions?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="C24m-Y4WAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">andro...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/android-ndk/0f3030ca-963d-4602-9948-fd26f968d26do%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/android-ndk/0f3030ca-963d-4602-9948-fd26f968d26do%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/android-ndk/0f3030ca-963d-4602-9948-fd26f968d26do%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/android-ndk/0f3030ca-963d-4602-9948-fd26f968d26do%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/7836cf9f-6e29-4bec-b28f-74158d9a2944o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Develop in C/C++

Glenn Kasten
In reply to this post by George Xian
https://developer.android.com/training/articles/perf-jni

On Monday, July 6, 2020 at 2:54:28 PM UTC-7, George Xian wrote:
Qt? 

There's a QBluetooth API inside Qt which will give you access to Bluetooth through a C++ interface (the Qt signals and slots is required for that to work though). My organization however just called Java methods through JNI.

On Tuesday, July 7, 2020 at 3:38:59 AM UTC+12 [hidden email] wrote:
Hi everyone,

My company has to develop an API library (.so) in C / C ++ on the Android platform. The library can be incorporated into other Apps also written with different Framework (Xamarin, Flutter, Native Java / Kotlin etc.). The library will use to communicate with our external device in Bluetooth (BLE). I have not found an example to start to set up a C / C ++ project and to be able to access Bluetooth from here.
Do you have any suggestions?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/c16dccf9-daf5-4974-9519-91920205e42fo%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Develop in C/C++

Alias R. Cummins
In reply to this post by George Xian
Yeah, if you want a cross platform native library, Qt is a good choice.

Nevertheless, you might be making your life unnecessarily difficult by going this route.
As I understand it, Bluetooth access from the NDK is deliberately limited because of the
potential security problems it could call, also Bluetooh is surprisingly complex under the
hood.

I'd recommend you start with the Qt docs:
Docs here:
https://doc.qt.io/qt-5/qtbluetooth-index.html

On Mon, 6 Jul 2020 at 23:54, [hidden email] <[hidden email]> wrote:
Qt? 

There's a QBluetooth API inside Qt which will give you access to Bluetooth through a C++ interface (the Qt signals and slots is required for that to work though). My organization however just called Java methods through JNI.

On Tuesday, July 7, 2020 at 3:38:59 AM UTC+12 [hidden email] wrote:
Hi everyone,

My company has to develop an API library (.so) in C / C ++ on the Android platform. The library can be incorporated into other Apps also written with different Framework (Xamarin, Flutter, Native Java / Kotlin etc.). The library will use to communicate with our external device in Bluetooth (BLE). I have not found an example to start to set up a C / C ++ project and to be able to access Bluetooth from here.
Do you have any suggestions?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/07809b36-6345-45d1-a348-dbec69aeb28cn%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAP5h4q9z7vtZ3hi5SY7t83nV8zYCn7_o%3Dcqc2a4FwN%2B5r3zMwA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Develop in C/C++

Alias R. Cummins
In reply to this post by mac actiaitalia
SWIG can also help reduce the JNI workload:

On Tue, 7 Jul 2020 at 20:27, mac actiaitalia <[hidden email]> wrote:

Thank you for your suggestion. There is a link for tutorial or code example?

Regards


Il giorno lunedì 6 luglio 2020 23:54:28 UTC+2, Alias R. Cummins ha scritto:
Access to the bluetooth stack from native code is quite difficult. I'd suggest you call out to JNI for that, the Java/Kolin API will be much easier to use.

On Mon, 6 Jul 2020 at 17:38, mac actiaitalia <[hidden email]> wrote:
Hi everyone,

My company has to develop an API library (.so) in C / C ++ on the Android platform. The library can be incorporated into other Apps also written with different Framework (Xamarin, Flutter, Native Java / Kotlin etc.). The library will use to communicate with our external device in Bluetooth (BLE). I have not found an example to start to set up a C / C ++ project and to be able to access Bluetooth from here.
Do you have any suggestions?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/0f3030ca-963d-4602-9948-fd26f968d26do%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/7836cf9f-6e29-4bec-b28f-74158d9a2944o%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAP5h4q8EuCMWJ-h0-L5KgcSmmJCHdCGW3xcRBwvQSfqhLTRpQw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Develop in C/C++

mac actiaitalia
In reply to this post by Alias R. Cummins
Yes, QT is also an alternative, but we didn't want to drag too many dependencies like QT's ".so" libraries.

Il giorno martedì 7 luglio 2020 23:35:10 UTC+2, Alias R. Cummins ha scritto:
Yeah, if you want a cross platform native library, Qt is a good choice.

Nevertheless, you might be making your life unnecessarily difficult by going this route.
As I understand it, Bluetooth access from the NDK is deliberately limited because of the
potential security problems it could call, also Bluetooh is surprisingly complex under the
hood.

I'd recommend you start with the Qt docs:
Docs here:
<a href="https://doc.qt.io/qt-5/qtbluetooth-index.html" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fdoc.qt.io%2Fqt-5%2Fqtbluetooth-index.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGTChWu3lSuVjKA9dIJiR04r5MsFA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fdoc.qt.io%2Fqt-5%2Fqtbluetooth-index.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGTChWu3lSuVjKA9dIJiR04r5MsFA&#39;;return true;">https://doc.qt.io/qt-5/qtbluetooth-index.html

On Mon, 6 Jul 2020 at 23:54, [hidden email] <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="P98o3RVkAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">georg...@...> wrote:
Qt? 

There's a QBluetooth API inside Qt which will give you access to Bluetooth through a C++ interface (the Qt signals and slots is required for that to work though). My organization however just called Java methods through JNI.

On Tuesday, July 7, 2020 at 3:38:59 AM UTC+12 [hidden email] wrote:
Hi everyone,

My company has to develop an API library (.so) in C / C ++ on the Android platform. The library can be incorporated into other Apps also written with different Framework (Xamarin, Flutter, Native Java / Kotlin etc.). The library will use to communicate with our external device in Bluetooth (BLE). I have not found an example to start to set up a C / C ++ project and to be able to access Bluetooth from here.
Do you have any suggestions?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="P98o3RVkAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">andro...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/android-ndk/07809b36-6345-45d1-a348-dbec69aeb28cn%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/android-ndk/07809b36-6345-45d1-a348-dbec69aeb28cn%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/android-ndk/07809b36-6345-45d1-a348-dbec69aeb28cn%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/android-ndk/07809b36-6345-45d1-a348-dbec69aeb28cn%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/833a7338-483a-4aa7-b919-b4dfeb8ce002o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Develop in C/C++

Alias R. Cummins
Qt is also expensive to your bottom line.

On Wed, 8 Jul 2020 at 08:30, mac actiaitalia <[hidden email]> wrote:
Yes, QT is also an alternative, but we didn't want to drag too many dependencies like QT's ".so" libraries.

Il giorno martedì 7 luglio 2020 23:35:10 UTC+2, Alias R. Cummins ha scritto:
Yeah, if you want a cross platform native library, Qt is a good choice.

Nevertheless, you might be making your life unnecessarily difficult by going this route.
As I understand it, Bluetooth access from the NDK is deliberately limited because of the
potential security problems it could call, also Bluetooh is surprisingly complex under the
hood.

I'd recommend you start with the Qt docs:
Docs here:
https://doc.qt.io/qt-5/qtbluetooth-index.html

On Mon, 6 Jul 2020 at 23:54, [hidden email] <[hidden email]> wrote:
Qt? 

There's a QBluetooth API inside Qt which will give you access to Bluetooth through a C++ interface (the Qt signals and slots is required for that to work though). My organization however just called Java methods through JNI.

On Tuesday, July 7, 2020 at 3:38:59 AM UTC+12 [hidden email] wrote:
Hi everyone,

My company has to develop an API library (.so) in C / C ++ on the Android platform. The library can be incorporated into other Apps also written with different Framework (Xamarin, Flutter, Native Java / Kotlin etc.). The library will use to communicate with our external device in Bluetooth (BLE). I have not found an example to start to set up a C / C ++ project and to be able to access Bluetooth from here.
Do you have any suggestions?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/07809b36-6345-45d1-a348-dbec69aeb28cn%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/833a7338-483a-4aa7-b919-b4dfeb8ce002o%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAP5h4q_e_P5cabirREwTbQW-AgHQauczRXPK5Eibzu1Qq0tZpw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Develop in C/C++

mac actiaitalia
Yes, I know. if it is the simplest solution then it might be ok.

Now I'm trying a solution without QT. I am using Android Studio and created a simple project in JNI with a method that returns a jstring (Hello World :-)). I'm trying to use Xamarin as a UI, the library created in JNI is loaded, but the method that returns the jstring returns an exception. If I create a method that returns void, everything is fine. Do you have any idea about type compatibility and how to return strings from one environment to another?


Il giorno mercoledì 8 luglio 2020 22:30:10 UTC+2, Alias R. Cummins ha scritto:
Qt is also expensive to your bottom line.

On Wed, 8 Jul 2020 at 08:30, mac actiaitalia <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="0P_nhB6vAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mac.act...@...> wrote:
Yes, QT is also an alternative, but we didn't want to drag too many dependencies like QT's ".so" libraries.

Il giorno martedì 7 luglio 2020 23:35:10 UTC+2, Alias R. Cummins ha scritto:
Yeah, if you want a cross platform native library, Qt is a good choice.

Nevertheless, you might be making your life unnecessarily difficult by going this route.
As I understand it, Bluetooth access from the NDK is deliberately limited because of the
potential security problems it could call, also Bluetooh is surprisingly complex under the
hood.

I'd recommend you start with the Qt docs:
Docs here:
<a href="https://doc.qt.io/qt-5/qtbluetooth-index.html" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fdoc.qt.io%2Fqt-5%2Fqtbluetooth-index.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGTChWu3lSuVjKA9dIJiR04r5MsFA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fdoc.qt.io%2Fqt-5%2Fqtbluetooth-index.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGTChWu3lSuVjKA9dIJiR04r5MsFA&#39;;return true;">https://doc.qt.io/qt-5/qtbluetooth-index.html

On Mon, 6 Jul 2020 at 23:54, [hidden email] <[hidden email]> wrote:
Qt? 

There's a QBluetooth API inside Qt which will give you access to Bluetooth through a C++ interface (the Qt signals and slots is required for that to work though). My organization however just called Java methods through JNI.

On Tuesday, July 7, 2020 at 3:38:59 AM UTC+12 [hidden email] wrote:
Hi everyone,

My company has to develop an API library (.so) in C / C ++ on the Android platform. The library can be incorporated into other Apps also written with different Framework (Xamarin, Flutter, Native Java / Kotlin etc.). The library will use to communicate with our external device in Bluetooth (BLE). I have not found an example to start to set up a C / C ++ project and to be able to access Bluetooth from here.
Do you have any suggestions?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/android-ndk/07809b36-6345-45d1-a348-dbec69aeb28cn%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/android-ndk/07809b36-6345-45d1-a348-dbec69aeb28cn%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/android-ndk/07809b36-6345-45d1-a348-dbec69aeb28cn%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/android-ndk/07809b36-6345-45d1-a348-dbec69aeb28cn%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="0P_nhB6vAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">andro...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/android-ndk/833a7338-483a-4aa7-b919-b4dfeb8ce002o%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/android-ndk/833a7338-483a-4aa7-b919-b4dfeb8ce002o%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/android-ndk/833a7338-483a-4aa7-b919-b4dfeb8ce002o%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/android-ndk/833a7338-483a-4aa7-b919-b4dfeb8ce002o%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/78d83f77-0476-491b-a998-50952596e4fbo%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Develop in C/C++

Alias R. Cummins
Yes, I have a fair bit of experience in this but we are drifting dangerously close to the arena of paid consultancy work.

Could you detail the error?

On Thu, 9 Jul 2020 at 09:17, mac actiaitalia <[hidden email]> wrote:
Yes, I know. if it is the simplest solution then it might be ok.

Now I'm trying a solution without QT. I am using Android Studio and created a simple project in JNI with a method that returns a jstring (Hello World :-)). I'm trying to use Xamarin as a UI, the library created in JNI is loaded, but the method that returns the jstring returns an exception. If I create a method that returns void, everything is fine. Do you have any idea about type compatibility and how to return strings from one environment to another?


Il giorno mercoledì 8 luglio 2020 22:30:10 UTC+2, Alias R. Cummins ha scritto:
Qt is also expensive to your bottom line.

On Wed, 8 Jul 2020 at 08:30, mac actiaitalia <[hidden email]> wrote:
Yes, QT is also an alternative, but we didn't want to drag too many dependencies like QT's ".so" libraries.

Il giorno martedì 7 luglio 2020 23:35:10 UTC+2, Alias R. Cummins ha scritto:
Yeah, if you want a cross platform native library, Qt is a good choice.

Nevertheless, you might be making your life unnecessarily difficult by going this route.
As I understand it, Bluetooth access from the NDK is deliberately limited because of the
potential security problems it could call, also Bluetooh is surprisingly complex under the
hood.

I'd recommend you start with the Qt docs:
Docs here:
https://doc.qt.io/qt-5/qtbluetooth-index.html

On Mon, 6 Jul 2020 at 23:54, [hidden email] <[hidden email]> wrote:
Qt? 

There's a QBluetooth API inside Qt which will give you access to Bluetooth through a C++ interface (the Qt signals and slots is required for that to work though). My organization however just called Java methods through JNI.

On Tuesday, July 7, 2020 at 3:38:59 AM UTC+12 [hidden email] wrote:
Hi everyone,

My company has to develop an API library (.so) in C / C ++ on the Android platform. The library can be incorporated into other Apps also written with different Framework (Xamarin, Flutter, Native Java / Kotlin etc.). The library will use to communicate with our external device in Bluetooth (BLE). I have not found an example to start to set up a C / C ++ project and to be able to access Bluetooth from here.
Do you have any suggestions?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/07809b36-6345-45d1-a348-dbec69aeb28cn%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/833a7338-483a-4aa7-b919-b4dfeb8ce002o%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/78d83f77-0476-491b-a998-50952596e4fbo%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAP5h4q-Qy35E8Amu3_fqu_co4B_de8CfuexxstGRVRpDzsPHyA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Develop in C/C++

Steven Winston
In reply to this post by mac actiaitalia
You can use bluez if you really want to.  But seriously, stop.  Use the Java library.  That handles the permissions in a way that wont make you crazy.

On Monday, July 6, 2020 at 8:38:59 AM UTC-7, mac actiaitalia wrote:
Hi everyone,

My company has to develop an API library (.so) in C / C ++ on the Android platform. The library can be incorporated into other Apps also written with different Framework (Xamarin, Flutter, Native Java / Kotlin etc.). The library will use to communicate with our external device in Bluetooth (BLE). I have not found an example to start to set up a C / C ++ project and to be able to access Bluetooth from here.
Do you have any suggestions?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/e1901715-811a-4260-a719-55a2ea2e9a59o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Develop in C/C++

mac actiaitalia
Yes, I know :-D
It's crazy to use C ++ in android.
However I have to create a wrap in C++ that makes calls in Java, this is a prerogative of my company.


Il giorno martedì 14 luglio 2020 08:44:13 UTC+2, Steven Winston ha scritto:
You can use bluez if you really want to.  But seriously, stop.  Use the Java library.  That handles the permissions in a way that wont make you crazy.

On Monday, July 6, 2020 at 8:38:59 AM UTC-7, mac actiaitalia wrote:
Hi everyone,

My company has to develop an API library (.so) in C / C ++ on the Android platform. The library can be incorporated into other Apps also written with different Framework (Xamarin, Flutter, Native Java / Kotlin etc.). The library will use to communicate with our external device in Bluetooth (BLE). I have not found an example to start to set up a C / C ++ project and to be able to access Bluetooth from here.
Do you have any suggestions?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/b2b49b5c-2e27-4289-8ca8-e774912f5099o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Develop in C/C++

Alias R. Cummins
Actually you don't need Qt, you could do everything with SWIG bindings and a minimal skeleton app.

A

On Tue, 14 Jul 2020 at 13:55, Alias R. Cummins <[hidden email]> wrote:
It's not crazy to use C++ on Android, it's just a bit more difficult.

There's 2 routs you could go:

 - Make your app GUI in Qt and call out to the bluetooth stack via the Qt JNI bindings
- Use bluez and do everything in native

If this is something that needs to do weird and advanced stuff with the Bluetooth stack, bluez might be a good option.

Do you need to also deploy on iOS? Is that why you want to use C++? Is the requirement for cross platform deployment?

A

On Tue, 14 Jul 2020 at 13:18, mac actiaitalia <[hidden email]> wrote:
Yes, I know :-D
It's crazy to use C ++ in android.
However I have to create a wrap in C++ that makes calls in Java, this is a prerogative of my company.


Il giorno martedì 14 luglio 2020 08:44:13 UTC+2, Steven Winston ha scritto:
You can use bluez if you really want to.  But seriously, stop.  Use the Java library.  That handles the permissions in a way that wont make you crazy.

On Monday, July 6, 2020 at 8:38:59 AM UTC-7, mac actiaitalia wrote:
Hi everyone,

My company has to develop an API library (.so) in C / C ++ on the Android platform. The library can be incorporated into other Apps also written with different Framework (Xamarin, Flutter, Native Java / Kotlin etc.). The library will use to communicate with our external device in Bluetooth (BLE). I have not found an example to start to set up a C / C ++ project and to be able to access Bluetooth from here.
Do you have any suggestions?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/b2b49b5c-2e27-4289-8ca8-e774912f5099o%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAP5h4q_1fVPUEVyo9KyS_VaG76AHVA65xmRt-ru%3DtK711nUkGw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Develop in C/C++

Andrew Esh-3
In reply to this post by mac actiaitalia
It's not crazy to use C++ on Android. I do it all the time. At the company I work for, I develop and maintain a large amount of C and C++ code that is dual platform: Linux and Android. If we implemented everything in Java on the Android platform, then we'd have two products to support.

On the Android platform we compile the C/C++ code within the Native Development Kit (NDK). If we need to do something that is best done on the Java side, we call out through the Java Native Interface (JNI) and make use of Java-provided services. We implement some of our functionality in Java so as to provide an API to our C/C++ code for those who want to call it from a Java environment.

Sometimes it is easier to use functionality on the Android platform that is on the Java side. Such functionality is probably the reference implementation provided by Google. The implementation language should not be taken as a mandate that the entire stack of software must be written in the same language. With the NDK, and the JNI, access to any functionality can be obtained, regardless of the implementation language.

A library written in C/C++ can be a full and equal partner to any other part of the application which is written in Java.

On Tuesday, July 14, 2020 at 6:19:02 AM UTC-5 [hidden email] wrote:
Yes, I know :-D
It's crazy to use C ++ in android.
However I have to create a wrap in C++ that makes calls in Java, this is a prerogative of my company.


Il giorno martedì 14 luglio 2020 08:44:13 UTC+2, Steven Winston ha scritto:
You can use bluez if you really want to.  But seriously, stop.  Use the Java library.  That handles the permissions in a way that wont make you crazy.

On Monday, July 6, 2020 at 8:38:59 AM UTC-7, mac actiaitalia wrote:
Hi everyone,

My company has to develop an API library (.so) in C / C ++ on the Android platform. The library can be incorporated into other Apps also written with different Framework (Xamarin, Flutter, Native Java / Kotlin etc.). The library will use to communicate with our external device in Bluetooth (BLE). I have not found an example to start to set up a C / C ++ project and to be able to access Bluetooth from here.
Do you have any suggestions?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/3ca2edb9-ec4a-4df9-8661-fc95fa9f0f69n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Develop in C/C++

mac actiaitalia
Ok. thanks Andrew, very clear!
My problem I don't have much experience in making the two languages interact with JNI. For this I would need examples and tutorials to better understand how to write methods in C / C ++ that can call Android functionality in Java.


Il giorno martedì 14 luglio 2020 14:39:47 UTC+2, Andrew Esh ha scritto:
It's not crazy to use C++ on Android. I do it all the time. At the company I work for, I develop and maintain a large amount of C and C++ code that is dual platform: Linux and Android. If we implemented everything in Java on the Android platform, then we'd have two products to support.

On the Android platform we compile the C/C++ code within the Native Development Kit (NDK). If we need to do something that is best done on the Java side, we call out through the Java Native Interface (JNI) and make use of Java-provided services. We implement some of our functionality in Java so as to provide an API to our C/C++ code for those who want to call it from a Java environment.

Sometimes it is easier to use functionality on the Android platform that is on the Java side. Such functionality is probably the reference implementation provided by Google. The implementation language should not be taken as a mandate that the entire stack of software must be written in the same language. With the NDK, and the JNI, access to any functionality can be obtained, regardless of the implementation language.

A library written in C/C++ can be a full and equal partner to any other part of the application which is written in Java.

On Tuesday, July 14, 2020 at 6:19:02 AM UTC-5 [hidden email] wrote:
Yes, I know :-D
It's crazy to use C ++ in android.
However I have to create a wrap in C++ that makes calls in Java, this is a prerogative of my company.


Il giorno martedì 14 luglio 2020 08:44:13 UTC+2, Steven Winston ha scritto:
You can use bluez if you really want to.  But seriously, stop.  Use the Java library.  That handles the permissions in a way that wont make you crazy.

On Monday, July 6, 2020 at 8:38:59 AM UTC-7, mac actiaitalia wrote:
Hi everyone,

My company has to develop an API library (.so) in C / C ++ on the Android platform. The library can be incorporated into other Apps also written with different Framework (Xamarin, Flutter, Native Java / Kotlin etc.). The library will use to communicate with our external device in Bluetooth (BLE). I have not found an example to start to set up a C / C ++ project and to be able to access Bluetooth from here.
Do you have any suggestions?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/bb0a0a78-637a-4b9c-819d-3db834875df0o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Develop in C/C++

Dime Bar
In reply to this post by Andrew Esh-3
Unfortunately the latest Android 11 privacy file system is mostly in Java. 

Your gonna have to go through hops to get around the privacy settings and even then you might not be able to access data natively which is a shame. 



On Tue, 14 Jul 2020 at 13:39, Andrew Esh <[hidden email]> wrote:
It's not crazy to use C++ on Android. I do it all the time. At the company I work for, I develop and maintain a large amount of C and C++ code that is dual platform: Linux and Android. If we implemented everything in Java on the Android platform, then we'd have two products to support.

On the Android platform we compile the C/C++ code within the Native Development Kit (NDK). If we need to do something that is best done on the Java side, we call out through the Java Native Interface (JNI) and make use of Java-provided services. We implement some of our functionality in Java so as to provide an API to our C/C++ code for those who want to call it from a Java environment.

Sometimes it is easier to use functionality on the Android platform that is on the Java side. Such functionality is probably the reference implementation provided by Google. The implementation language should not be taken as a mandate that the entire stack of software must be written in the same language. With the NDK, and the JNI, access to any functionality can be obtained, regardless of the implementation language.

A library written in C/C++ can be a full and equal partner to any other part of the application which is written in Java.

On Tuesday, July 14, 2020 at 6:19:02 AM UTC-5 [hidden email] wrote:
Yes, I know :-D
It's crazy to use C ++ in android.
However I have to create a wrap in C++ that makes calls in Java, this is a prerogative of my company.


Il giorno martedì 14 luglio 2020 08:44:13 UTC+2, Steven Winston ha scritto:
You can use bluez if you really want to.  But seriously, stop.  Use the Java library.  That handles the permissions in a way that wont make you crazy.

On Monday, July 6, 2020 at 8:38:59 AM UTC-7, mac actiaitalia wrote:
Hi everyone,

My company has to develop an API library (.so) in C / C ++ on the Android platform. The library can be incorporated into other Apps also written with different Framework (Xamarin, Flutter, Native Java / Kotlin etc.). The library will use to communicate with our external device in Bluetooth (BLE). I have not found an example to start to set up a C / C ++ project and to be able to access Bluetooth from here.
Do you have any suggestions?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/3ca2edb9-ec4a-4df9-8661-fc95fa9f0f69n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAHY3sxXR4j1qiR%3D-AWgB4cg4DkKP8%3DG_BNNGXqTaRo2B%2BYoVdQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Develop in C/C++

Andrew Esh-3
In reply to this post by mac actiaitalia
There are many JNI examples among the NDK documentation on the Google Developer site: https://developer.android.com/ndk/samples/sample_hellojni  

Or this:  https://www.codeproject.com/Articles/993067/Calling-Java-from-Cplusplus-with-JNI  

On Tuesday, July 14, 2020 at 10:17:39 AM UTC-5 [hidden email] wrote:
Ok. thanks Andrew, very clear!
My problem I don't have much experience in making the two languages interact with JNI. For this I would need examples and tutorials to better understand how to write methods in C / C ++ that can call Android functionality in Java.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/d0c1ebea-35ae-483e-b74e-61f068407099n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Develop in C/C++

mac actiaitalia
In reply to this post by Dime Bar
Hello everyone,

I have an Android test project in Android Studio with a part in C/C++. The example code is the following:


static JavaVM *_gJVM = nullptr;
static JNIEnv *_gpJNIEnv = nullptr;

extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
{
__android_log_print(ANDROID_LOG_DEBUG, "native-lib", "IN JNI_OnLoad");

_gJVM = vm;

_gJVM->GetEnv(reinterpret_cast<void **>(&_gpJNIEnv), JNI_VERSION_1_6);

__android_log_print(ANDROID_LOG_DEBUG, "native-lib", "OUT JNI_OnLoad");

return JNI_VERSION_1_6;
}

extern "C" JNIEXPORT int NativeTest3Wrap()
{
return Java_com_example_testrp1227_MainActivity_NativeTest3(_gpJNIEnv, nullptr);
}

Firtsly, I don't know if it's right call Java metod in this way:

extern "C" JNIEXPORT jint JNICALL
Java_com_example_testrp1227_MainActivity_NativeTest3(JNIEnv *env, jobject thiz)
{
__android_log_print(ANDROID_LOG_DEBUG, "native-lib", "IN NativeTest3");
jclass testCl;

if(thiz == nullptr)
{
testCl = env->FindClass("com/example/testrp1227/TestJavaCall");
} else
{
testCl = env->GetObjectClass(thiz);
}

__android_log_print(ANDROID_LOG_DEBUG, "native-lib", "NativeTest3 1");

jmethodID methodCall = env->GetStaticMethodID(testCl,"test1", "()I");

__android_log_print(ANDROID_LOG_DEBUG, "native-lib", "OUT NativeTest3");

return env->CallStaticIntMethod(testCl, methodCall);
}

This is Java method to call from C / C ++ that I have in the same project:

package com.example.testrp1227;

public class TestJavaCall
{
public static int test1()
{
return 20;
}
}

Secondly, onceI have compiled the project I get my ".so" library. At this point, I use Xamarin (Visual Studio 2019) to call the C/C++ NativeTest3Wrap method which should call the Java method, but it does not work. I get an exception in Xamarin:
 JNI DETECTED ERROR IN APPLICATION: JNI GetStaticMethodID called with pending exception java.lang.ClassNotFoundException: Didn't find class "com.example.testrp1227.TestJavaCall" on path: DexPathList[[zip file "/data/app/com.ACTIA.Diag4App-RjGvk1bh4b94eSR59z7OxA==/base.apk"],nativeLibraryDirectories=[/data/app/com.ACTIA.Diag4App-RjGvk1bh4b94eSR59z7OxA==/lib/arm64, /data/app/com.A

But, I have inserted only the ".so" file in the Xamarin project, maybe I should also insert the jar file of the Android Studio project?

Thanks


Il giorno martedì 14 luglio 2020 23:34:31 UTC+2, thedimebar ha scritto:
Unfortunately the latest Android 11 privacy file system is mostly in Java. 

Your gonna have to go through hops to get around the privacy settings and even then you might not be able to access data natively which is a shame. 



On Tue, 14 Jul 2020 at 13:39, Andrew Esh <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="iu1zb8WsBwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">andr...@...> wrote:
It's not crazy to use C++ on Android. I do it all the time. At the company I work for, I develop and maintain a large amount of C and C++ code that is dual platform: Linux and Android. If we implemented everything in Java on the Android platform, then we'd have two products to support.

On the Android platform we compile the C/C++ code within the Native Development Kit (NDK). If we need to do something that is best done on the Java side, we call out through the Java Native Interface (JNI) and make use of Java-provided services. We implement some of our functionality in Java so as to provide an API to our C/C++ code for those who want to call it from a Java environment.

Sometimes it is easier to use functionality on the Android platform that is on the Java side. Such functionality is probably the reference implementation provided by Google. The implementation language should not be taken as a mandate that the entire stack of software must be written in the same language. With the NDK, and the JNI, access to any functionality can be obtained, regardless of the implementation language.

A library written in C/C++ can be a full and equal partner to any other part of the application which is written in Java.

On Tuesday, July 14, 2020 at 6:19:02 AM UTC-5 [hidden email] wrote:
Yes, I know :-D
It's crazy to use C ++ in android.
However I have to create a wrap in C++ that makes calls in Java, this is a prerogative of my company.


Il giorno martedì 14 luglio 2020 08:44:13 UTC+2, Steven Winston ha scritto:
You can use bluez if you really want to.  But seriously, stop.  Use the Java library.  That handles the permissions in a way that wont make you crazy.

On Monday, July 6, 2020 at 8:38:59 AM UTC-7, mac actiaitalia wrote:
Hi everyone,

My company has to develop an API library (.so) in C / C ++ on the Android platform. The library can be incorporated into other Apps also written with different Framework (Xamarin, Flutter, Native Java / Kotlin etc.). The library will use to communicate with our external device in Bluetooth (BLE). I have not found an example to start to set up a C / C ++ project and to be able to access Bluetooth from here.
Do you have any suggestions?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="iu1zb8WsBwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">andro...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/android-ndk/3ca2edb9-ec4a-4df9-8661-fc95fa9f0f69n%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/android-ndk/3ca2edb9-ec4a-4df9-8661-fc95fa9f0f69n%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/android-ndk/3ca2edb9-ec4a-4df9-8661-fc95fa9f0f69n%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/android-ndk/3ca2edb9-ec4a-4df9-8661-fc95fa9f0f69n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/207b4f68-76a8-4b00-8e8a-df233317215bo%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Develop in C/C++

Alias R. Cummins
Please explain where you are adding the .so files in the project. 

Normally this would be in main/jni/{your target architecture, e.g. ARM64-8a}

However it's better to use Android Studio backed by gradle aware make because it's supported by Google. 

If you could post both your gradle build files that would help too.

On Mon 20 Jul 2020, 16:35 mac actiaitalia, <[hidden email]> wrote:
Hello everyone,

I have an Android test project in Android Studio with a part in C/C++. The example code is the following:


static JavaVM *_gJVM = nullptr;
static JNIEnv *_gpJNIEnv = nullptr;

extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
{
__android_log_print(ANDROID_LOG_DEBUG, "native-lib", "IN JNI_OnLoad");

_gJVM = vm;

_gJVM->GetEnv(reinterpret_cast<void **>(&_gpJNIEnv), JNI_VERSION_1_6);

__android_log_print(ANDROID_LOG_DEBUG, "native-lib", "OUT JNI_OnLoad");

return JNI_VERSION_1_6;
}

extern "C" JNIEXPORT int NativeTest3Wrap()
{
return Java_com_example_testrp1227_MainActivity_NativeTest3(_gpJNIEnv, nullptr);
}

Firtsly, I don't know if it's right call Java metod in this way:

extern "C" JNIEXPORT jint JNICALL
Java_com_example_testrp1227_MainActivity_NativeTest3(JNIEnv *env, jobject thiz)
{
__android_log_print(ANDROID_LOG_DEBUG, "native-lib", "IN NativeTest3");
jclass testCl;

if(thiz == nullptr)
{
testCl = env->FindClass("com/example/testrp1227/TestJavaCall");
} else
{
testCl = env->GetObjectClass(thiz);
}

__android_log_print(ANDROID_LOG_DEBUG, "native-lib", "NativeTest3 1");

jmethodID methodCall = env->GetStaticMethodID(testCl,"test1", "()I");

__android_log_print(ANDROID_LOG_DEBUG, "native-lib", "OUT NativeTest3");

return env->CallStaticIntMethod(testCl, methodCall);
}

This is Java method to call from C / C ++ that I have in the same project:

package com.example.testrp1227;

public class TestJavaCall
{
public static int test1()
{
return 20;
}
}

Secondly, onceI have compiled the project I get my ".so" library. At this point, I use Xamarin (Visual Studio 2019) to call the C/C++ NativeTest3Wrap method which should call the Java method, but it does not work. I get an exception in Xamarin:
 JNI DETECTED ERROR IN APPLICATION: JNI GetStaticMethodID called with pending exception java.lang.ClassNotFoundException: Didn't find class "com.example.testrp1227.TestJavaCall" on path: DexPathList[[zip file "/data/app/com.ACTIA.Diag4App-RjGvk1bh4b94eSR59z7OxA==/base.apk"],nativeLibraryDirectories=[/data/app/com.ACTIA.Diag4App-RjGvk1bh4b94eSR59z7OxA==/lib/arm64, /data/app/com.A

But, I have inserted only the ".so" file in the Xamarin project, maybe I should also insert the jar file of the Android Studio project?

Thanks


Il giorno martedì 14 luglio 2020 23:34:31 UTC+2, thedimebar ha scritto:
Unfortunately the latest Android 11 privacy file system is mostly in Java. 

Your gonna have to go through hops to get around the privacy settings and even then you might not be able to access data natively which is a shame. 



On Tue, 14 Jul 2020 at 13:39, Andrew Esh <[hidden email]> wrote:
It's not crazy to use C++ on Android. I do it all the time. At the company I work for, I develop and maintain a large amount of C and C++ code that is dual platform: Linux and Android. If we implemented everything in Java on the Android platform, then we'd have two products to support.

On the Android platform we compile the C/C++ code within the Native Development Kit (NDK). If we need to do something that is best done on the Java side, we call out through the Java Native Interface (JNI) and make use of Java-provided services. We implement some of our functionality in Java so as to provide an API to our C/C++ code for those who want to call it from a Java environment.

Sometimes it is easier to use functionality on the Android platform that is on the Java side. Such functionality is probably the reference implementation provided by Google. The implementation language should not be taken as a mandate that the entire stack of software must be written in the same language. With the NDK, and the JNI, access to any functionality can be obtained, regardless of the implementation language.

A library written in C/C++ can be a full and equal partner to any other part of the application which is written in Java.

On Tuesday, July 14, 2020 at 6:19:02 AM UTC-5 [hidden email] wrote:
Yes, I know :-D
It's crazy to use C ++ in android.
However I have to create a wrap in C++ that makes calls in Java, this is a prerogative of my company.


Il giorno martedì 14 luglio 2020 08:44:13 UTC+2, Steven Winston ha scritto:
You can use bluez if you really want to.  But seriously, stop.  Use the Java library.  That handles the permissions in a way that wont make you crazy.

On Monday, July 6, 2020 at 8:38:59 AM UTC-7, mac actiaitalia wrote:
Hi everyone,

My company has to develop an API library (.so) in C / C ++ on the Android platform. The library can be incorporated into other Apps also written with different Framework (Xamarin, Flutter, Native Java / Kotlin etc.). The library will use to communicate with our external device in Bluetooth (BLE). I have not found an example to start to set up a C / C ++ project and to be able to access Bluetooth from here.
Do you have any suggestions?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/3ca2edb9-ec4a-4df9-8661-fc95fa9f0f69n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/207b4f68-76a8-4b00-8e8a-df233317215bo%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/CAP5h4q_f6oSdXYB2YR4Ao%2BfHRX9M3DaUZb9B64MS5Zm%2B17iVNA%40mail.gmail.com.
12