0

I have been trying, for 2 days now, to simply get past the first few pages of the first chapter of Big Nerd Ranch's Android Programming Book.

The gist of my problem is that when I create a new Android app, no layout or .java files are created.

I have installed the ADT Bundle (which includes Eclipse and the SDK) from the Android dev site. I have also installed Eclipse on my own, updated Java on my Mac, and manually downloaded the SDK. In both scenarios I am running ADT version 23.0.

Here are some screenshots of what I'm doing:

Creating the project enter image description here

The Project workspace right after creating: enter image description here

The Installed ADT Tools enter image description here

The installed SDKs and API Levels enter image description here

I also read on the dev forums that there are some issues with version 23.0, and that things like ProGuard, SQLite3, and other items are missing, which I have copied into the Android SDK folder where everything is located.

And yet, it doesn't work. No matter what API Level I target, I cannot get the layout and java file to create. Any ideas and solutions? I know there is Android studio but I really want to learn it with Eclipse for legacy support, and as this is what most books use for teaching. Plus, there is no support for the NDK yet, from what I have read, which is also of interest to me.

Russia Must Remove Putin
  • 374,368
  • 89
  • 403
  • 331
iFeli
  • 395
  • 2
  • 9
  • Why not just create them by hand? There's nothing special about the autogenerated files. – Gabe Sechan Jun 28 '14 at 17:32
  • Well I could, but I'm trying to understand 2 things: a) Why this isn't working, it's a good learning experience for me to troubleshoot any problems I encounter. b) This should according to the Google and Android resources I've read. Also, since I'm new, I don't know exactly what should go in those files or exactly what they are yet. – iFeli Jun 28 '14 at 17:36
  • I would put Android aside for a week or so, then check to see if there are updates to the tools. This week's tools update -- pushed out in concert with the Google I|O conference -- has had more than its fair share of problems. However, beyond that, your book was published a bit over a year ago, and as a result it will be somewhat out of sync with the way the tools look and work. – CommonsWare Jun 28 '14 at 17:37
  • This is something I have been reading. The L Preview and Rev 23 have broken tons of things :/ It's a shame. I well aware I'll have to do some research of my own as the books get outdated, but it's kinda silly not being able to download what's on the Android Developer site and get things to work the way they should 'out of the box'. – iFeli Jun 28 '14 at 17:42
  • Try looking for a copy of the previous version somewhere. However, be prepared to have to fix bugs with Eclipse- the Android plugins have always had a few issues. – Gabe Sechan Jun 28 '14 at 18:23

2 Answers2

1

I had this kind of "bug" the first time I used Eclipse ADT too. In my case uninstall and reinstalling fixed the problem.

However as the comments told you, it's no big deal to have the files created automatically for you, except in the case you're totally new to Android and doesn't know what you may miss if you create the file from scratch.. which was also my case.

But in case you are still bugged by the problem then this might help. Usually these 3 files are created automatically for you, but in case they would not, then make them on your own by copy-pasting these:

AppNameHere\res\layout\activity_main.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.anything.appnamehere.MainActivity"
    tools:ignore="MergeRootFrame" />

AppNameHere\res\layout\fragment_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.anything.appnamehere.MainActivity$PlaceholderFragment" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

</RelativeLayout>

AppNameHere\src\com.anything.appnamehere\MainActivity.java

package com.anything.appnamehere;
public class MainActivity extends Activity{

}

These codes are for my app which is named com.anything.appnamehere, please modify to suit your need.

Mr. Kro
  • 138
  • 9
  • Thanks a bunch :) That has helped me understand things a bit more. If you see my comment below I got the ADT and SDK to work with Rev 22.6.3, however it creates a fragment as well. How can I delete the fragment and simply use the Activity without breaking anything in the starter project? – iFeli Jun 28 '14 at 19:57
  • You can delete it by right click and choose delete, but I recommend leave anything as it is and delete only when you're sure what it is and exactly which file(s) are making reference to it. A file which does nothing will make no problem if nothing else calls it and it's still ther, but may cause crashes if something calls it when it's not there – Mr. Kro Jul 01 '14 at 02:36
  • Thanks for the suggestion Mr. Kro. I will keep that in mind for future projects and when deleting files while I fully understand how things work in Android :) – iFeli Jul 01 '14 at 14:54
0

OK, So after several hours of experimentation and research, there is currently no way to create a default Android project with the Rev 23.0 version of the ADT Tools.

Here is what I did form scratch to get things working on my computer. I'm running OS X 10.9.3:

  1. Downloaded the Java JDK 7u60 from here: Java JDK for Mac
  2. Downloaded Eclipse Luna 64-bit from here: Eclipse Luna 64-Bit Mac
  3. Downloaded the Android SDK version 22.6.3 here: Android SDK 22.6.2 Mac
  4. Downloaded the ADT tools version 22.6.3 from here: ADT 22.6.3 Mac

    • I first put the Android SDK folder, unzipped, in my Applications directory and renamed it to "Android SDK" (You can use whatever you want or put it elsewhere.
    • Afterwards, I went into Eclipse > Help > Install New Software...
    • Then I clicked on Add > Archive > .Zip file for ADT 22.6.3
    • Launched Eclipse and was promoted to select the SDK location, so in Eclipse's preferences I selected the folder I put inside my Applications directory.
    • Updated the Android SDK built tools and downloaded the SDKs for the API levels I wanted. Note that I did NOT update the Android SDK Tools to the Rev 23 update available. This is what's broken and has things like ProGuard, SQLite, and other items missing (it's because it was released earlier this week for the L Preview).

And that's it, I am now able to create an application and the .java and activity files are there.

As mentioned by Mr. Kro, there are differences between the book and the SDK, but this is to be expected after ~1 year since its release. In any case this is going to help you if you are having the same trouble as I am. And with this you can use the latest Eclipse and the latest stable Android SDK/ADT, until Google patches Rev 23.

iFeli
  • 395
  • 2
  • 9