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!