mihir77
November 5, 2017, 6:14am
#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?
do u mean in the assets pkg ?
mihir77
November 6, 2017, 4:32am
#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
I used cocos2d-js 3.8.1. My code uses to share an image below:
var btnShareLink = new cc.MenuItemFont(“Share Photo”, function(){
cc.log(’===== share photo ====’);
var info = new Object();
info.type = “photo”;
info.title = “My Photo”;
info.image = “res/twitter2.png”;
sdkbox.PluginFacebook.dialog(info);
}, this);
Everytimes i run this code, i got error
BitmapFactory(32315): Unable to decode stream: java.io.FileNotFoundException: res/twitter2.png: open failed: ENOENT (No such file or …
“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?
mihir77
November 7, 2017, 1:50pm
#4
anybody? how to give path to image for android?
nite
November 7, 2017, 9:36pm
#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
htlxyz
November 8, 2017, 3:50am
#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
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.
htlxyz
February 26, 2019, 11:03am
#8
share sdk can share a image with a path. and the share sdk just can read file location at sd card.