ELET4133: Embedded Systems Topic 3 Eclipse Tour & Building a First App
Agenda In this class we will look at the Eclipse IDE We will examine it s various parts when working on an application We will load an existing project into Eclipse as well as start a new project It s not as intuitive as you would think We will define a virtual Android device and simulated an App on it We will execute an App on a real Android device and show some basic troubleshooting 2
Eclipse To start the Eclipse IDE, navigate to the executable file and open it Don t be concerned if it takes a while to open 3
Eclipse If you had not been working on an App the last time you used Eclipse, or if this is the first use it should appear as below 4
Eclipse If you had been working on an App the last time you used Eclipse, it should open with that App 5
Eclipse If you had been working on an App the last time you used Eclipse, it should open with that App There are 5 main areas in the IDE 6
Eclipse The first is the navigation window It shows all the files in the project A Logical View 7
Eclipse The Navigation Window can also show the folder view As laid out in the system 8
Eclipse Either view helps move from one file to another quickly 9
Eclipse The next is the Main Work Area You can change the layout of the App graphically 10
Eclipse The next is the Main Work Area You can change the layout of the App graphically Or using the XML editor 11
Eclipse Or you can work on other files Java file Manifest file Or any other text file 12
Eclipse The console view is used to show errors and warnings 13
Eclipse The outline view shows an outline of the layout of the screen Helps keep track of the part you are working on 14
Eclipse The task list view allows you to come up with a work plan and then list tasks for each day 15
Import an Existing Project 16
Eclipse: Import an Existing Project Before you start a new project it s a good practice to remove the current project from the IDE To remove the current project, right click on the project name and select Delete 17
Eclipse: Import an Existing Project You ll be prompted to confirm deleting the project Choose [OK] Do NOT check the box unless you really want to delete the complete project from the disk 18
Eclipse: Import an Existing Project To work on an existing project choose File->Import 19
Eclipse: Import an Existing Project To work on an existing project choose File->Import, then Existing Project 20
Eclipse: Import an Existing Project To work on an existing project choose File->Import, then Existing Project, then Browse and choose the Parent folder of the app you want to work on 21
Eclipse: Import an Existing Project To work on an existing project choose File->Import, then Existing Project, then Browse and choose the Parent folder of the app you want to work on, then [Finish] 22
Eclipse: Import an Existing Project It will take a few seconds for the project to load Navigate to and double click on the file you want to edit That file will be loaded into the main work area 23
Begin a New Project This section follows an online tutorial from Android called Creating an Android Project. It is found at: http://developer.android.com/training/basics/firstapp/creating-project.html 24
Eclipse: Begin a New Project With a blank work area choose File->New-> Project 25
Eclipse: Begin a New Project With a blank work area choose File->New-> Project Choose Android Application Project and click [Next] 26
Eclipse: Begin a New Project With a blank work area choose File->New-> Project Choose Android Application Project and click [Next] Type in an App name and choose [Next] 27
Eclipse: Begin a New Project Keep the default checks on this screen and click on [Next] 28
Eclipse: Begin a New Project Keep the default checks on this screen and click on [Next], click [Next] again 29
Eclipse: Begin a New Project Keep the default checks on this screen and click on [Next], click [Next] again, then select Create Activity and Blank Activity then [Next] again 30
Eclipse: Begin a New Project Keep the default checks on this screen and click on [Next], click [Next] again, then select Create Activity and Blank Activity then [Next] again, and finally click [Finish] 31
Eclipse: Begin a New Project Before you ever input ANY code, Eclipse has created a complete working project for you. It is runnable It is not very useful It prints Hello World 32
Execute a Project (a different project was selected for this section) 33
Eclipse: Execute a Project Before you can run a project, you must either: Have an Android device capable of running the app or Use the Virtual Device Emulator 34
Execute a Project on an Android Virtual Device 35
Execute on an Android Virtual Device To simulate the project on an Android Virtual Device Select the Device Manager Select Window -> Android Virtual Device Manager 36
Execute on an Android Virtual Device Select a device from the list of defined devices (if the virtual device is on this list, skip to slide 43) If none have been defined, or if the one needed has not been defined, select [New] Note: I have already defined an Atrix 2 37
Execute on an Android Virtual Device After selecting [New], this window appears Name the device, then 1) choose your device from a list under Device, or 2) Choose the one that is closest to your device, or 3) Define one that is close, or 4) Look under Target 38
Execute on an Android Virtual Device My device was not in the Device list So, I looked in the list under Target 39
Execute on an Android Virtual Device My device was not in the Device list So, I looked in the list under Target The Atrix 2 was listed under Target 40
Execute on an Android Virtual Device So the pre-defined Atrix 2 is selected 41
Execute on an Android Virtual Device So the pre-defined Atrix 2 is selected The Virtual Device was named Then select [OK] Your device should appear in the list of Virtual Devices 42
Execute on an Android Virtual Device Select your device from the list and click [START] 43
Execute on an Android Virtual Device It takes a few minutes for the virtual device to appear 44
Execute on an Android Virtual Device It takes a few minutes for the virtual device to appear Then a few more minutes for the virtual device to start working 45
Execute on an Android Virtual Device It takes a few minutes for the virtual device to appear Then a few more minutes for the virtual device to start working Slide the slider as you would a real Atrix 2 46
Execute on an Android Virtual Device It takes a few minutes for the virtual device to appear Then a few more minutes for the virtual device to start working Slide the slider as you would a real Atrix 2 And the virtual device acts like the real device 47
Execute on an Android Virtual Device Click the middle button on the front of the phone to get to the Apps 48
Execute on an Android Virtual Device Click the middle button on the front of the phone to get to the Apps And the Apps are shown The Pizza App can be selected at this point 49
Execute on an Android Virtual Device Click the middle button on the front of the phone to get to the Apps And the Apps are shown The Pizza App can be selected at this point The Virtual Device acts pretty much as the real device acts 50
Execute on an Android Virtual Device Of course, there are some things the virtual device cannot simulate For example, it: Cannot run/simulate Bluetooth Cannot run/simulate WiFi Cannot run/simulate an actual phone call Cannot run/simulate audio files or videos 51
Execute on an Android Virtual Device But, it will give you a pretty good idea if your App will work If your App works on the virtual device, you still have to test your App on the real thing 52
Execute a Project on an Android Device 53
Execute on an Android Device To run on an Android Device (a physical device) You must be able to connect your Android Device (my phone in this case) to the computer through a USB cable Preferably, the USB cable that came with your device Enable USB debugging on your device Settings -> Developer Options 54
Execute on an Android Device To run on an Android Device (a physical device) You must be able to connect your Android Device (my phone in this case) to the computer through a USB cable Preferably, the USB cable that came with your device Enable USB debugging on your device Settings -> Developer Options -> USB Debugging First, check to see if the device is connected 55
Execute on an Android Device You can check that it is connected in 3 ways (1) Run adb.exe from the prompt Note path 56
Execute on an Android Device You can also (2) Look at the Device Manager Should see Android Phone listed in the Device List 57
Execute on an Android Device You can also (3) Check from Eclipse With Package Name Selected Select Run->Run As->Android Application 58
Execute on an Android Device A list of connected devices will appear in this list: If your device is listed, it is recognized If your device is not listed, it is not recognized by the OS and you have troubleshooting to do (go to slide 64) 59
Execute on an Android Device Make Sure that USB debugging is enabled on your device Settings -> Developer Options -> USB Debugging Select your device and click [OK] 60
Execute on an Android Device The application is then downloaded to your Android Device and executed Pizza App loaded in Eclipse on my laptop My Phone after the Pizza App was Downloaded to it 61
Execute on an Android Device The virtual device and the real device look pretty much the same This App worked well in both the virtual device and the real device Virtual device Real device 62
Summary We looked at the Eclipse IDE It s various parts when working on an application We loaded an existing project into Eclipse We started a new project in Eclipse We saw that without doing anything, you had an App that printed Hello World on the screen We defined a virtual Android device and simulated an App on it After some troubleshooting, we executed the same App on a real Android device 63
Some simple troubleshooting attempts 64
Troubleshooting You can check that it is connected in 3 ways (1) Run adb.exe from the prompt Note path 65
Troubleshooting You can check that it is connected in 3 ways (1) Run adb.exe from the prompt Note path Mine did not show anything when the adb command was executed Windows (or the adb command) did not recognize my device 66
Troubleshooting You can also (2) Look at the Device Manager Should see Android Phone listed in the Device List 67
Troubleshooting You can also (2) Look at the Device Manager Should see Android Phone listed in the Device List Mine did not show Android Phone It showed Unknown Device 68
Troubleshooting You can also (3) Check from Eclipse With Package Name Selected Select Run->Run As->Android Application 69
Troubleshooting A list of connected devices will appear in this list: If your device is listed, it is recognized If your device is not listed, it is not recognized by the OS (continue) 70
Troubleshooting You must get Windows (or whatever OS you are using) and adb (Android Debug Bridge) to recognize your device Some basic troubleshooting: Double check that the phone is connected properly 71
Troubleshooting You must get Windows (or whatever OS you are using) and adb (Android Debug Bridge) to recognize your device Some basic troubleshooting: Double check that the phone is connected properly, if it is Try a different cable 72
Troubleshooting You must get Windows (or whatever OS you are using) and adb (Android Debug Bridge) to recognize your device Some basic troubleshooting: Double check that the phone is connected properly, if it is Try a different cable You could try re-booting the phone 73
Troubleshooting You must get Windows (or whatever OS you are using) and adb (Android Debug Bridge) to recognize your device Some basic troubleshooting: Double check that the phone is connected properly, if it is Try a different cable You could try re-booting the phone Or re-boot the computer 74
Troubleshooting If your phone still isn t recognized by your OS Download and install the latest driver for your phone (you may have to re-boot again) 75
Troubleshooting If your phone still isn t recognized by your OS Download and install the latest driver for your phone (you may have to re-boot again) Start searching through the forums or get help from your phone s manufacturer 76
Troubleshooting If your phone still isn t recognized by your OS Download and install the latest driver for your phone (you may have to re-boot again) Start searching through the forums or get help from your phone s manufacturer None of this worked for my phone 77
Troubleshooting I believed that the upgraded Android OS (Ice Cream Sandwich: 4.2) was the problem The previous Android OS (Gingerbread: 4.1) was recognized by Windows An Android forum entry suggested that a Factory Reset on the phone would allow me to downgrade to the previous OS (Gingerbread: 4.1) 78
Troubleshooting I backed up as much as I could (and damn if I didn t forget a few things) Then performed a Factory Reset I was reluctant to do this, but after several hours of trying things that did not work (as listed on the previous slides), I decided not to waste any more time The Factory Reset put the phone back in the state it was when I purchased it (2 years ago) 79
Troubleshooting The Factory Reset did not allow me to downgrade the OS (this was why I did it!!) But, when I plugged the phone into the computer, my Android Phone was recognized So, the Factory Reset was necessary even though the previous Android OS was not Once your Android Device is recognized by your programming platform, you can move forward 80