Sdkbox share : image not found for android

Sdkbox share : image not found for android
0.0 0

#1

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?


#2

do u mean in the assets pkg ?


#3

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?


#4

anybody? how to give path to image for android?


#5

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


#6

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