LZ-Says:不畏艰难,一起干!!!
前言
对于任何一门新接触的语言,我们总会因为不熟悉从而导致犯一些基本的低级错误,对于错误,我们要秉承拥抱的态度,遇到的越多,也意味着我们每天在前行,错误,不过尔尔~
异常收集汇总
Step 1:MissingComponentException: There is no ‘Rigidbody’ attached to the “Player” game object, but a script is trying to access it.
错误日志:
MissingComponentException: There is no 'Rigidbody' attached to the "Player" game object, but a script is trying to access it.
You probably need to add a Rigidbody to the game object "Player". Or your script needs to check if the component is attached before using it.
UnityEngine.Rigidbody.AddForce (Vector3 force) (at C:/buildslave/unity/build/artifacts/generated/common/modules/Physics/DynamicsBindings.gen.cs:1426)
Player.Update () (at Assets/Script/Player.cs:23)
问题解决:
为你的游戏组件添加刚体即可。
Step 2:The referenced script on this Behaviour (Game Object ‘Player’) is missing!
错误日志:
The referenced script on this Behaviour (Game Object 'Player') is missing!
错误解决:
例如,有的预制件的组件中包含了脚本,但是这个脚本已经删除了,那么在脚本组件的位置将显示一个丢失的信息。你需要移除这个组件,或者替换上更新后的脚本。其它的情况大体如此。细心检查,将丢失的资源补上或者移除即可。还要一种是这个预制件本来分配了一个layer或者tag,但是后来这个layer或tag被删除了,那么这里的layer或tag将显示none,你需要给它分配一个新的layer或tag。
Step 3:Because you are not a member of this project this build will not access Unity services.
问题提示:
问题解决:
一般由于Unity连接不上服务导致。
Step 4:Exception: JNI: Init’d AndroidJavaClass with null ptr!
问题日志:
Exception: JNI: Init'd AndroidJavaClass with null ptr!
UnityEngine.AndroidJavaClass..ctor (IntPtr jclass) (at C:/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:622)
UnityEngine.AndroidJavaObject.get_JavaLangClass () (at C:/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:600)
UnityEngine.AndroidJavaObject.FindClass (System.String name) (at C:/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:591)
UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String className) (at C:/buildslave/unity/build/Runtime/Export/AndroidJavaImpl.cs:611)
UnityEngine.AndroidJavaClass..ctor (System.String className) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/AndroidJavaBindings.gen.cs:92)
Test.OnGUI () (at Assets/Script/Test.cs:29)
问题解决:
需要在真机运行。
GitHub地址
https://github.com/HLQ-Struggle
个人公众号
不定时发表博文,欢迎大家关注~
赞赏
觉得LZ做的不错,不妨来个赞赏哦~~~
参考资料
- https://www.zhihu.com/question/29037925;
- https://blogs.unity3d.com/cn/2015/09/10/unity-services-are-just-a-few-clicks-away/;
- https://stackoverflow.com/questions/28279269/exception-jni-initd-androidjavaclass-with-null-ptr;