SDK for Mac: https://developer.android.com/studio
Installation guide: https://www.talkandroid.com/guides/developer/android-sdk-install-guide/
See more discussion at:
https://stackoverflow.com/questions/2672100/can-i-develop-android-applications-on-macos
Build the first App:
https://www.iosinsight.com/develop-android-apps-on-mac/
Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts
Thursday, April 25, 2019
Wednesday, July 30, 2014
Flash an Android Phone
A friend got an old Android phone to use for Android development testing. It was a Nexus S 4G, Android build version was GWK74 (2.7.3 Gingerbread). So I spent some time to investigate how to do this. It worked and here is the note.
In this case, when boot into fastboot mode, it complains "Fastboot Mode No Boot or Recovery IMG". So need to download the images.
Also during the process, windows needs 2 device drivers to detect the phone: 1) when android is on, need google device driver for Nexus S 4G, which comes with ADT (in my case, it's in D:\Android\android-sdk\extras\google\usb_drive). 2) when android is in fastboot mode, need another driver called "Android Bootloader Interface driver". After a lot of search, this is available with pdaNet [1].
Next, need to download the images. This can be downloaded from Factory Images for Nexus Devices [2]. For Nexus S 4G, the corresponding section is at the end of the page: "Factory Images sojus for Nexus S 4G (d720)". 3 versions are available: 2.3.7 (GWK74), 4.0.4 (IMM76D) and 4.1.1 (JRO03R). The phone previously had 2.3.7 (GWK74), now we want a more modern version, so choose 4.1.1 (JRO03R).
Now, for actual steps to flash the phone, see [3]. Note in the last step 10, the commands are the same as in flash-all.sh and flash-all.bat of the package in [2]. The steps in [3] are copied below. In an established environment (no need to setup any drivers), the steps involved are 5, 6, 7, 9, 10, 11.
1. Install the Android SDK and Eclipse.
Eclipse probably isn’t necessary but it is nice to have.
2. Launch the Android SDK Manager.
3. In the Android SDK manager verify that the Google USB Driver is installed and up to date.
4. Connect the target phone to the PC using USB. Make sure USB Debugging is enabled on the phone.
5. From the command line, display all adb devices
Use the command: adb devices
This command is in the Android SDK platform-tools folder. I have this added to my Path. ADB should list out all attached Android devices.
If no devices are listed, make sure you have the Google Android USB driver installed.
Windows Device Manager should show a device of “Android Composite ADB Interface”.
6. Use ADB to reboot the phone into Fastboot mode
Use the command: adb reboot bootloader
This command is in the Android SDK platform-tools folder.
7. Verify that fastboot can access the phone
Use the command: fastboot devices
This should list out all attached Android devices in Fastboot mode. Notice that the device is no longer visible to ADB. “adb devices” no longer lists the device. However, “fastboot devices” should.
8. Install the Android Bootloader Interface driver if needed
If Fastboot Devices lists the phone, this step is not necessary. If Fastboot does not list the phone or shows
You may need to install the Android Bootloader Interface driver. This can be from the pdaNet.
9. Download and expand the device images to use.
For this phone, Google publishes the standard images at https://developers.google.com/android/nexus/images#sojusgwk74
10. Execute the commands from flash-all.sh to flash the device.
Change to the folder with the expanded images and execute the fastboot commands from the flash-all.sh file.
fastboot flash bootloader bootloader-crespo4g-d720sprlc1.img
fastboot reboot-bootloader
fastboot flash radio radio-crespo4g-d720sprlf2.img
fastboot reboot-bootloader
fastboot -w update image-sojus-jro03r.zip
Note the last step "fastboot -w update image-sojus-jro03r.zip" may fail, possible because it cannot decode the zip file for the images, so do it manually: first uncompress the zip file, which contains the images, then in DOS, use these commands (refer to the end of [4]), which I call step 11:
11. Flash the images.
fastboot flash recovery recovery.img
fastboot flash boot boot.img
fastboot flash userdata userdata.img
fastboot flash system system.img
12. Recovery
In the Android screen, use sound dial to choose "Recovery", then press power button to confirm.
It takes a few minutes to recover from the flashed images, then automatically boot into the new Android 4.1.1 system.
The entire process can be summarized into 3 steps:
1) setup device drivers so computer can detect the phone in both normal and fastboot modes.
2) download image package for your device.
3) use Android SDK tools adb and fastboot to do the flash.
References:
[1] pdaNet
[2] Factory Images for Nexus Devices
[3] Flash Nexus S 4G
[4] http://wiki.cyanogenmod.org/w/Doc:_fastboot_intro
In this case, when boot into fastboot mode, it complains "Fastboot Mode No Boot or Recovery IMG". So need to download the images.
Also during the process, windows needs 2 device drivers to detect the phone: 1) when android is on, need google device driver for Nexus S 4G, which comes with ADT (in my case, it's in D:\Android\android-sdk\extras\google\usb_drive). 2) when android is in fastboot mode, need another driver called "Android Bootloader Interface driver". After a lot of search, this is available with pdaNet [1].
Next, need to download the images. This can be downloaded from Factory Images for Nexus Devices [2]. For Nexus S 4G, the corresponding section is at the end of the page: "Factory Images sojus for Nexus S 4G (d720)". 3 versions are available: 2.3.7 (GWK74), 4.0.4 (IMM76D) and 4.1.1 (JRO03R). The phone previously had 2.3.7 (GWK74), now we want a more modern version, so choose 4.1.1 (JRO03R).
Now, for actual steps to flash the phone, see [3]. Note in the last step 10, the commands are the same as in flash-all.sh and flash-all.bat of the package in [2]. The steps in [3] are copied below. In an established environment (no need to setup any drivers), the steps involved are 5, 6, 7, 9, 10, 11.
1. Install the Android SDK and Eclipse.
Eclipse probably isn’t necessary but it is nice to have.
2. Launch the Android SDK Manager.
3. In the Android SDK manager verify that the Google USB Driver is installed and up to date.
4. Connect the target phone to the PC using USB. Make sure USB Debugging is enabled on the phone.
5. From the command line, display all adb devices
Use the command: adb devices
This command is in the Android SDK platform-tools folder. I have this added to my Path. ADB should list out all attached Android devices.
If no devices are listed, make sure you have the Google Android USB driver installed.
Windows Device Manager should show a device of “Android Composite ADB Interface”.
6. Use ADB to reboot the phone into Fastboot mode
Use the command: adb reboot bootloader
This command is in the Android SDK platform-tools folder.
7. Verify that fastboot can access the phone
Use the command: fastboot devices
This should list out all attached Android devices in Fastboot mode. Notice that the device is no longer visible to ADB. “adb devices” no longer lists the device. However, “fastboot devices” should.
8. Install the Android Bootloader Interface driver if needed
If Fastboot Devices lists the phone, this step is not necessary. If Fastboot does not list the phone or shows
9. Download and expand the device images to use.
For this phone, Google publishes the standard images at https://developers.google.com/android/nexus/images#sojusgwk74
10. Execute the commands from flash-all.sh to flash the device.
Change to the folder with the expanded images and execute the fastboot commands from the flash-all.sh file.
fastboot flash bootloader bootloader-crespo4g-d720sprlc1.img
fastboot reboot-bootloader
fastboot flash radio radio-crespo4g-d720sprlf2.img
fastboot reboot-bootloader
fastboot -w update image-sojus-jro03r.zip
Note the last step "fastboot -w update image-sojus-jro03r.zip" may fail, possible because it cannot decode the zip file for the images, so do it manually: first uncompress the zip file, which contains the images, then in DOS, use these commands (refer to the end of [4]), which I call step 11:
11. Flash the images.
fastboot flash recovery recovery.img
fastboot flash boot boot.img
fastboot flash userdata userdata.img
fastboot flash system system.img
12. Recovery
In the Android screen, use sound dial to choose "Recovery", then press power button to confirm.
It takes a few minutes to recover from the flashed images, then automatically boot into the new Android 4.1.1 system.
The entire process can be summarized into 3 steps:
1) setup device drivers so computer can detect the phone in both normal and fastboot modes.
2) download image package for your device.
3) use Android SDK tools adb and fastboot to do the flash.
References:
[1] pdaNet
[2] Factory Images for Nexus Devices
[3] Flash Nexus S 4G
[4] http://wiki.cyanogenmod.org/w/Doc:_fastboot_intro
Tuesday, July 1, 2014
Birthday Calculator update
Today updated the Birthday Calculator Android App according to the feedback of the friend. Added these functions:
1) Instead of using keyUP() which does not work for real Android phone touch screen event, now it is using OnChange event, actually, TextWatcher is the name here.
2) Tax is added. Check the checkbox in front of Tax, then Tax is included in tip calculation.
3) The settings page is setup now. The tax rate is included in setting.
The new interface is like this:
1) Instead of using keyUP() which does not work for real Android phone touch screen event, now it is using OnChange event, actually, TextWatcher is the name here.
2) Tax is added. Check the checkbox in front of Tax, then Tax is included in tip calculation.
3) The settings page is setup now. The tax rate is included in setting.
The new interface is like this:
More iOS and Android programming, and OCR library
In the past month I have followed the book Beginning iOS Programming to build the Bands App, which has many features, such as accessing iPhone's photo album and camera, data storage, sharing band information via email and instant message, searching internet for band information, finding music stores on google map, and using iTunes web service to listen to song previews.
Today I also build my first Android App: the Birthday Calculator. The idea came from a friend, who used to have trouble calculating per person bill for a birthday party, where the person on birthday is free of charge, other people pay. He wanted an App to do the calculation. I did it today, just one day, about 8 hours. It's more just like a Bill calculator, given total bill (plus tax), tip rate, and number of persons, calculate per person bill. When running inside Android simulator, the interface is like this:
The top text box lets one enter the total bill (plus tax). Under this the user can choose from 4 fixed tip rates: 10%, 15%, 20% and 25%. It also allows the user to enter a customized tax rate, which defaults at 17% when the App initially starts. Under this the user can increase or decrease the number of persons using two buttons, or enter directly in the text box to the right side. The last line in green shows per person bill. Whenever the user changes anything on the UI, the bill, the tip rate, or the person number, it automatically updates all other fields for the change, so you see all the values instantly update on the interface as you type.
Considerations are made for exception cases. The total bill allows only decimal number input, and there are the cases the user enters something like ".25". When "." is first entered, the number conversion shouldn't crash the App. The bill should also be limited to at most 2 decimal digits. The customized tip rate and person number text boxes allow only integer input. The customized tip rate is limited between 0-99%. For person number you need to avoid 0, which would lead to divide by 0 error. Listeners are used to monitor keyUP and onFocus events.
A similar calculator is the 9mi web calculator for salary. They are looking for people to make it onto Android and iOS. Feel like I'm ready for that job.
This is the first step towards a new world for me.
== OCR software ==
Another thing, a friend's son wants to build an App with OCR function. A few days ago I did a search on line about OCR library for iOS and Android.
For iOS, the Tesseract OCR iOS library can be used. Tesseract for Android is also available, see here for experience on how to use it.. The Tesseract OCR was developed at HP lab since the 1990s. Between 1995 and 2006 there were few work done, but after that it was improved by google. It is arguably (one of) the most accurate OCR library. It is under the Apache 2.0 license now. Should be handy to use.
When searching for existing OCR products, a quick search on App store using keyword "ocr" found CamScanner, which has 4.5 star rating, but OCR function is available only for premium version, which costs $4.99/month or $49.99 per year. Most others are not free, like Scanner with OCR by SwissMadeApps, Pixter Scanner OCR by Quanticapps, SmartScan+OCR by AMAXIM APPS, Perfect OCR by Pksoft Inc. etc. Leadtools OCR Application has 3 star rating and is free. OCR Scanner by Smart Mobile Store is also free. I downloaded these 2 to have a try.
OCR Scanner seems not bad in recognition quality, but it's UI interface is a little off position to the top, so the top header is half covered and can't be seen. There is no way to cancel a conversion in the middle. It allows 5 free conversions a day.
Leadtools OCR has a more friendly UI, richer functions, can cancel a conversion in the middle. But the recognition quality seems not so satisfying in dim light, and is more sensitive to disturbance.
Today I also build my first Android App: the Birthday Calculator. The idea came from a friend, who used to have trouble calculating per person bill for a birthday party, where the person on birthday is free of charge, other people pay. He wanted an App to do the calculation. I did it today, just one day, about 8 hours. It's more just like a Bill calculator, given total bill (plus tax), tip rate, and number of persons, calculate per person bill. When running inside Android simulator, the interface is like this:
The top text box lets one enter the total bill (plus tax). Under this the user can choose from 4 fixed tip rates: 10%, 15%, 20% and 25%. It also allows the user to enter a customized tax rate, which defaults at 17% when the App initially starts. Under this the user can increase or decrease the number of persons using two buttons, or enter directly in the text box to the right side. The last line in green shows per person bill. Whenever the user changes anything on the UI, the bill, the tip rate, or the person number, it automatically updates all other fields for the change, so you see all the values instantly update on the interface as you type.
Considerations are made for exception cases. The total bill allows only decimal number input, and there are the cases the user enters something like ".25". When "." is first entered, the number conversion shouldn't crash the App. The bill should also be limited to at most 2 decimal digits. The customized tip rate and person number text boxes allow only integer input. The customized tip rate is limited between 0-99%. For person number you need to avoid 0, which would lead to divide by 0 error. Listeners are used to monitor keyUP and onFocus events.
A similar calculator is the 9mi web calculator for salary. They are looking for people to make it onto Android and iOS. Feel like I'm ready for that job.
This is the first step towards a new world for me.
== OCR software ==
Another thing, a friend's son wants to build an App with OCR function. A few days ago I did a search on line about OCR library for iOS and Android.
For iOS, the Tesseract OCR iOS library can be used. Tesseract for Android is also available, see here for experience on how to use it.. The Tesseract OCR was developed at HP lab since the 1990s. Between 1995 and 2006 there were few work done, but after that it was improved by google. It is arguably (one of) the most accurate OCR library. It is under the Apache 2.0 license now. Should be handy to use.
When searching for existing OCR products, a quick search on App store using keyword "ocr" found CamScanner, which has 4.5 star rating, but OCR function is available only for premium version, which costs $4.99/month or $49.99 per year. Most others are not free, like Scanner with OCR by SwissMadeApps, Pixter Scanner OCR by Quanticapps, SmartScan+OCR by AMAXIM APPS, Perfect OCR by Pksoft Inc. etc. Leadtools OCR Application has 3 star rating and is free. OCR Scanner by Smart Mobile Store is also free. I downloaded these 2 to have a try.
OCR Scanner seems not bad in recognition quality, but it's UI interface is a little off position to the top, so the top header is half covered and can't be seen. There is no way to cancel a conversion in the middle. It allows 5 free conversions a day.
Leadtools OCR has a more friendly UI, richer functions, can cancel a conversion in the middle. But the recognition quality seems not so satisfying in dim light, and is more sensitive to disturbance.
Friday, June 13, 2014
Android App Development
7/12/2014
Open Android emulator and install apk in command line on a mac:
- Start avd manager:
In /Developer/Applications/Android/android-sdk-macosx/tools, type
android avd
- To install an apk
with the emulator running, go into ../platform-tools, type:
./adb install ~/Downloads/myapp.apk
7/3/2014
Now put the Birthday Calculator project on repository, and created the first release.
The App is built with the setting of Android SDK min version 11 and target version 19. In other words, to install this App, you should have Android 3.0 (Honeycomb, see Wiki: Android version history) or above to be safely compatible.
6/26/2014
6/13/2014
- Was able to run example projects, and create empty Android project.
- downloaded book code from http://www.apress.com/9781430210641
for book Android Essentials, by Chris Haseman. QA76.76 A65 J37 2008
- Android emulator runs too slow. Follow this to make it faster:
http://stackoverflow.com/questions/1554099/why-is-the-android-emulator-so-slow
- save this html page as "performance - Why is the Android emulator so slow.pdf"
Basically:
Use 2000 MiB for SD Card. Enable Snapshot. Use 1024 for device ram size.
In AVD manager, Start.. -> check Launch from snapshot and Save to snapshot
This seems faster but not good enough. So try the next: HAMX acceleration.
- My CPU: Intel Xeon CPU W3530. Support vt, from
http://ark.intel.com/Products/VirtualizationTechnology
Tried the one using HAMX acceleration. It's much faster now!
-> The HAEM.exe is at D:\Android\android-sdk\extras\intel\Hardware_Accelerated_Execution_Manager
- Also found that, once the emulator is on, open new Android app
does not need to restart the emulator.
- Another online tutorial:
https://developer.android.com/training/basics/firstapp/index.html
- this provide info on doing this from command line, v.s. using IDE such as eclipse.
- Same installation procedures work on both Windows and Mac.
Environment set up on both Windows and Mac.
6/12/2014
- Install Eclipse from eclipse.org/downloads/. Use JEE version.
- 32-bit version does not work.
- 64-bit version works.
- tried to create the Hello World application and works.
- Install Android SDK
- from https://developer.android.com/sdk/index.html
- run it. Install to D:\Android\android-sdk
- Install Eclipse Plug-In of Android. ADT: Android Developer Tools.
- From https://developer.android.com/sdk/index.html
Choose: USE AN EXISTING IDE. It is on page:
https://developer.android.com/sdk/installing/index.html
6/11/2014
- Borrowed book "Android Essentials" by Chris Haseman from library. It's on web at here.
References:
[1] Develop Apps | Android Developers Homepage
[2] Android ActionBar完全解析,使用官方推荐的最佳导航栏
Open Android emulator and install apk in command line on a mac:
- Start avd manager:
In /Developer/Applications/Android/android-sdk-macosx/tools, type
android avd
- To install an apk
with the emulator running, go into ../platform-tools, type:
./adb install ~/Downloads/myapp.apk
7/3/2014
Now put the Birthday Calculator project on repository, and created the first release.
The App is built with the setting of Android SDK min version 11 and target version 19. In other words, to install this App, you should have Android 3.0 (Honeycomb, see Wiki: Android version history) or above to be safely compatible.
6/26/2014
- After 3 weeks, at the same time I read Nick Harris's Beginning iOS Programming and finished a Bands App on my iPhone. In comparison the "Android Essentials" book did not impress me. It is hard to read and too crude to make much sense. Anyway, it was published back in 2008, so let's don't push too much expectation on it. The only thing "good" is that it's a thin book. Actually, there are tutorials on line. Once got through several prototype examples, one will understand the basic building blocks and underlying framework, then pick a better book becomes easy.
6/13/2014
- Was able to run example projects, and create empty Android project.
- downloaded book code from http://www.apress.com/9781430210641
for book Android Essentials, by Chris Haseman. QA76.76 A65 J37 2008
- Android emulator runs too slow. Follow this to make it faster:
http://stackoverflow.com/questions/1554099/why-is-the-android-emulator-so-slow
- save this html page as "performance - Why is the Android emulator so slow.pdf"
Basically:
Use 2000 MiB for SD Card. Enable Snapshot. Use 1024 for device ram size.
In AVD manager, Start.. -> check Launch from snapshot and Save to snapshot
This seems faster but not good enough. So try the next: HAMX acceleration.
- My CPU: Intel Xeon CPU W3530. Support vt, from
http://ark.intel.com/Products/VirtualizationTechnology
Tried the one using HAMX acceleration. It's much faster now!
-> The HAEM.exe is at D:\Android\android-sdk\extras\intel\Hardware_Accelerated_Execution_Manager
- Also found that, once the emulator is on, open new Android app
does not need to restart the emulator.
- Another online tutorial:
https://developer.android.com/training/basics/firstapp/index.html
- this provide info on doing this from command line, v.s. using IDE such as eclipse.
- Same installation procedures work on both Windows and Mac.
Environment set up on both Windows and Mac.
6/12/2014
- Install Eclipse from eclipse.org/downloads/. Use JEE version.
- 32-bit version does not work.
- 64-bit version works.
- tried to create the Hello World application and works.
- Install Android SDK
- from https://developer.android.com/sdk/index.html
- run it. Install to D:\Android\android-sdk
- Install Eclipse Plug-In of Android. ADT: Android Developer Tools.
- From https://developer.android.com/sdk/index.html
Choose: USE AN EXISTING IDE. It is on page:
https://developer.android.com/sdk/installing/index.html
6/11/2014
- Borrowed book "Android Essentials" by Chris Haseman from library. It's on web at here.
References:
[1] Develop Apps | Android Developers Homepage
[2] Android ActionBar完全解析,使用官方推荐的最佳导航栏
Subscribe to:
Posts (Atom)
Blog Archive
-
▼
2026
(36)
-
▼
June
(19)
- C10K to C10M: from thread-per-connection model to ...
- Benchmark server performance
- Application server for php, python, java, node.js,...
- Application server for C++, Go and Rust
- Nginx as reverse proxy and load balancer
- Infrastructure running: nginx, apache, php, python...
- Flow chart of nginx+apache+uvcorn infrastructure
- Flow chart of apache+uvcorn infrastructure
- Uvicorn and Gunicorn
- What's deadsnakes PPA
- What's the optional lsb-core package
- Codex known logging bug
- Daemonsize a service
- Train text to image model, to generate images of c...
- Train a model based on OpenAI API
- Open port 8080 for WebSocket
- Add websocket support on Bluehost Ubuntu VPS for D...
- Install Claude Code on ubuntu VPS of Bluehost
- Install PostgreSQL on Mac
-
▼
June
(19)


