Original address: http://blog.csdn.net/u012085988/article/details/17531005
Download resources: http://download.csdn.net/detail/u012085988/6770625
(recently csdn seems to have a problem, hyperlinks can not be used, blog after the release of the discovery was truncated, what is the situation)
Click Download Resources. This includes the files required by unity to introduce mobile MMSDK, and a compiled Android test program. If you don't want to write code, you don't want to build eclipse to download the resource bundle, skip the Eclipse section and create a new unity project directly. The resource bundle also provides a Readme file that describes the purpose of each file.
Essential Foundation:
Blog 1 "Unity calls Android function" http://blog.csdn.net/u012085988/article/details/17414293
Blog 2 "Unity3d access mobile mm Payment SDK Problem" http://blog.csdn.net/lihandsome/article/details/11919113
Basic steps
1. Create a new Android project with Eclipse.
2. Introduce the mobile mm Payment SDK, write the purchase item code, make sure the project can be compiled and pass the purchase test by moving mm in E.
3, Introduce Unity development package (Classes.jar), modify the code, make the Code compatible with unity, recompile the project.
4. Package The COM directory under bin/classes in the project directory into a jar file
5. Copy some of the files used in Eclipse Engineering to unity.
6. Write Call and callback script
7, compile the project, and use Androidmutiltools to re-sign the application
8. Real Machine test Run
Each step is described in detail below:
1, the new project. It's not going to be Google yourself. It is worth noting that the new project will let you enter the package name, which will match the bundle ID in the Unity project.
2. Introduction of mobile mm Payment SDK. can refer to the MM Official online reference manual v2.3. MMSDK can be downloaded in http://dev.10086.cn/wiki/, or you can download the above resource pack directly, I will pack the MM SDK in it. Children's shoes that have not been used to move mm are best to understand the API of the SDK from the official website first. Not introduced here.
3. Classes.jar in the Unity installation directory (path =editor\data\playbackengines\androidplayer\bin\ Classes.jar) This file is also available in my resource pack, and children's shoes that don't want to find a path can steal a little lazy. Classes.jar, like other third-party jars, is placed in the Eclipse Project's Libs directory and added to the compilation path. (Does not add the compilation path of the children's shoes themselves Google, here do not understand the child paper can first look at this blog: http://blog.csdn.net/u012085988/article/details/17414293. Modify the code so that it can invoke the Unity code (this step doesn't look at the blog post). Mainactivity.java and Ydmm.java (the purchase Class) are also packaged into a resource bundle, and in order to save space, the code is not posted here.
4, packaging jar. command is a jar CVF ***.jar com related introduction see http://blog.csdn.net/u012085988/article/details/17414293 step Sixth
5. Follow the http://blog.csdn.net/u012085988/article/details/17414293 7th step to copy the relevant resources to unity. You can also use the method in the resource bundle to directly copy the directory in the resource bundle.
6, call the script in the resource bundle "Mm.cs", directly drag it to the gameobject. After configuring the relevant parameters, call the Mmhandle function to trade. The relevant configuration information and callback functions are shown in the resource bundle Readme.txt and Api.txt.
7, compile the project to generate APK files. At this point, if the installation runs directly, the program will definitely crash. Because mm is missing a configuration file. These three files are in the resource bundle in the "moving mm three files that require special processing" in the directory. Follow the methods in http://blog.csdn.net/lihandsome/article/details/11919113 to add three files to the APK.
8, now you can run the real machine. View log information can be used in the ADB (Android SDK). Command line:./adb logcat.