Unity Access Mobile mm payment (Android)

Source: Internet
Author: User
<span id="Label3"></p><p><p><span style="font-size:14px">Mobile does not have access to the mobile mm Payment SDK for unity3d, so ...</span></p></p><p><p><span style="font-size:14px">In this way, you need to go to the official website to download IAP-SDK as a jar package for unity Calls: http://dev.10086.cn/iap/?action=down&areaid=1354082900</span></p></p><p><p><span style="font-size:14px">1. Make it clear that you have to have a plugins/android directory in the assets directory of unity, and you must be in the assets directory, otherwise you will not be able to package the resources to Pak. At this point, you can try to hit an apk package, with a compressed file open directory structure is this:</span></p></p><p><p><span style="font-size:14px"></span></p></p><p><p><span style="font-size:14px">Why is that so? I want to know too! Record a path here, find the Unity installation directory under mac, Right-click the Unity app to display the package content:/<span style="color:rgb(51,51,51); font-family:arial; line-height:20px">contents/</span>Playbackengines/androidplayer;window Find the Unity installation directory: <span style="font-family:arial; line-height:20px">unity\editor\data\</span> <span style="font-family:arial; line-height:20px">Playbackengines</span> <span style="font-family:arial; line-height:20px">\</span> <span style="font-family:arial; line-height:20px">Androidplayer. </span></span></p></p><p><p><span style="font-size:14px"><span style="font-family:arial; line-height:20px">2, then I think you have downloaded the sdk, I think you first thing must first look at it to access the document, then you have to put it inside the demo to test it? well, We've created a demo.apk, and I opened it with betterzip:</span></span></p></p><p><p><span style="font-size:14px"><span style="font-family:arial; line-height:20px"></span></span></p></p><p><p><span style="font-size:14px"><span style="font-family:arial; line-height:20px">Notice the contents of the red box and see what's the difference between the APK (figure A) and the Unity build? yes, the absence of these files is likely to lead to a variety of errors that make you MAD. For example what "failed to find ...", or the official demo apk can run, and its own apk always error case should pay attention to compare the difference between the Two. finally, We look at the mobile mm inside the purchase jar Package:</span></span></p></p><p><p><span style="font-size:14px"><span style="font-family:arial; line-height:20px"><br></span></span></p></p><p><p><span style="font-size:14px"><span style="font-family:arial; line-height:20px">look, like this mobile mm in-purchase Payment SDK puts resources in the <span style="color:rgb(51,51,51); font-family:Arial; text-indent:16px; background-color:rgb(254,254,254)">mmbilling jar package, which makes unity Unrecognizable. So we're going to copy the necessary resources and put them in the plugins/android corresponding directory, the general <span style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:20px; text-indent:16px; background-color:rgb(254,254,254)">Plugins/android contains the following directories:</span> </span></span></span></p></p><p><p> <span style="font-size:14px"><span style="font-family:arial" line-height:20px "><span style=" Color:rgb ( 51,51,51); font-family:arial; text-indent:16px; Background-color:rgb (254,254,254) "><span style=" Color:rgb (51,51,51); font-family:arial; font-size:14px; line-height:20px; text-indent:16px; Background-color:rgb (254,254,254) ">a, Assets resource directory, such as the god Horse icon and other resources; </span> </span> </span> </span> </p></p><p><p> <span style="font-size:14px"><span style="font-family:arial; line-height:20px"><span style="font-family: Arial; text-indent:16px; Background-color:rgb (254,254,254) "><span style=" Color:rgb (51,51,51); font-family:arial; font-size:14px; line-height:20px; text-indent:16px; Background-color:rgb (254,254,254) ">b, bin/libs directory, because not to do Android development, silly points unclear. Said to be used to put a third-party jar package, but finally found whether you put the jar package in the bin directory, the Libs directory, or even directly in the Android root directory can be. Hey.. It's too moral Integrity. </span> <span style="font-family:arial; font-size:14px; line-height:20px; text-indent:16px; Background-color:rgb (254,254,254) "><span style=" color: #ff0000 "> preferably put the jar package in the bin directory, resources (armeabi-v7a, <span style=" font-family:arial; font-size:14px; line-height:20px; text-indent:16px; Background-color:rgb (254,254,254) ">x86 </span>) puts the Libs directory. </span></span></span></span></span></p></p><p><p> <span style="font-size:14px"><span style="font-family:arial" line-height:20px "><span style=" Color:rgb ( 51,51,51); font-family:arial; text-indent:16px; Background-color:rgb (254,254,254) "><span style=" Color:rgb (51,51,51); font-family:arial; font-size:14px; line-height:20px; text-indent:16px; Background-color:rgb (254,254,254) ">c, Res directory, but also to put Resources. God Horse situation? Let assets love Why. A moment of Confusion. But I said demo.apk in the res directly copied to <span style="color:rgb (51,51,51); font-family:arial; font-size:14px; line-height:20px; text-indent:16px; Background-color:rgb (254,254,254) ">plugins/</span> Android directory, Let Unity packaging will be Error. Hey.. </span></span></span></span></p></p><p><p><span style="font-size:14px"><span style="font-family:arial; line-height:20px"><span style="color:rgb(51,51,51); font-family:Arial; text-indent:16px; background-color:rgb(254,254,254)"><span style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:20px; text-indent:16px; background-color:rgb(254,254,254)">d, Androidmanifest.xml This file you have to put <span style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:20px; text-indent:16px; background-color:rgb(254,254,254)">under the Plugins/android. </span></span></span></span></span></p></p><p><p><span style="font-size:14px"><span style="font-family:arial; line-height:20px"><span style="color:rgb(51,51,51); font-family:Arial; text-indent:16px; background-color:rgb(254,254,254)"><span style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:20px; text-indent:16px; background-color:rgb(254,254,254)">well, at least we've integrated the assets Resources. oh, yes, There's The Libs directory. so resources armeabi, x86 and so On. Check it out:</span></span></span></span></p></p><p><p><span style="font-size:14px"><span style="font-family:arial; line-height:20px"><span style="color:rgb(51,51,51); font-family:Arial; text-indent:16px; background-color:rgb(254,254,254)"><span style="color:rgb(51,51,51); font-family:Arial; font-size:14px; line-height:20px; text-indent:16px; background-color:rgb(254,254,254)"></span></span></span></span></p></p><p><p><span style="line-height:20px; color:rgb(51,51,51); font-family:Arial; font-size:14px; text-indent:16px">I here demo.apk unpacked assets all the resources below to add to the Plugins/android/assets directory, Libs The resources are added to the armeabi-v7a and x86 directory, Here directly to the demo Armeabi directory to add to the armeabi-v7a directory is good. of course, I will have all the Third-party jar packages in the Libs directory, such as: mmbilling.3.1.7.jar, and I wrote the Jar package:</span></p></p><p><p><span style="line-height:20px; color:rgb(51,51,51); font-family:Arial; font-size:14px; text-indent:16px"><br></span></p></p><p><p><span style="line-height:20px; color:rgb(51,51,51); font-family:Arial; font-size:14px; text-indent:16px">3, as to how to access, I think you should at least look at the official Android access documents it. Detailed Access Process: http://www.cnblogs.com/alongu3d/p/3627936.html</span></p></p><p><p><span style="font-size:14px">4. A little bit more about unity interacting with ANDROID. honestly, I don't understand. The general practice is to:</span></p></p><p><p><span style="font-size:14px">a, you have to create a new Android project that introduces Unity's class.jar:<span style="font-size:14px">/</span><span style="font-size:14px; color:rgb(51,51,51); font-family:arial; line-height:20px">contents/</span><span style="font-size:14px">playbackengines/androidplayer/relase/bin </span></span></p></p><p><p><span style="font-size:14px"><span style="font-size:14px">B. Inheritance</span></span> <span style="font-family:‘Courier New‘"> <span style="font-size:14px">unityplayeractivity:</span></span></p></p><p><p><span style="font-family:‘Courier New‘"><span style="font-size:14px"></span></span></p></p><pre name="code" class="java"><pre name="code" class="java">Package Com.vgame.plugins;import Android.os.bundle;import Com.iap.cm.iap_cm;import Com.unity3d.player.unityplayeractivity;public class Unityactivity extends unityplayeractivity{@Overrideprotected void OnCreate (Bundle Savedinstancestate) {super.oncreate (savedinstancestate); iap_cm.oninit (this);}}</pre></pre><br>Unity Side:<p><p></p></p><p><p><span style="font-family:‘Courier New‘"><span style="font-size:14px"></span></span></p></p><pre name="code" class="csharp"><pre name="code" class="csharp">Using (androidjavaclass ac = new Androidjavaclass ("com.unity3d.player.UnityPlayer")) {using (androidjavaobject ao = AC. Getstatic<androidjavaobject> ("currentactivity")) {ao. Callstatic ("init", "appid", "appkey", "gameobject object to accept message", "callback method");}}</pre></pre><br>of course, you have to write the Init method in Unityactivity and It's Static.<p><p></p></p><p><p><span style="font-family:Courier New; font-size:14px">however, I do not want to do so, I do not want to inherit unityplayeractivity, so:</span></p></p><p><p><span style="font-family:Courier New; font-size:14px"></span></p></p><pre name="code" class="csharp"><pre name="code" class="csharp">Using (androidjavaclass ac = new Androidjavaclass ("com.iap.mm.IAPController")) {AC. Callstatic ("init", "appid", "appkey", "gameobject object to accept messages", "callback method");}</pre></pre><br>however, It is regrettable that this cannot be called to Init and is not responding at All. What is this for? I don't know. It is estimated that the using of this work to recycle AC to me, ok:<p><p></p></p><p><p><span style="font-family:Courier New; font-size:14px"></span></p></p><pre name="code" class="csharp"><pre name="code" class="csharp">Androidjavaclass ac = new Androidjavaclass ("com.iap.mm.IAPController"); AC. Callstatic ("init", "appid", "appkey", "gameobject object to accept messages", "callback method");</pre></pre><br>It worked! Of course you should not forget to put the Com.iap.mm.IAPController project into a jar package in the Plugins/android/bin directory yo!<p><p></p></p><p><p><span style="font-family:Courier New; font-size:14px">5, to this point, the remaining copyrightdeclaration.xml, mmiap.xml, version or res files to be packaged into the apk?</span></p></p><p><p><span style="font-family:Courier New; font-size:14px">a, Make sure that you have the demo inside the Aseets and Lib files are integrated into Unity's plugins/android file, package Generation apk, Here you package to KeyStore saved to a folder such as: relase what, casually, is to keep the Spare.</span></p></p><p><p><span style="font-family:Courier New; font-size:14px">b, change the apk suffix name to zip, Open with compressed file, I use Betterzip here:</span></p></p><p><p><span style="font-family:Courier New; font-size:14px"><br></span></p></p><p><p><span style="font-family:Courier New; font-size:14px">At this point we can see that the resources in Aseets and Lib have been packaged into the APK.</span></p></p><p><p><span style="font-family:Courier New; font-size:14px">C. Add the missing <span style="font-family:‘Courier New‘; font-size:14px">copyrightdeclaration.xml,</span><span style="font-family:‘Courier New‘; font-size:14px">mmiap.xml, and</span><span style="font-family:‘Courier New‘; font-size:14px">version files:</span></span></p></p><p><p><span style="font-family:Courier New; font-size:14px"><span style="font-family:‘Courier New‘; font-size:14px"><br></span></span></p></p><p><p><span style="font-family:Courier New; font-size:14px">Save and change the extension back to Apk. I think it's impossible to install to the phone, you say? So it is necessary to re-sign the apk, see Here: http://blog.csdn.net/h5q8n2e7/article/details/47837653 if you are window:http://blog.sina.com.cn/s/ Blog_13791f8000102v2ru.html</span></p></p><p><p><span style="font-size:14px">All right!</span></p></p> <p style="font-size:12px;"><p style="font-size:12px;">Copyright Notice: This article for Bo Master original article, without Bo Master permission not Reproduced.</p></p> <p><p>Unity Access Mobile mm payment (Android)</p></p></span>

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.