How to integrate Qt library inside Android native projectHow do save an Android Activity state using save instance state?Why is the Android emulator so slow? How can we speed up the Android emulator?How do I pass data between Activities in Android application?Developing cross platform mobile applicationIntegrating the ZXing library directly into my Android applicationHow do I add a library project to Android Studio?Android Studio: Add jar as library?Dilemma: when to use Fragments vs Activities:Automatically accept all SDK licencesIntegration of Android Native module with existing Xamarin Native Project
How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?
Adding span tags within wp_list_pages list items
What defenses are there against being summoned by the Gate spell?
Schoenfled Residua test shows proportionality hazard assumptions holds but Kaplan-Meier plots intersect
Collect Fourier series terms
Can a Warlock become Neutral Good?
Finding angle with pure Geometry.
Why do I get two different answers for this counting problem?
Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)
can i play a electric guitar through a bass amp?
How did the USSR manage to innovate in an environment characterized by government censorship and high bureaucracy?
Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?
Is a tag line useful on a cover?
Modeling an IP Address
Why Is Death Allowed In the Matrix?
Is it possible to do 50 km distance without any previous training?
Approximately how much travel time was saved by the opening of the Suez Canal in 1869?
What's the output of a record cartridge playing an out-of-speed record
Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?
What is the offset in a seaplane's hull?
How do we improve the relationship with a client software team that performs poorly and is becoming less collaborative?
How can I prevent hyper evolved versions of regular creatures from wiping out their cousins?
Theorems that impeded progress
What does it mean to describe someone as a butt steak?
How to integrate Qt library inside Android native project
How do save an Android Activity state using save instance state?Why is the Android emulator so slow? How can we speed up the Android emulator?How do I pass data between Activities in Android application?Developing cross platform mobile applicationIntegrating the ZXing library directly into my Android applicationHow do I add a library project to Android Studio?Android Studio: Add jar as library?Dilemma: when to use Fragments vs Activities:Automatically accept all SDK licencesIntegration of Android Native module with existing Xamarin Native Project
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am a native Android developer, and a client has asked me to re-use his Qt library project in a native Android app. I am really new to Qt development, I mean, I understand C/C++ but have never dealt with Qt development itself, neither the environment or the deployment methods.
I have been looking into these solutions, but I don't get any closer to being able to create an Android project with a Qt library inside with which I can interact.
Similar solutions:
- http://thebugfreeblog.blogspot.com/2012/05/embedded-cross-platform-development-for.html
- https://developer.android.com/studio/projects/add-native-code#create-sources
My question: How do I export my Qt project to a usable format for my Android project? Any step-by-step guide would be really appreciated.
Thanks!
add a comment |
I am a native Android developer, and a client has asked me to re-use his Qt library project in a native Android app. I am really new to Qt development, I mean, I understand C/C++ but have never dealt with Qt development itself, neither the environment or the deployment methods.
I have been looking into these solutions, but I don't get any closer to being able to create an Android project with a Qt library inside with which I can interact.
Similar solutions:
- http://thebugfreeblog.blogspot.com/2012/05/embedded-cross-platform-development-for.html
- https://developer.android.com/studio/projects/add-native-code#create-sources
My question: How do I export my Qt project to a usable format for my Android project? Any step-by-step guide would be really appreciated.
Thanks!
1
What kind of library is the Qt library? Note that Qt is designed to run its own event loop, and anything interesting pretty much requires that, as well as aQCoreApplicationinstance existing You should start simple, create a Qt library which, for example, just runs a timer and communicates with your app once per second or whatever. That's not many lines of Qt code. Once you get that integrated, then you can try with a more complex library.
– hyde
Mar 22 at 6:09
It's a communication protocol library, it generates frames according to certain parameters and when a received frame is processed it parses the frame and returns a "comprehensible" response/parameters. So, yeah, good point, still need to figure out the setup for the project though. Thanks!
– xaviburruezo
Mar 22 at 12:11
add a comment |
I am a native Android developer, and a client has asked me to re-use his Qt library project in a native Android app. I am really new to Qt development, I mean, I understand C/C++ but have never dealt with Qt development itself, neither the environment or the deployment methods.
I have been looking into these solutions, but I don't get any closer to being able to create an Android project with a Qt library inside with which I can interact.
Similar solutions:
- http://thebugfreeblog.blogspot.com/2012/05/embedded-cross-platform-development-for.html
- https://developer.android.com/studio/projects/add-native-code#create-sources
My question: How do I export my Qt project to a usable format for my Android project? Any step-by-step guide would be really appreciated.
Thanks!
I am a native Android developer, and a client has asked me to re-use his Qt library project in a native Android app. I am really new to Qt development, I mean, I understand C/C++ but have never dealt with Qt development itself, neither the environment or the deployment methods.
I have been looking into these solutions, but I don't get any closer to being able to create an Android project with a Qt library inside with which I can interact.
Similar solutions:
- http://thebugfreeblog.blogspot.com/2012/05/embedded-cross-platform-development-for.html
- https://developer.android.com/studio/projects/add-native-code#create-sources
My question: How do I export my Qt project to a usable format for my Android project? Any step-by-step guide would be really appreciated.
Thanks!
edited Mar 21 at 20:52
eyllanesc
86.5k103564
86.5k103564
asked Mar 21 at 15:32
xaviburruezoxaviburruezo
255
255
1
What kind of library is the Qt library? Note that Qt is designed to run its own event loop, and anything interesting pretty much requires that, as well as aQCoreApplicationinstance existing You should start simple, create a Qt library which, for example, just runs a timer and communicates with your app once per second or whatever. That's not many lines of Qt code. Once you get that integrated, then you can try with a more complex library.
– hyde
Mar 22 at 6:09
It's a communication protocol library, it generates frames according to certain parameters and when a received frame is processed it parses the frame and returns a "comprehensible" response/parameters. So, yeah, good point, still need to figure out the setup for the project though. Thanks!
– xaviburruezo
Mar 22 at 12:11
add a comment |
1
What kind of library is the Qt library? Note that Qt is designed to run its own event loop, and anything interesting pretty much requires that, as well as aQCoreApplicationinstance existing You should start simple, create a Qt library which, for example, just runs a timer and communicates with your app once per second or whatever. That's not many lines of Qt code. Once you get that integrated, then you can try with a more complex library.
– hyde
Mar 22 at 6:09
It's a communication protocol library, it generates frames according to certain parameters and when a received frame is processed it parses the frame and returns a "comprehensible" response/parameters. So, yeah, good point, still need to figure out the setup for the project though. Thanks!
– xaviburruezo
Mar 22 at 12:11
1
1
What kind of library is the Qt library? Note that Qt is designed to run its own event loop, and anything interesting pretty much requires that, as well as a
QCoreApplication instance existing You should start simple, create a Qt library which, for example, just runs a timer and communicates with your app once per second or whatever. That's not many lines of Qt code. Once you get that integrated, then you can try with a more complex library.– hyde
Mar 22 at 6:09
What kind of library is the Qt library? Note that Qt is designed to run its own event loop, and anything interesting pretty much requires that, as well as a
QCoreApplication instance existing You should start simple, create a Qt library which, for example, just runs a timer and communicates with your app once per second or whatever. That's not many lines of Qt code. Once you get that integrated, then you can try with a more complex library.– hyde
Mar 22 at 6:09
It's a communication protocol library, it generates frames according to certain parameters and when a received frame is processed it parses the frame and returns a "comprehensible" response/parameters. So, yeah, good point, still need to figure out the setup for the project though. Thanks!
– xaviburruezo
Mar 22 at 12:11
It's a communication protocol library, it generates frames according to certain parameters and when a received frame is processed it parses the frame and returns a "comprehensible" response/parameters. So, yeah, good point, still need to figure out the setup for the project though. Thanks!
– xaviburruezo
Mar 22 at 12:11
add a comment |
1 Answer
1
active
oldest
votes
Assuming your Qt application is only used for its logic (not the GUI side), what you need it to:
Adding JNI to your Qt library for Android
JNI (Java Native Interface) allows creating an interface to link and use native (C++) code from Java. This is used to wrap your C++ code and provide functions visible and usable directly from your Android application
- Install the version of Qt you want for Android using Qt's online installer (a checkbox when choosing the version of Qt you want)
- Create a JNI interface to allow your application and the library to talk. This is covered in that sample: https://developer.android.com/ndk/samples/sample_hellojni. I would probably recommend creating another C++/JNI library acting as a wrapper for your C++/Qt library. That way you don't contaminate the original library with JNI dependencies.
Integrate your JNI library in your application
Once your have a JNI interface, you have to cross-compile and ship that library with your Android application
- Build your native library from Android Studio (after pointing to your Qt libraries and include dir). Alternatively, you can manually build it from Qt Creator (slightly easier) and import only the resulting
.so. But that will be painful if your Qt library changes - Package the library (
.so), and load it when your application starts. This is also covered in the sample. Once the library is loaded, you will be able to use the JNI functions that you exposed and pass arguments, after some conversion work. Your Android application can also pass a handle to the native library, allowing communication in both ways.
Notes
- Be careful to the licensing of your project. Cross-compiling Qt for Android will likely switch to its GPLv3 or Commercial license, versus LGPLv3 without Android.
- Qt libraries have to be included in your final pacakge. So they either have to be statically linked against your original library, or dynamically linked, and stored in your APK
- You can leverage Qt JNI classes to make the creation of the interface easier, but that is not required: https://doc.qt.io/qt-5/qandroidjniobject.html
- Threading can become difficult, as calls to/from JNI have to run from the main thread
I would recommend starting from a working example if you find one, as that whole setup will definitely take some time. I don't know of a complete tutorial covering that, but feel free to share if you find one!
Wow, thank you, right now it's a lot to process and to try out. Thank you for your answer, it's something I haven't seen documented anywhere for now. I'll let you know if I figure something out!
– xaviburruezo
Mar 22 at 12:14
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55284006%2fhow-to-integrate-qt-library-inside-android-native-project%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Assuming your Qt application is only used for its logic (not the GUI side), what you need it to:
Adding JNI to your Qt library for Android
JNI (Java Native Interface) allows creating an interface to link and use native (C++) code from Java. This is used to wrap your C++ code and provide functions visible and usable directly from your Android application
- Install the version of Qt you want for Android using Qt's online installer (a checkbox when choosing the version of Qt you want)
- Create a JNI interface to allow your application and the library to talk. This is covered in that sample: https://developer.android.com/ndk/samples/sample_hellojni. I would probably recommend creating another C++/JNI library acting as a wrapper for your C++/Qt library. That way you don't contaminate the original library with JNI dependencies.
Integrate your JNI library in your application
Once your have a JNI interface, you have to cross-compile and ship that library with your Android application
- Build your native library from Android Studio (after pointing to your Qt libraries and include dir). Alternatively, you can manually build it from Qt Creator (slightly easier) and import only the resulting
.so. But that will be painful if your Qt library changes - Package the library (
.so), and load it when your application starts. This is also covered in the sample. Once the library is loaded, you will be able to use the JNI functions that you exposed and pass arguments, after some conversion work. Your Android application can also pass a handle to the native library, allowing communication in both ways.
Notes
- Be careful to the licensing of your project. Cross-compiling Qt for Android will likely switch to its GPLv3 or Commercial license, versus LGPLv3 without Android.
- Qt libraries have to be included in your final pacakge. So they either have to be statically linked against your original library, or dynamically linked, and stored in your APK
- You can leverage Qt JNI classes to make the creation of the interface easier, but that is not required: https://doc.qt.io/qt-5/qandroidjniobject.html
- Threading can become difficult, as calls to/from JNI have to run from the main thread
I would recommend starting from a working example if you find one, as that whole setup will definitely take some time. I don't know of a complete tutorial covering that, but feel free to share if you find one!
Wow, thank you, right now it's a lot to process and to try out. Thank you for your answer, it's something I haven't seen documented anywhere for now. I'll let you know if I figure something out!
– xaviburruezo
Mar 22 at 12:14
add a comment |
Assuming your Qt application is only used for its logic (not the GUI side), what you need it to:
Adding JNI to your Qt library for Android
JNI (Java Native Interface) allows creating an interface to link and use native (C++) code from Java. This is used to wrap your C++ code and provide functions visible and usable directly from your Android application
- Install the version of Qt you want for Android using Qt's online installer (a checkbox when choosing the version of Qt you want)
- Create a JNI interface to allow your application and the library to talk. This is covered in that sample: https://developer.android.com/ndk/samples/sample_hellojni. I would probably recommend creating another C++/JNI library acting as a wrapper for your C++/Qt library. That way you don't contaminate the original library with JNI dependencies.
Integrate your JNI library in your application
Once your have a JNI interface, you have to cross-compile and ship that library with your Android application
- Build your native library from Android Studio (after pointing to your Qt libraries and include dir). Alternatively, you can manually build it from Qt Creator (slightly easier) and import only the resulting
.so. But that will be painful if your Qt library changes - Package the library (
.so), and load it when your application starts. This is also covered in the sample. Once the library is loaded, you will be able to use the JNI functions that you exposed and pass arguments, after some conversion work. Your Android application can also pass a handle to the native library, allowing communication in both ways.
Notes
- Be careful to the licensing of your project. Cross-compiling Qt for Android will likely switch to its GPLv3 or Commercial license, versus LGPLv3 without Android.
- Qt libraries have to be included in your final pacakge. So they either have to be statically linked against your original library, or dynamically linked, and stored in your APK
- You can leverage Qt JNI classes to make the creation of the interface easier, but that is not required: https://doc.qt.io/qt-5/qandroidjniobject.html
- Threading can become difficult, as calls to/from JNI have to run from the main thread
I would recommend starting from a working example if you find one, as that whole setup will definitely take some time. I don't know of a complete tutorial covering that, but feel free to share if you find one!
Wow, thank you, right now it's a lot to process and to try out. Thank you for your answer, it's something I haven't seen documented anywhere for now. I'll let you know if I figure something out!
– xaviburruezo
Mar 22 at 12:14
add a comment |
Assuming your Qt application is only used for its logic (not the GUI side), what you need it to:
Adding JNI to your Qt library for Android
JNI (Java Native Interface) allows creating an interface to link and use native (C++) code from Java. This is used to wrap your C++ code and provide functions visible and usable directly from your Android application
- Install the version of Qt you want for Android using Qt's online installer (a checkbox when choosing the version of Qt you want)
- Create a JNI interface to allow your application and the library to talk. This is covered in that sample: https://developer.android.com/ndk/samples/sample_hellojni. I would probably recommend creating another C++/JNI library acting as a wrapper for your C++/Qt library. That way you don't contaminate the original library with JNI dependencies.
Integrate your JNI library in your application
Once your have a JNI interface, you have to cross-compile and ship that library with your Android application
- Build your native library from Android Studio (after pointing to your Qt libraries and include dir). Alternatively, you can manually build it from Qt Creator (slightly easier) and import only the resulting
.so. But that will be painful if your Qt library changes - Package the library (
.so), and load it when your application starts. This is also covered in the sample. Once the library is loaded, you will be able to use the JNI functions that you exposed and pass arguments, after some conversion work. Your Android application can also pass a handle to the native library, allowing communication in both ways.
Notes
- Be careful to the licensing of your project. Cross-compiling Qt for Android will likely switch to its GPLv3 or Commercial license, versus LGPLv3 without Android.
- Qt libraries have to be included in your final pacakge. So they either have to be statically linked against your original library, or dynamically linked, and stored in your APK
- You can leverage Qt JNI classes to make the creation of the interface easier, but that is not required: https://doc.qt.io/qt-5/qandroidjniobject.html
- Threading can become difficult, as calls to/from JNI have to run from the main thread
I would recommend starting from a working example if you find one, as that whole setup will definitely take some time. I don't know of a complete tutorial covering that, but feel free to share if you find one!
Assuming your Qt application is only used for its logic (not the GUI side), what you need it to:
Adding JNI to your Qt library for Android
JNI (Java Native Interface) allows creating an interface to link and use native (C++) code from Java. This is used to wrap your C++ code and provide functions visible and usable directly from your Android application
- Install the version of Qt you want for Android using Qt's online installer (a checkbox when choosing the version of Qt you want)
- Create a JNI interface to allow your application and the library to talk. This is covered in that sample: https://developer.android.com/ndk/samples/sample_hellojni. I would probably recommend creating another C++/JNI library acting as a wrapper for your C++/Qt library. That way you don't contaminate the original library with JNI dependencies.
Integrate your JNI library in your application
Once your have a JNI interface, you have to cross-compile and ship that library with your Android application
- Build your native library from Android Studio (after pointing to your Qt libraries and include dir). Alternatively, you can manually build it from Qt Creator (slightly easier) and import only the resulting
.so. But that will be painful if your Qt library changes - Package the library (
.so), and load it when your application starts. This is also covered in the sample. Once the library is loaded, you will be able to use the JNI functions that you exposed and pass arguments, after some conversion work. Your Android application can also pass a handle to the native library, allowing communication in both ways.
Notes
- Be careful to the licensing of your project. Cross-compiling Qt for Android will likely switch to its GPLv3 or Commercial license, versus LGPLv3 without Android.
- Qt libraries have to be included in your final pacakge. So they either have to be statically linked against your original library, or dynamically linked, and stored in your APK
- You can leverage Qt JNI classes to make the creation of the interface easier, but that is not required: https://doc.qt.io/qt-5/qandroidjniobject.html
- Threading can become difficult, as calls to/from JNI have to run from the main thread
I would recommend starting from a working example if you find one, as that whole setup will definitely take some time. I don't know of a complete tutorial covering that, but feel free to share if you find one!
edited Mar 21 at 23:23
answered Mar 21 at 23:17
Adrien LeravatAdrien Leravat
1,5621023
1,5621023
Wow, thank you, right now it's a lot to process and to try out. Thank you for your answer, it's something I haven't seen documented anywhere for now. I'll let you know if I figure something out!
– xaviburruezo
Mar 22 at 12:14
add a comment |
Wow, thank you, right now it's a lot to process and to try out. Thank you for your answer, it's something I haven't seen documented anywhere for now. I'll let you know if I figure something out!
– xaviburruezo
Mar 22 at 12:14
Wow, thank you, right now it's a lot to process and to try out. Thank you for your answer, it's something I haven't seen documented anywhere for now. I'll let you know if I figure something out!
– xaviburruezo
Mar 22 at 12:14
Wow, thank you, right now it's a lot to process and to try out. Thank you for your answer, it's something I haven't seen documented anywhere for now. I'll let you know if I figure something out!
– xaviburruezo
Mar 22 at 12:14
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55284006%2fhow-to-integrate-qt-library-inside-android-native-project%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
What kind of library is the Qt library? Note that Qt is designed to run its own event loop, and anything interesting pretty much requires that, as well as a
QCoreApplicationinstance existing You should start simple, create a Qt library which, for example, just runs a timer and communicates with your app once per second or whatever. That's not many lines of Qt code. Once you get that integrated, then you can try with a more complex library.– hyde
Mar 22 at 6:09
It's a communication protocol library, it generates frames according to certain parameters and when a received frame is processed it parses the frame and returns a "comprehensible" response/parameters. So, yeah, good point, still need to figure out the setup for the project though. Thanks!
– xaviburruezo
Mar 22 at 12:11