Building SMTP client for Qt for Android target



  • I am using the SMTP Client project to create a library file (.dll) on Windows. Everything works fine and e-mails are sent successfully.

    I want to port my Qt project to Android and since Android is a different architecture I need to build the library using a Android armv7 toolkit.

    I try this, but I get error:

    <Internal Error: Unknown Android deployment JSON file location. Error while building/deploying project SMTPEmail (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.4.2)) When executing step "Build Android APK">

    I suspect there is something I have to add/remove from the project file. I see there is a "win32:CONFIG += dll", but nothing similar for other platforms.

    The .pro files looks like this:

    #-------------------------------------------------
    #
    # Project created by QtCreator 2011-08-11T20:59:25
    #
    #-------------------------------------------------
    
    QT       += core network
    
    TARGET = SMTPEmail
    
    # Build as an application
    #TEMPLATE = app
    
    # Build as a library
    TEMPLATE = lib
    DEFINES += SMTP_BUILD
    win32:CONFIG += dll
    
    QMAKE_CXXFLAGS += -fPIC
    
    SOURCES += \
    src/emailaddress.cpp \
    src/mimeattachment.cpp \
    src/mimefile.cpp \
    src/mimehtml.cpp \
    src/mimeinlinefile.cpp \
    src/mimemessage.cpp \
    src/mimepart.cpp \
    src/mimetext.cpp \
    src/smtpclient.cpp \
    src/quotedprintable.cpp \
    src/mimemultipart.cpp \
    src/mimecontentformatter.cpp \
    
    HEADERS  += \
    src/emailaddress.h \
    src/mimeattachment.h \
    src/mimefile.h \
    src/mimehtml.h \
    src/mimeinlinefile.h \
    src/mimemessage.h \
    src/mimepart.h \
    src/mimetext.h \
    src/smtpclient.h \
    src/SmtpMime \
    src/quotedprintable.h \
    src/mimemultipart.h \
    src/mimecontentformatter.h \
    src/smtpexports.h
    
    OTHER_FILES += \
    LICENSE \
    README.md
    
    FORMS +=


  • @Phataas It looks like you need the SMTP Client as a shared library compiled for the Android target architecture (it seems armv7 per your post). So step 1 is to build the SMTP Client as library for armv7. You're very likely need a cross-compile environment under Linux and installing the Android NDK, Once you have the resulting .so library, you need to put it in folder android/libs/armeabi-v7a under your project root folder, so the library file is deployed to the Android device along all other files.

    I've been using an external library with my Android app without any issues, given creating the .so file was straitghforward. See project PixelKnot about how they use the external library F5Android

    Good luck!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.