How to integrate shareSDK for the cocos2dx Project

Source: Internet
Author: User

Colin-Liao is an original individual. You are welcome to repost the article.Address. Colin-LiaoThe column address http://blog.csdn.net/focusdeveloper

1. http://wiki.sharesdk.cn/cocos2d-x Guide

2. http://wiki.sharesdk.cn/android_quick integration Guide

3. http://wiki.sharesdk.cn/ios Guide

Then download the so-called cocos2dx-appropriate demo (the one in the Document). Let's talk about it first. This demo is really rough, and the documents on the official website are not very careful, the first integration is really necessary. However, this SDK is good to use.

Integrate the android project first. Download the android integrated sdk in document 2 and import the MainLibs and OnekeyShare projects to the project according to the Guide in document 2. After completion, it should be as described in document 1.

(1) quick sharing of java source code (2) If you integrate or are easy to use, you should have a package of wxapi or yxapi (3) you should have added Share SDK and OnekeyShare images and text resources to your resource folder (4) the jar package of Share SDK should be available in the libs directory of your project. (5) assets Directory, in addition to cocos2d-x resources, there is a ShareSDK. xml file

Copy the shareSDK. xml file to the shareSDK of android and add it to the assets Directory of your project. This xml is used to configure which platforms need to be integrated. xml has a parameter for each platform. If integration is required, the parameter is true. If integration is not performed, the parameter is false.

Configure the xml file AndroidManifest. xml, as described in document 2.

Then go to the pro in the demo of cocos2dx in document 1. copy cn from the android folder. sharesdk. shareSDKUtils. java, this file (keep the name of the first two levels of folders) to the src directory of your project. Add ShareSDKUtils. prepare () to the oncreate function of the cocos2dxactivity. java class of the project ()

The document is finished here, and the project crashes when it runs here. The error "sharesdk has not been initialized" is reported. Here we should change the prepare () function to the ShareSDKUtils. java class.

public static void prepare() {UIHandler.prepare();if (context == null) {context = Cocos2dxActivity.getContext().getApplicationContext();ShareSDK.initSDK(context);}}
After integrating the android sharesdk, add the iOS and android public parts to document 1. In this way, the shareSDK for android is integrated.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.