Sdkbox share : image not found for android

Hi,

I installed sdkbox share plugin. Its working successfully on ios, but on android i am getting

error:java.io.FileNotFoundException: image:1.png

my images are in res folder

Here is my code -

   sdkbox::SocialShareInfo info;
    info.text = "test";
    info.title = "tt";
    info.image = "1.png";
    info.link = "http://www.tt.com";
    info.platform = sdkbox::SocialPlatform::Platform_Select;
    info.showDialog = true;
    sdkbox::PluginShare::share(info);

i also added - FileUtils::getInstance()->addSearchPath("res"); in appdelegate

This is my - build-cfg.json

{
    "ndk_module_path" :[
        "../cocos2d",
        "../cocos2d/cocos",
        "../cocos2d/external"
    ],
    "copy_resources": [
        {
            "from": "../Resources",
            "to": ""
        }
    ]
}

i also tried - info.image = “res/1.png”;
i also tried - info.image = “assets/res/1.png”;
but still it don’t work…

What should be done to load image from res folder in android?

do u mean in the assets pkg ?

Normally i have all images in Resources/res folder…

But in android it copies to assets/res…So how to give the path so it finds the image 1.png

“Here it says we can’t load from assets folder…
we need to put it in memory of android to share this image”

Can’t we do this - info.image = “assets/res/1.png”;

If not how to link to the image in project?

anybody? how to give path to image for android?

If you’re sharing the link, facebook will automatically fetch the image from the link and show it as the post

You can use this tool to preview the shared post
https://developers.facebook.com/tools/debug/sharing/

For the image not found problem
@htlxyz Can you help? I think you had this problem before

please copy the image to sdcard.

copy sample code maybe like follow:

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    std::string oldpath = "asset/source/path/to/image";
    std::string newpath = "sdcard/dest/path/to/image";
    if (FileUtils::getInstance()->writeDataToFile(FileUtils::getInstance()->getDataFromFile(oldpath), newpath)) {
        info.image = newpath;
    }
#endif
1 Like

It doesn’t seem to work for me. Shouldn’t the sdkbox plugin handle all of this internally? If it doesn’t work out of the box then what’s the use for the plugin, might as well write JNI.

share sdk can share a image with a path. and the share sdk just can read file location at sd card.