Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. My custom plugin not loading on android
Forum Updated to NodeBB v4.3 + New Features

My custom plugin not loading on android

Scheduled Pinned Locked Moved Mobile and Embedded
1 Posts 1 Posters 545 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Abin
    wrote on last edited by
    #1

    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
    @

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved