Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by FlippyPls · Jun 12, 2017 at 10:28 PM · androidandroid buildnullreferenceexception

Android version not working as intended

Hello!

See, I have a few problems I'm trying to figure out. I'm completely new to android development through unity, but I'm hoping I can get some answers here.

I'm getting a lot of nullreferenceexceptions on my android build that don't occur in unity editor, nor in normal windows build. (I fixed one of the problems by assigning a variable through the inspector instead of doing GameObject.FindGameObjectWithTag().)

for example I'm doing a transform.getchild() that doesn't work on the android build that works perfectly in the editor.

I'm really confused, I've been programming just like I would for a normal windows build and when I tried it out on android so many things are not working at all. Should I be programming differently for android (not including optimization, input and other stuff that is generally different for other platforms)? I'm more talking about what I can do and what I can't do code-wise.

Sorry for the novel, I'd be super thankful for any advice! :)

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Pedro_Brito · Jun 12, 2017 at 11:07 PM 0
Share

Are you using the most recent Unity version? I think this can be, sometimes, bugs from your currently installed Unity version.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Raimi · Jun 12, 2017 at 11:18 PM

 void Update()
 {
      transform.Getchild(0).transform.position += transform.Getchild(1).transform.positon;
 }

if you use Unity's built in functions rather than C# native functions you should be fine. Main issue is probs iPhone

Comment
Add comment · Show 7 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image FlippyPls · Jun 12, 2017 at 11:21 PM 0
Share

Yes, that's what I used.

avatar image Raimi · Jun 12, 2017 at 11:26 PM 0
Share

Give some code examples and we can see if we can help you out

avatar image FlippyPls Raimi · Jun 12, 2017 at 11:39 PM 0
Share
 plant = transform.GetChild(1);

this is what makes a nullreferenceexception, even tho I can see the plant is spawned and everything works in the editor.

avatar image Raimi · Jun 12, 2017 at 11:47 PM 0
Share

What Type is plant? GameObject, transform, vector2?

 Gameobject plant = transform.GetChild(1).gameobject;
 
 Transform plant = transform.Getchild(1).transform;


avatar image FlippyPls Raimi · Jun 12, 2017 at 11:50 PM 0
Share

Transform.

             plant.localScale = Vector3.Lerp(InitialScale, FinalScale, percent);

This is the line of code that actually givesme the error. I'm assu$$anonymous$$g the nullreferenceexception is referring to the plant.

EDIT: Oh, I thought GetChild(0) returned the same as GetChild(0).transform in this case.

avatar image Raimi FlippyPls · Jun 12, 2017 at 11:53 PM 0
Share

Have you actually assigned something to plant? like in inspector, or GameObject.Find()?

Show more comments
avatar image
0

Answer by Pedro_Brito · Jun 12, 2017 at 11:42 PM

Are you sure you've wet up everything correctly and you've updated Unity to the most recent version?

I've already experienced some issues while building for Android, quick were fixed by updating Unity.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image FlippyPls · Jun 12, 2017 at 11:43 PM 0
Share

Yes, I actually reinstalled whole unity yesterday, so it should be up to date. I'm currently on 5.6.1f1.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

131 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Building for android freezes unity editor 2 Answers

Probuilder throws ArgumentReferenceException when Extruding object on Android 0 Answers

How to port game on android wear ? 2 Answers

Unity2D quads not appearing in front of other quads in Android build 1 Answer

IL2CPP support for Linq 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges