Two weeks ago I helped with a beginner's Android Workshop at Mobile March. A lot of the people had problems getting their development environment up and running - but for reasons that weren't really any fault of their own, or were easily overlooked. Typically once you've got all the gears in place building is simple, but I'd forgotten how surprisingly difficult it can be to get a project up and running in Eclipse initially.
Here's a few common problems I saw around the classroom:
- Installing the Android SDK (the tools for Android) but not the ADT plugin (how Eclipse interfaces with the SDK), or vice versa. Make sure both are installed.
- Not installing any Android platforms (or not installing the correct one for the app you're trying to build). The SDK is just a starter package - from there, you need to run the Android SDK Manager and add SDK components. There's an SDK platform for each version of Android; I recommend just installing the whole lot (it takes time to download, but makes everything else easy).
- If you get compilation errors upon importing a project, do a full clean and rebuild. Clean is found in Project --> Clean. This can sometimes clear up import issues.
- Compilation issues with @Override. If you're getting compilation error on @Override, that's because your JDK compliance level is set incorrectly. You either need to go into Eclipse --> Preferences --> Java --> Compiler and set the compliance level to 1.6+, or you need to go into the individual project and change that setting (right-click the project --> Properties --> Java Compiler --> Compiler compliance level).
- Using emulators that are not compatible with your sample app. If your app targets 2.3, you must have a 2.3 (or higher) emulator. If your app uses Google Maps, your emulator must be a "Google APIs" emulator (and also conform to the previous version requirement as well).
- Did you try Android briefly more than a year ago and now it refuses to work? Chances are the problem is an invalid debug.keystore. When you build in Eclipse, it creates your APK using an automatically generated debug keystore. Older versions of Android had these set to expire a year after creation, so if you dabbled in Android before it may have expired. You can find the path to your debug.keystore by going into Preferences --> Android --> Build. You can safely delete your old debug.keystore and the Android build process will automatically create a new, valid one for you.
- If none of the above helps, I found the most useful debugging tool for build errors was to turn on verbose output. You can turn that on in Preferences --> Android --> Build --> Build Output, then check the Console for any salient error messages.
Good luck getting your first Android app building!
Here's a few common problems I saw around the classroom:
- Installing the Android SDK (the tools for Android) but not the ADT plugin (how Eclipse interfaces with the SDK), or vice versa. Make sure both are installed.
- Not installing any Android platforms (or not installing the correct one for the app you're trying to build). The SDK is just a starter package - from there, you need to run the Android SDK Manager and add SDK components. There's an SDK platform for each version of Android; I recommend just installing the whole lot (it takes time to download, but makes everything else easy).
- If you get compilation errors upon importing a project, do a full clean and rebuild. Clean is found in Project --> Clean. This can sometimes clear up import issues.
- Compilation issues with @Override. If you're getting compilation error on @Override, that's because your JDK compliance level is set incorrectly. You either need to go into Eclipse --> Preferences --> Java --> Compiler and set the compliance level to 1.6+, or you need to go into the individual project and change that setting (right-click the project --> Properties --> Java Compiler --> Compiler compliance level).
- Using emulators that are not compatible with your sample app. If your app targets 2.3, you must have a 2.3 (or higher) emulator. If your app uses Google Maps, your emulator must be a "Google APIs" emulator (and also conform to the previous version requirement as well).
- Did you try Android briefly more than a year ago and now it refuses to work? Chances are the problem is an invalid debug.keystore. When you build in Eclipse, it creates your APK using an automatically generated debug keystore. Older versions of Android had these set to expire a year after creation, so if you dabbled in Android before it may have expired. You can find the path to your debug.keystore by going into Preferences --> Android --> Build. You can safely delete your old debug.keystore and the Android build process will automatically create a new, valid one for you.
- If none of the above helps, I found the most useful debugging tool for build errors was to turn on verbose output. You can turn that on in Preferences --> Android --> Build --> Build Output, then check the Console for any salient error messages.
Good luck getting your first Android app building!
No comments:
Post a Comment