Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead. Please use Android Tools > Fix Project Properties
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
When developing applications using the Android platform, developers occasionally encounter compiler compliance level errors, such as "Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead." This error stems from a mismatch between the Java version used in the project and the version expected by the Android development tools.
Understanding Compiler Compliance Levels
The compiler compliance level refers to the version of the Java Language that your source code is compliant with. Each compliance level corresponds to a version of the Java programming language, with specific features and capabilities:
- 5.0 (also referred to as Java 5) brought enhancements such as generics, annotations, autoboxing/unboxing, enumerations, and more, which were not present in earlier versions.
- 6.0 (Java 6) followed with further improvements including scripting support, JDBC 4.0 support, and enhancements in the Java Compiler API and GUI management.
When the Android development tools are set to expect Java 5 or 6, but the project uses Java 7, it leads to the stated compatibility error. Java 7 includes features such as the diamond operator, strings in switch statements, and try-with-resources statements, which aren’t supported under the compliance levels of 5.0 or 6.0 expected by certain Android SDK versions.
Resolving the Compiler Compliance Error
The error message typically suggests a quick fix: "Please use Android Tools > Fix Project Properties." This solution attempts to automatically adjust the project settings to a compatible compliance level. Here's how you can execute this fix in Eclipse, a commonly used IDE for Android development:
- Right-click on the project in the Project Explorer.
- Go to 'Android Tools'.
- Select 'Fix Project Properties'.
This process sets the project to a compliance level that matches the Android SDK requirements, generally Java 5 or 6.
Manual Compliance Level Adjustment
Alternatively, project compliance levels can be manually adjusted in the project properties:
- Right-click on the project and select
Properties. - Navigate to
Java Compiler. - Check 'Enable project specific settings'.
- Set the 'Compiler compliance level' to either '5.0' or '6.0'.
- Apply changes and close the window.
Updating the JDK Used
Sometimes, even after adjusting the compliance level, errors related to SDK version mismatches or deprecated methods may occur. In such cases, consider downloading and using an older JDK compatible with the required compliance level:
- Install the JDK for Java 5 or Java 6.
- In Eclipse, go to
Window > Preferences > Java > Installed JREsto add and select the appropriate JDK.
Detailed Step-by-Step Example:
Suppose you are working on an app using JDK 7 in Eclipse and encounter the mismatch error. Here’s how you could resolve it:
- Open Project Properties: Right-click on the project => Properties => Java Compiler.
- Adjust Compliance Level: Check 'Enable project specific settings' and select 6.0.
- Apply and Rebuild: Click Apply and Close, then clean and rebuild the project.
Summary Table
| Feature/Change | Java 5 | Java 6 | Java 7 |
| Generics | ✓ | ✓ | ✓ |
| Annotations | ✓ | ✓ | ✓ |
| Autoboxing/Unboxing | ✓ | ✓ | ✓ |
| Enumerations | ✓ | ✓ | ✓ |
| Diamond Operator | ✓ | ||
| Strings in Switch | ✓ | ||
| Try-with-resources | ✓ |
Conclusion
Understanding and managing compiler compliance levels is crucial for Android development, particularly when older versions of the SDK are involved. Properly setting the JDK and compliance levels ensures that the features used in the application are supported by both the Java version and the Android platform, leading to a smoother development process and fewer runtime issues.

