Running an Android app is different from other sorts of Java applications. In a Java console application, you start with a main() method in a single class. An Android consists of both Java code and many other kinds of resources. As a developer, you should understand the basics of how an app is packaged for deployment, and how it starts up at runtime.
- [Voiceover] When you write Java code for an Android app,…you start off with the same sort of files as you do…for other Java application platforms.…You write your code in text files…with the .java file extension…and you can combine your custom code…with existing libraries that are…pre-compiled into .class bytecode files…and are usually organized into JAR files.…From there, you go through the same sort of steps…as in other platforms using the javac command…that's a part of the Java development kit…to compile your source code into java bytecode…in class files.…
The next step is optional,…and when you're packaging an app…it's common to use a tool called ProGuard.…This tool minimizes and obscures your java code.…It goes through all of your code and renames…identifiers, class and interface and method names…to shrink them down to a smaller size.…It can also obscure your java code…so that if somebody tries to decompile that code,…it won't be of much use to them.…Now, if you're working in another java development…platform, this might be your last compilation step.…
Watch these Java tutorials to learn smarter, more efficient methods for Android app development.
- Preparing the development environment
- Packaging and running Android apps
- Optimizing Java code for Android
- Implementing event handler interfaces
- Defining custom callback methods
- Working with the Android SDK's Java packages
- Storing data
- Reading text files
- Parsing JSON and XML data
- Managing device sensors
- Playing audio