Solved Problem with Subdirs
-
Hi everyone!.
I'm building an two app for Android using qml (client and admin). I decided to use a Subdir project to create the two application because they share a good portion of code, but when I try run the client app it crash and noticed that it compile with the admin app as a lib.a. How can I compile both app avoiding QtCreator include one in the other as a library?
This is my project file:TEMPLATE = subdirs SUBDIRS = client admin model utils rest client.depends = model utils rest admin.depends = model utils rest model.depends = utils utils.depends = rest
-
Hi @Antonio-Ortiz,
you will need to show us the
client.pro
andadmin.pro
files also.What you want to do is perfectly possible, and I've done it several times, so there must be a small problem in your project.
Regards
-
@aha_1980 Thanks for your quick reply. This are the files
The client.pro
TARGET = Shoppu QT += quick svg qml quickcontrols2 webview mqtt CONFIG += c++11 android:{ QT += androidextras } # The following define makes your compiler emit warnings if you use # any feature of Qt which as been marked deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ main.cpp \ source/androidgallery.cpp RESOURCES += \ qml.qrc \ translation.qrc # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH = # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target DISTFILES += \ android/AndroidManifest.xml \ android/gradle/wrapper/gradle-wrapper.jar \ android/gradlew \ android/res/drawable/logo.png \ android/res/drawable/splash.xml \ android/res/values/apptheme.xml \ android/res/values/libs.xml \ android/build.gradle \ android/gradle/wrapper/gradle-wrapper.properties \ android/gradlew.bat ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android INCLUDEPATH += $$PWD/../rest \ $$PWD/../utils \ $$PWD/../model \ DEPENDPATH += $$PWD/../rest \ $$PWD/../utils \ $$PWD/../model unix:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../rest -lrest else: unix:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../rest -lrest unix:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../utils -lutils else: unix:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../utils -lutils unix:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../model -lmodel else: unix:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../model -lmodel LANGUAGES = es_us es_VE lupdate_only{ SOURCES = strings/*.js \ views/*.qml \ controllers/*qml } # used to create .ts files defineReplace(prependAll) { for(a,$$1):result += $$2$${a}$$3 return($$result) } # Available translations tsroot = $$join(TARGET,,,.ts) tstarget = $$join(TARGET,,,_) TRANSLATIONS = $$PWD/translations/$$tsroot TRANSLATIONS += $$prependAll(LANGUAGES, $$PWD/translations/$$tstarget, .ts) # run LRELEASE to generate the qm files qtPrepareTool(LRELEASE, lrelease) for(tsfile, TRANSLATIONS) { command = $$LRELEASE $$tsfile system($$command)|error("Failed to run: $$command") } HEADERS += \ source/androidgallery.h
And this is the admin.pro
TARGET = ShoppuAdmin QT += quick svg mqtt android:{ QT += androidextras } CONFIG += c++11 # The following define makes your compiler emit warnings if you use # any feature of Qt which as been marked deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ main.cpp \ source/androidgallery.cpp \ source/notificationclient.cpp HEADERS += \ source/androidgallery.h \ source/notificationclient.h RESOURCES += \ qml.qrc \ translation.qrc INCLUDEPATH += $$PWD/../rest \ $$PWD/../utils \ $$PWD/../model \ DEPENDPATH += $$PWD/../rest \ $$PWD/../utils \ $$PWD/../model unix:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../rest -lrest else: unix:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../rest -lrest unix:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../utils -lutils else: unix:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../utils -lutils unix:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../model -lmodel else: unix:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../model -lmodel # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH = # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target DISTFILES += \ android/AndroidManifest.xml \ android/gradle/wrapper/gradle-wrapper.jar \ android/gradlew \ android/res/values/libs.xml \ android/build.gradle \ android/gradle/wrapper/gradle-wrapper.properties \ android/gradlew.bat \ android/src/ve/com/disinglab/shoppuAdmin/MyBraodcastReceiver.java \ android/src/ve/com/disinglab/shoppuAdmin/ \ android/src/ve/com/disinglab/shoppuAdmin/NotificationClient.java ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android LANGUAGES = es_us es_VE lupdate_only{ SOURCES = strings/*.qml \ components/*qml \ controllers/*qml \ } # used to create .ts files defineReplace(prependAll) { for(a,$$1):result += $$2$${a}$$3 return($$result) } # Available translations tsroot = $$join(TARGET,,,.ts) tstarget = $$join(TARGET,,,_) TRANSLATIONS = $$PWD/translations/$$tsroot TRANSLATIONS += $$prependAll(LANGUAGES, $$PWD/translations/$$tstarget, .ts) # run LRELEASE to generate the qm files qtPrepareTool(LRELEASE, lrelease) for(tsfile, TRANSLATIONS) { command = $$LRELEASE $$tsfile system($$command)|error("Failed to run: $$command") }
-
Hi @Antonio-Ortiz,
what happens if you add
TEMPLATE = app
to both project files and do a full rebuild?Regards
-
@aha_1980 said in Problem with Subdirs:
rebuild
Still the same error when I try to compile client.
~/build-shoppu-Android_for_armeabi_v7a_Clang_Qt_5_13_2_android_armv7-Debug/android-build/src/ve/com/disinglab/shoppuAdmin/NotificationClient.java:23: error: package R does not exist m_builder.setSmallIcon(R.drawable.logo);
As you can see it is trying to use a file from the admin app
-
I'm a bit out here, as I don't use Android; but still it sounds strange that it tries to compile a file that is not in the project?!
Have you cleared all build artifacts and Makefiles (or whatever is used to build for Android)?
Otherwise I'm currently out of ideas. I can just recommend you to carefully read the build log and see if you find something strange.
Regards
-
@aha_1980 said in Problem with Subdirs:
still it sounds strange th
I notice the same behavior on the desktop build.
Thanks, I will check the logs -
All ready found the error. I was calling a file from the admin folder in my client.pro