For Android development, SQLite3 is the default database that comes with the Android OS. As such, it's a good idea to know some of the basic commands. We decided to keep them here for a handy reference. Leave us a Comment if we missed something you'd like us to include.
The ADB prompt looks like this.
#
The sqlite3 prompt looks like this.
sqlite>
To connect to a database:
# sqlite3 databasename.db
To list ALL tables in a database:
sqlite> .tables
list ALL tables with names like 'foo' in a database:
sqlite> .tables foo
To show the create commands used to create the tables:
sqlite> .schema
show the create commands used to create a table foo:
sqlite> .schema foo
To set column widths for output:
sqlite> .width col_width1 col_width2 col_width3 ...
Showing posts with label Android SDK. Show all posts
Showing posts with label Android SDK. Show all posts
Sunday, September 23, 2012
Wednesday, June 6, 2012
SOLVED: Project contains R.java error, R.java is missing, R.java not generating
1. Eclipse refuses to generate a new .APK, instead generating a popup chiding you for having the gall to include error(s) in your code, as here.
(X) Your project contains error(s), please fix them before running your application.
2. Your code looks fine. No red stuff anywhere near your files.
3. Travel up the project tree and notice R.java (the automatically generated resource file) is red.
Solution(s):
Basically, Eclipse is telling you there's a problem in a resource file, but it didn't figure this out until you tried to run the code. Follow the red. It's designed to help you locate the source of your pain.
Solution 1:
Be Fearless! Dive into R.java to find the problem. That's right, open it up and look inside. In my case, it was a typographical error (a single tiny tick mark added inadvertently to the end of the text) in the strings.xml file. The offending string was clearly marked in red, so it was trivial to find and fix the typo.
Solution 2:
If that doesn't get you out of your funk, try this. Technically, it deals with a missing R.java file, but the root cause is very similar.
Solution 3:
Here's another idea to try.
Solutions #2 and #3 were found here.
Solution 4:
Watch this video. There's an example of how to generate (and resolve) a similar condition beginning at frame time 20:32. We highly recommend watching the whole series, published on YouTube. It provides a good introduction to Android programming using Java in Eclipse. Thanks, Marakana, for providing an excellent video of your boot camp training class.
Labels:
Android SDK,
Eclipse,
HowTo,
Java,
Troubleshooting Code
Wednesday, April 18, 2012
HOW TO: (Android) Rotate the Screen on your Emulator
Want to see what your layout looks like when rotated 90ยบ?
Use [Cntl] + [F11]
Use [Cntl] + [F11]
TERMINAL TIP: Handy ADB Commands (Android Debug Bridge)
Here are some very useful commands. To use them, you must have installed the Android SDK (Software Development Kit), which includes the command line tool ADB. When you have installed it, you can then open a Windows command window.
adb devices lists connected devices
adb [-d | -e] shell connects terminal mini-bash shell to device (-d) or emulator (-e)
Once in the debug shell, try these commands
kill-server cuts connection to emulator
start-server [re-]connects eclipse to emulator
logcat displays running log in a terminal windows
logcat TAG:* *:S filtered: TAG:* = only show all TAG entries; *:S = all others Silent
[ TAG corresponds to Log.d(TAG, "msg"); in .java code ]
input keyevent 82 unlocks screen of connected device
adb devices lists connected devices
adb [-d | -e] shell connects terminal mini-bash shell to device (-d) or emulator (-e)
Once in the debug shell, try these commands
kill-server cuts connection to emulator
start-server [re-]connects eclipse to emulator
logcat displays running log in a terminal windows
logcat TAG:* *:S filtered: TAG:* = only show all TAG entries; *:S = all others Silent
[ TAG corresponds to Log.d(TAG, "msg"); in .java code ]
input keyevent 82 unlocks screen of connected device
Labels:
ADB,
Android SDK,
command line,
Eclipse,
Java,
Troubleshooting Code,
unlock screen
HOW TO: Add a Menu for an Android App using Java in Eclipse
These are the steps needed in order to add a menu.
1. File > New > class: BaseActivity
2. Modify to read "BaseActivity extends Activity"
3. CTL-SHFT-O Organize Imports
4. [HoverOver] Click: Add unimplemented methods
5. Put common functionality such as menu items here
7. As you add menu items, add functionality as part of a CASE: statement
8. File > New > Android XML file > menu.xml
9. Make sure you set the icon property in the menu.xml
10. Update Android.manifest
11. Update new child activity pages like this: NameOfActivity extends BaseActivity
1. File > New > class: BaseActivity
2. Modify to read "BaseActivity extends Activity"
3. CTL-SHFT-O Organize Imports
4. [HoverOver] Click: Add unimplemented methods
5. Put common functionality such as menu items here
7. As you add menu items, add functionality as part of a CASE: statement
8. File > New > Android XML file > menu.xml
9. Make sure you set the icon property in the menu.xml
10. Update Android.manifest
11. Update new child activity pages like this: NameOfActivity extends BaseActivity
Saturday, April 14, 2012
SOLVED: R.layout.main cannot be resolved to a variable
This is a misleading error message. A telltale symptom is your class file contains
import android.R; in your imports list. Remove this line, then look for the real cause of the error message.
More than likely, there is an error in a /res file preventing the project's 'R' file from being generated. If Eclipse can't find one, it will use Android's 'R' file. Check your /res folder for errors (red icons indicate errors). Finding the root cause might not be easy, but once you find and fix the error (and save it), a new 'R' file will be automatically generated.
When that happens, all should again be well with your code.
import android.R; in your imports list. Remove this line, then look for the real cause of the error message.
More than likely, there is an error in a /res file preventing the project's 'R' file from being generated. If Eclipse can't find one, it will use Android's 'R' file. Check your /res folder for errors (red icons indicate errors). Finding the root cause might not be easy, but once you find and fix the error (and save it), a new 'R' file will be automatically generated.
When that happens, all should again be well with your code.
Labels:
Android SDK,
Eclipse,
IDE Errors,
Java,
Troubleshooting Code
SOLVED: Eclipse Update - Connection refused (https://dl-ssl.google.com/android/repository/)
[Updated 28 January 2013]
Every time I try to update Eclipse, I get a variation of this error message.
Connection refused (https://dl-ssl.google.com/android/repository/)
There are several solutions to this issue. Google recommends using the non-secure variant of the repository address, http://dl-ssl.google.com/android/repository/, but I no longer travel this road. I've discovered that once I get the parameters correct for the non-secure site, the secure site will also work. To me, this just means an extra, unnecessary step. Since I prefer using the secure connection, I simply skip down to my short list, provided below, of things that might work. Sometimes, it requires a combination of solutions in order to update correctly. Persistence will pay off!
SOLUTION 1:
Make sure your firewall is set to allow Java, Eclipse, and Android SDK to get out and check for updates (preferred) ... OR turn it off (much more risky).
SOLUTION 2:
Check the URL you're using against the one published on the Android site. The address changes sometimes, so make sure it's the latest one. If it's different, you can try simply updating the address, but your best bet is to update the SDK.
SOLUTION 3:
Try a different network environment.
In certain recent versions of the Windows environment, the SDK Manager must be RUNAS the system administrator (not just any old administrator) as a standalone. This will, by virtue of the relationship between the SDK and Eclipse, update the appropriate add-ons in Eclipse. If you use this solution all the time, you should remove the address from Eclipse's add-ons repository list.
SOLUTION 4:
If you use a proxy server, try this. If not, skip to the next solution.
1. Open a command prompt or terminal window
2. Navigate to the directory in which android.bat resides (the SDK install location)
3. Backup android.bat (in case this fix doesn't work, you will need to revert to the original)
4. Locate the line (near the bottom, very long) that contains %REMOTE_DEBUG%
5. Add the following parameters, using actual values
* Replace [myProxyServer] with the name of your proxy server
* Replace [myProxyPort] with the port number your proxy server uses
-DproxyHost=[myproxyserver] -DproxyPort=[myProxyPort]
6. Save the new android.bat file
7. Restart SDK Manager
8. If problem persists, remove the new android.bat file and restore the original file
SOLUTION 5: For Mac users (may work for other platforms, too)
When the error occurs, click CANCEL, then Update SDK Manager, then Restart SDK Manager.
SOLUTION 6:
Take a look at this post for new ideas. A couple of the solutions in this list were gleaned from here. If you find one that works that's not in this list, please let us know by leaving a comment below.
http://code.google.com/p/android/issues/detail?id=21359
SOLUTION 7: (aka The Last Resort)
Uninstall/Reinstall latest Eclipse _AND_ Android SDK.
28 January 2013
For a recent Tools update, I kept getting a message from Android SDK that the ...\tools directory was in use. Of course, as dumb as it sounds, the program that had locked this directory was the very same Android SDK!!! Here's how I fixed that.
1. Close Eclipse and Android SDK, if running.
2. Manually rename the \tools directory to the destination folder name in the error message. In my case it was ToolPackage.old02.
3. Move the renamed folder via DragNDrop into the ...\temp folder.
4. I found the new version tools_rXX-windows.zip in my ...\temp directory & extracted the tools directory in the SDK root directory.
For example, the newly extracted folder on my Windows 7 machine is c:\Dev\android-sdk-windows\tools.
Every time I try to update Eclipse, I get a variation of this error message.
Connection refused (https://dl-ssl.google.com/android/repository/)
There are several solutions to this issue. Google recommends using the non-secure variant of the repository address, http://dl-ssl.google.com/android/repository/, but I no longer travel this road. I've discovered that once I get the parameters correct for the non-secure site, the secure site will also work. To me, this just means an extra, unnecessary step. Since I prefer using the secure connection, I simply skip down to my short list, provided below, of things that might work. Sometimes, it requires a combination of solutions in order to update correctly. Persistence will pay off!
SOLUTION 1:
Make sure your firewall is set to allow Java, Eclipse, and Android SDK to get out and check for updates (preferred) ... OR turn it off (much more risky).
SOLUTION 2:
Check the URL you're using against the one published on the Android site. The address changes sometimes, so make sure it's the latest one. If it's different, you can try simply updating the address, but your best bet is to update the SDK.
SOLUTION 3:
Try a different network environment.
In certain recent versions of the Windows environment, the SDK Manager must be RUNAS the system administrator (not just any old administrator) as a standalone. This will, by virtue of the relationship between the SDK and Eclipse, update the appropriate add-ons in Eclipse. If you use this solution all the time, you should remove the address from Eclipse's add-ons repository list.
SOLUTION 4:
If you use a proxy server, try this. If not, skip to the next solution.
1. Open a command prompt or terminal window
2. Navigate to the directory in which android.bat resides (the SDK install location)
3. Backup android.bat (in case this fix doesn't work, you will need to revert to the original)
4. Locate the line (near the bottom, very long) that contains %REMOTE_DEBUG%
5. Add the following parameters, using actual values
* Replace [myProxyServer] with the name of your proxy server
* Replace [myProxyPort] with the port number your proxy server uses
-DproxyHost=[myproxyserver] -DproxyPort=[myProxyPort]
6. Save the new android.bat file
7. Restart SDK Manager
8. If problem persists, remove the new android.bat file and restore the original file
SOLUTION 5: For Mac users (may work for other platforms, too)
When the error occurs, click CANCEL, then Update SDK Manager, then Restart SDK Manager.
SOLUTION 6:
Take a look at this post for new ideas. A couple of the solutions in this list were gleaned from here. If you find one that works that's not in this list, please let us know by leaving a comment below.
http://code.google.com/p/android/issues/detail?id=21359
SOLUTION 7: (aka The Last Resort)
Uninstall/Reinstall latest Eclipse _AND_ Android SDK.
28 January 2013
For a recent Tools update, I kept getting a message from Android SDK that the ...\tools directory was in use. Of course, as dumb as it sounds, the program that had locked this directory was the very same Android SDK!!! Here's how I fixed that.
1. Close Eclipse and Android SDK, if running.
2. Manually rename the \tools directory to the destination folder name in the error message. In my case it was ToolPackage.old02.
3. Move the renamed folder via DragNDrop into the ...\temp folder.
4. I found the new version tools_rXX-windows.zip in my ...\temp directory & extracted the tools directory in the SDK root directory.
For example, the newly extracted folder on my Windows 7 machine is c:\Dev\android-sdk-windows\tools.
Labels:
Android SDK,
Eclipse,
IDE Errors,
Java
Subscribe to:
Posts (Atom)