My custom plugin not loading on android



  • I have written a plugin and I am trying to load it. It works fine when I debug in windows machine. But when I make the final package in android (not checked in windows) it fails to load the plugin. :(

    @void MainFrame::loadPlugin()
    {
    qDebug()<<Q_FUNC_INFO<<"Invoked";
    QDir pluginsDir(qApp->applicationDirPath());
    qDebug()<<Q_FUNC_INFO<<"pluginsDir.dirName"<<pluginsDir.dirName();
    #if defined(Q_OS_WIN)
    if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release") {
    pluginsDir.cdUp();
    pluginsDir.cdUp();
    pluginsDir.cd("plugins");
    }
    #endif
    foreach (QString fileName, pluginsDir.entryList(QDir::Files))
    {
    QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
    QObject *plugin = pluginLoader.instance();
    if (plugin)
    {
    qDebug()<<Q_FUNC_INFO<<"plugin instance is loaded";
    m_pServerInterface = qobject_cast<ServerInterface *>(plugin);
    if (NULL == m_pServerInterface)
    {
    //error screen should be displayed.
    qDebug()<<Q_FUNC_INFO<<"plugin object casted to ServerInterface is Null";
    }
    }
    }

    qDebug()<<Q_FUNC_INFO<<"loadPlugin() Exit";
    

    }@

    can someone help to find the mistake. I doubt in the path as for windows while debugging it works

    QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
    bool pluginLoaded = pluginLoader.isLoaded();

    It gives me false..

    //serverplugin.h
    @#ifndef SERVERPLUGIN_H
    #define SERVERPLUGIN_H

    #include <QObject>
    #include <QtPlugin>
    #include "acepos/aceclient/serverinterface.h"

    #include <QThread>
    #include "server.h"

    class ServerPlugin : public QObject,
    public ServerInterface
    {
    Q_OBJECT
    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.AcePos.ServerInterface/1.1" FILE "serverplugin.json")
    Q_INTERFACES(ServerInterface)
    QThread *m_pServerThread;
    Server *m_pServer;

    public:
    ServerPlugin():m_pServerThread(NULL), m_pServer(NULL){}

    private slots:
    //void handleServiceStartNotify();

    public:
    bool startServerService();
    bool stopServerService();
    };

    #endif
    @

    //serverinterface.h
    @#ifndef SERVERINTERFACE_H
    #define SERVERINTERFACE_H

    #include <QtPlugin>

    typedef void (*callbackFunction)();

    class ServerInterface
    {
    public:
    virtual ~ServerInterface() { }
    virtual bool startServerService() = 0;
    virtual bool stopServerService() = 0;
    };

    #define ServerInterface_iid "org.qt-project.Qt.AcePos.ServerInterface/1.1"

    Q_DECLARE_INTERFACE(ServerInterface, ServerInterface_iid)

    #endif // SERVERINTERFACE_H
    @


Log in to reply
 

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