about how to simulate debugging Android's U3d app on Visual Studio

Source: Internet
Author: User
Tags oracle vm virtualbox vm virtualbox

Just recently need to develop an Android phone on the Unity3d game features, thinking that since the development, of course, need to debug. Original words some basic functions are not required to use the simulation simulator, directly in the U3d development editor can be debugged, but some android can be executed, such as

Androidjavaclass JC = new Androidjavaclass ("");

If this code is debugged directly on the U3d development editor, it will return directly to the

Therefore, we need to debug on the physical machine (Android phone) or simulator to perform normally.

The following are all the results of my computer, and it does not mean that other computers have the same effect

I choose to debug on the simulator, because the use of physical machines, it is said that only use WiFi, although the USB debugging can also, but check the information, found a lot of problems, and WiFi words speed is much slower.

In the simulator selection, I first selected, Android Virtual Device (hereinafter referred to as AVD), after a variety of configurations, the AVD simulation of the Android U3D application does run correctly, but the AVD assigned to the Android Simulator network is a NAT network, that is, The IP that runs inside the Android simulator is the re-assigned virtual IP, And if we use 127.0.0.1来 attach is not able to access the emulator internal port, then there is only one way, using the redir instruction to redirect, the simulator assigned to the Android app Port reassigned to the PC access, of course, this method itself is not a problem, but the problem is

This port, every time you start a new debugging, will change, that is, every time you want to debug, you have to re-redir a new port before the line, this is the egg hurt AH

To solve this problem, we can only change the NAT network to bridge network, but I find all the AVD can not find the network connection mode to change the setting of the bridge, so forget, can only give up the AVD

Later, I turned to Visual Studio Emulator for Android, which is the VS comes with the Android emulator, based on the Hyper-V virtual machine run, in the virtual machine's network Media settings interface, you can change the network to bridge mode, very nice, Unfortunately, when I put my side of the project into the emulator run, no matter what to do, the simulator will crash, so this method at least on my computer can only be dropped, perhaps your project can use this method.

Then I turned to the domestic Android simulator, such as the Night God Ah, thunder and so on, unfortunately, these Android simulator bridge mode, do not support the WIN10 system, as for me to change the system? does not exist.

After that, using the supposedly best Android simulator geometry, really good, but also do support to modify the network connection mode for bridging, but do not know why, or the same as above, can not run my side of the project, this is not a crash, but the application open is all blank ... No way, only to forget, but this method in your project should also be able to use.

Finally, the use of VirtualBox to finally solve the problem, the following is the topic of this article, about how to simulate debugging Android u3d application in Visual Studio.

Before you start, you need to do some preparatory functions

1. Download Android x86 system files, can be install package, can also go (https://www.osboxes.org/android-x86) to download the finished virtual machine hard disk of others, recommend the latter, can be less toss, but the download package provided here need to drag down from Google hard drive , so, yes.

2. Download the virtual machine, this has nothing to say, I am using the Oracle VM VirtualBox, Baidu under the casual

3. Install the SDK package for Android, I use the VS installer provided, or you can use it.

4. If you are using VS, you need to install the Unity3d extension file on vs.

After the main function is done, we will first open the virtual machine configuration

In fact, there is nothing to say, set the system to the LIUNX project, the hard drive points to the downloaded VDI file

Then right-click on the project-Properties, on the Network tab, change the connection mode to bridge the NIC, then start the virtual machine on the line

After the normal startup project, follow the general Android operating mode, note the IP, and then open the command line controller

In the directory where Adb.exe is located, type

ADB Connect IP

If the connected to IP is present, the connection to the local machine and emulator is successful, and now CMD is available.

Next, leave the virtual machine on one side (if you can, set it up so that the Android system never sleeps, or it will not operate after a while, sleep mode can not wake up, only restart)

Open the Unity3d Editor, set the configuration under

The above box red, all need to be set, the editor I use VS, of course you can also use MonoDevelop, edit additional needs hook, SDK and JDK need to manually specify the location, set up can be closed

In the Build Settings screen, double-click Android, then put the red box on the hook, and finally click Build and Run

There will be an address selection box that lets you save the apk file, so make sure that the path to the APK file is not in Chinese and the Chinese text will cause the APK to fail to install on the installation emulator.

If the above work is not done wrong, after clicking Save, you will enter the long connected Android device, build the application, and send the app package to the Android emulator and install the operation automatically.

If all goes well, you'll find that the Android simulator has already run the app, waiting for you to operate,

Now let's start with VS

Whatever command is at the top and bottom of the breakpoint (cannot be broken when debugging without a breakpoint)

If vs installs the u3d extension component, there should be this option

Then you will find that the emulator inside runs the application, as well as shown here, do not want to, double click on the Open is

If this is not a problem, you will find that vs goes directly into debug mode

If it appears

This non-debug mode, is the connection is not successful

And then we're going to do some of the things we want to debug on the app.

See that vs has broken down normally, and in the automatic window, the current instruction variables are displayed, this way debugging is much more convenient.

about how to simulate debugging Android's U3d app on Visual Studio

Related Article

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.