Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Gabino Garcia
4,407 PointsProblems with other errors shown as I do the android video
I download the android emulator here yesterday..follow the video, android setup and the crystal ball project, and here's the problems I have..
- mine always starts with fragment_main.xml while in the video it's in main_activity.xml
- I could open the main_activity.xml instead but it starts off with no plain text in the graphic interface and in the outline (located on the top right) just shows container..while in the video it has relativelayout and the text with the hello world.
- when I start..looking at the problems tab..I already have two warnings apart from the one warning I'll have after editing the text to "the answer is YES" -- The import android.os.Build is never used -- The import android.support.v7.app.ActionBar
I don't know if it has something to do with the earlier setup I'd in which I choose which android os it is compatible with..(the 2.1 eclair as mentioned in the video and I choose that..) then the next one where I have to go with the jelly bean one and the next one has no other options but the kitkat version..
I couldn't continue with the lesson somehow unless I know what to do to resolve this.
please help. thanks
6 Answers
Steve Hunter
57,712 PointsI get this every time too! The "Hello world!" is in the fragment, not the main and activity_main.xml only contains some <FrameLayout> stuff. I don't know if there's a fix for it as default fragments are a new thing in Eclipse, i.e. after the video was filmed. There may be something in the "Teacher's Notes" section underneath the video.
However, here's what I do to get round the issue:
Copy the .xml from the fragment into the activity_main.xml after deleting the "Hello world!" text in the graphical layout. Delete the existing .xml but preserve the tools:context= line and combine that into the copied code, replacing the mention of fragment placeholder.
Delete fragment_main.xml - this throws a few errors. In MainActivity.java you'll get an error in the onCreate method within the if(savedInstanceState) - delete the 'if' statement completely.
Also, there'll be an error in the same file at about line 58. That'll be looking for R.layout.fragment_main - change that to R.layout.activity_main.
And you're good to go!
Hope that works for you - let me know if not.
Steve.
Gabino Garcia
4,407 PointsHi and thanks for replying.
Somehow I think I made it worst..
I did as you said but now I got two new errors
- Element type "RelativeLayout" must be followed by either attribute specifications, ">" or "/>". - This feels like a formatting error. I tried putting them in one line but it didn't work.
- error: Error parsing XML: not well-formed (invalid token)
The import error though with the Ctrl+Shift+O worked so now I'm left with the hardcoded string warning but as the video suggested I should ignore that..
dang, by following the video I don't think I can move on with the program T_T..
thanks
Steve Hunter
57,712 PointsPost the contents of your XML file - the problem is in there.
Gabino Garcia
4,407 PointsHi,
My apologies if it took this long to reply. So far I just went ahead and follow the video leaving everything at the fragment_view.xml..ignoring all three warnings and so far the ctrl+shift+o ain't working anymore..
wonder if I should really start with this video to learn android programming or start with learning Java and reading them notes..
thanks
Steve Hunter
57,712 PointsAdditional Java knowledge won't help solve this, unfortunately - this is an Eclipse thing.
I've done a bit of Java and some of the Android courses on here. I'd just get on with the Android courses, to be honest. You'll gain more from that than from learning Java.
What errors are you getting now?
Gabino Garcia
4,407 PointsI see. Guess I can skip another programming/scripting language XD thanks for the advice.
So far, none..continuing on with the videos as much as I can.
I appreciate the replies.
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsAnd for your
importerror - press Ctrl+Shift+O (PC) or Cmd+Shift+O (Mac) and the errors will disappear.