Issue
My app use a different style for minimum version of Android:
My app use a minimum version: API 9 Android 2.3 (Gingerbread)
I use Version qualifier for assign a different style to every Android version:
My styles file from values/style.xml
is:
<style name="AppTheme" parent="android:Theme">
</style>
My styles file from values-v11/styles.xml
(if device is Android 3.0 or later):
<style name="AppTheme" parent="android:Theme.Holo">
</style>
My styles file from values-v14/styles.xml
(if device is Android 4.0 or later):
<style name="AppTheme" parent="android:Theme.DeviceDefault">
</style>
The following .xml is only a fragment of AndroidManifest.xml
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
</application>
My issue is: When the app runs in my phone, the app crashes unexpectedly, I know that my issue is in the use of version qualifiers.
Solution
You use Android 2.3 for more compatibility. On Android Studio, the activities for minimum versions (like Android 2.3 Gingerbread or earlier) are created automatically with the following code:
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
The ActionBarActivity
isn't compatible with styles different to AppCompat
Try to convert from ActionBarActivity
to Activity
:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Answered By - user4400167
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.