After a few days of research, coupled with the guidance of the Great God, finally cocos connected to the multi-League advertising SDK success.
To connect to a third-party SDK, learn some of the usage of Eclipse, understand some Java code, and some xml,c++ call Java layer code is implemented by JNI. There is an article worth seeing: http://blog.csdn.net/ku726999/article/details/38553889 Click to open the link
1, build an empty HelloWorld project, in the D:\cocos2d-x-3.1.1\tools\cocos2d-console directory, open the Command window, enter:
Cocos New Nb-p com.test.nb-l cpp-d d:cocos2dx_original\cocos2dx_projects.
2, register the multi-union account, add the application, we will have a Publisher ID, create ad bit, will get ad bit ID.
3. Import Cocos Project in Eclipse, import step: 1) Right-"Import-" android-"existing Android code into workspace click Next to import your proj.android
Click Finish, and then import the Cocos Dependent Library, which is still imported as above, and the import path is your project D:\cocos2dx_projects\Pig\cocos2d\cocos\platform\android\java
Click OK.
4, click on the project-"clean, and then right-click"-"Operation Mode-" Android application
5, you will see your own project under a Libs folder, you download from the multi-League online Domob_android_sdk.jar added to your libs directory.
6. In Eclipse, right-click "Properties-" Java Build path-"library-" add the jar.
7. Add the following code to the Androidmanifest.xml:
<!--network access--<uses-permission android:name= "Android.permission.INTERNET" /> <!--Gets the status of the network information, such as whether the current network connection is valid-<uses-permission android:name= "Android.permission.ACCESS_NETWORK_STAT E "/> <!--read phone status--<uses-permission android:name=" Android.permission.READ_PHONE_STATE "/> <! --Allows programs to write to external storage, such as SD card write file--<uses-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/> < ;! --Get the wrong position--<uses-permission android:name= "Android.permission.ACCESS_COARSE_LOCATION"/> <!--get WiFi status --<uses-permission android:name= "Android.permission.ACCESS_WIFI_STATE"/> <!--The following permissions are optional, mainly brand advertising will be used, such as If you do not add, branded ads that require these effects will not be delivered to your app-<!--vibrate right--<uses-permission android:name= "Android.permission.VIBRAT E "/>
<activity android:name= "cn.domob.android.ads.DmActivity" android:theme= "@android: style/ Theme.translucent "> </activity>
The code location is as follows:
<?xml version= "1.0" encoding= "Utf-8"? ><manifest xmlns:android= "http://schemas.android.com/apk/res/ Android "package=" Com.test.Pig "android:versioncode=" 1 "android:versionname=" 1.0 "> <uses-sdk Andro id:minsdkversion= "9"/> <uses-feature android:glesversion= "0x00020000"/> <!--network access--<uses- Permission Android:name= "Android.permission.INTERNET"/> <!--get the status of network information, such as whether the current network connection is valid--<uses-permission Android:name= "Android.permission.ACCESS_NETWORK_STATE"/> <!--reading phone status--<uses-permission android:name = "Android.permission.READ_PHONE_STATE"/> <!--allows programs to write to external storage such as SD card write file--<uses-permission android:name= "an Droid.permission.WRITE_EXTERNAL_STORAGE "/> <!--get the wrong location-<uses-permission android:name=" Android.permi Ssion. Access_coarse_location "/> <!--get WiFi status-<uses-permission android:name=" Android.permission.ACCESS_WI Fi_state "/> <!--The following permissions are availableSelect permissions, mainly brand advertising will be used, if you do not add, the need for these effects of brand ads will not be put into your app--<!--vibration permissions--<uses-permission android:name= "ANDROID.P Ermission. Vibrate "/> <application android:label=" @string/app_name "android:icon=" @drawable/icon "> <!--tell cocos2dxactivity the name, so--and <meta-data android:name= "Android.app.lib_name" Android:value= "Cocos2dcpp"/> <activity android:name= "org.cocos2dx.cpp.AppActivity" Android:label= "@string/app_name" android:screenorientation= "Landscape" android:theme = "@android: Style/theme.notitlebar.fullscreen" android:configchanges= "orientation" > <inte nt-filter> <action android:name= "Android.intent.action.MAIN"/> <category androi D:name= "Android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity Android:name= "cn.domob.android.ads.DmActivity" Android:theme= "@android: Style/theme.translucent" > </activity> </application> <supports-screens android:anydensity= "true" Android:smallscreens= "true" android:normalscreens= "true" ANDROID:LARGESCR Eens= "true" android:xlargescreens= "true"/> <uses-permission android:name= "android.permission . INTERNET "/></manifest>
This will allow you to add ads. The great God is passing, ye is just a rookie, next introduction in the VS Plus code, call Java
Of course, the premise is that your java,eclipse environment should be well served.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
cocos2dx-3.1 access to multi-League advertising Sdk+android (1)