Unity3d and Android Communication

Source: Internet
Author: User

Unity3d and Android Communication, search some articles from the Internet, found my always unsuccessful! Then the debug pass, and now

Sum up!

There are several places to note:

1. Whether it is Win7 64-bit or 32-bit, can! But all you have to do is install the 32-bit Java Sdk1.6,eclipse 32,adt 32-bit!

2. New Android project, must select Target SDK for Android 4.0 SDK above, if select

Android 4.0 SDK below, import into unity when packaging will prompt some XML file errors!

SDK Selection diagram

If you do not select SDK 4.0, you will be prompted for errors when you package your project in unity!

3. Add a Classes.jar file for Unity3d, located in C:\Program files (x86) \unity\editor\data\playbackengines\androidplayer\bin\ classes.jar!

3.1 How to add this jar

Right-click on the item and click Properties to find the jar file and add it!

4. First a class inherits the Unityplayeractivity,android program when it starts, it instantiates the class!

5. Then add some Android native methods to this class!

6. Export the jar file

6.1 Right-click Android Project, export Jar file, the default selection can be exported jar file, the name of the custom!

7. Define the Androidmainfest.xml file, all the custom classes need to be registered inside!

8. Then in unity, create a new plugins folder and create an Android folder under the Plugins folder.

Create the Bin folder under the Android folder

8.1 Put the Androidmainfest.xml file in the Android directory

8.2 Put the jar file that you just packaged in the bin directory!

8.3 Put the Res folder in the Android directory!

9. Export Android Program

In the player setting settings, set the bundle identifier as the Android package name

This is finished, there are questions please leave a message, discuss together!

              

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.