We have an Android app that is using ActionBarSherlock and has the following Manifest configuration:
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15"/>
Lately we encountered crashes because we hat the following code line in the app:
String type = ...
if (type.isEmpty()) {
...
}
because the isEmpty() method is not available in Android 2.2.x (out minSdkVersion 8 we still support).
So we want to find that problem in development, while compiling the app an not when running on the device. Configuring Android version 2.2.x as SDK by setting
<sdk>
<platform>8</platform>
</sdk>
in the maven build configuration leads to the problem that the build fails because of ActionBarSherlock:
[INFO] ../target/unpack/apklibs/com.actionbarsherlock_library_apklib_4.1.0/res/values-v14/abs__styles.xml:4: error:
Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.ActionBar'.
So my question: Is there a way to compile with the correct SDK that makes sure everything in the code is compatible with the devices specified in minSdkVersion AND use ActionBarSherlock?
If you're using ActionBarSherlock you have to compile with a later SDK. But you can use Lint to check for these invalid API calls at build time.