Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

unity3d - How to create and read Log on Android devices?

I just tried my app on Android and it suddenly doesn't work well (on Windows it works fine). Is there a way to see unity console's errors and Debug.Log messages- when I run the device on Android?(I use development mode and script Debugging).

I connected adb to the device, and can also use logcat and filter to "unity", but it still shows a crazy log.

All I want to see is a clean log that shows errors and my Debug.Log messages which I usually can see easy and clear on the Unity Console on Unity on Windows.

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

View Logs on Android:

To see Debug.Log messages, download Android Studio. Go to the Android Monitor Tab in the Android Studio then select your device from there.

See the image below:

enter image description here


If you have problems of the logs from the device not showing, restart adb.exe. from the command-line.

Stop it:

adb kill-server

Then start it again:

adb start-server

All I want to see is a clean log that shows errors and my Debug.Log messages which I usually can see easy and clear on the Unity Console on Unity on Windows.

1.First filter it with the Unity tag.

enter image description here

2.Disable Development mode from Unity Build Settings. With that on, you will receive extra logs you don't even need.

View Logs on Android without Android Studio:

You can view log from without Android Studio by using the Log Viewer plugin which is free. It will let you see the log on the device itself.

enter image description here


Print Logs from Android Java Plugin:

If you are trying to create log from Java plugin, instead of using the Debug.Log function, use one of the Log functions from Java side.

For example, Log.v, Log.i, and Log.e.

Print Logs from Android C++ Plugin:

If using a C++ plugin, see this plugin from my other question which let's you print log from a C++ plugin with Debug::Log.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...