saulmm/From-design-to-Android-part1

Unable to open HomeActivity

Arkar-Aung opened this issue · 4 comments

After building project is success, the app crashes immediately right after launching.

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.saulmm.cui/com.saulmm.cui.HomeActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

If you build from this commit which is the head in master at a time, you shouldn't have that problem.

Anyway, that used to happen when your activity is inheriting from AppCompatActivity but the theme set to it is not related with AppCompat

i.e:

This will crash firing your exception
<style name="AppTheme" parent="@android:style/Theme.Material">
HomeActivity extends AppCompatActivity

This will work
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
HomeActivity extends AppCompatActivity

I have the same problem. In AdnroidManifest.xml, I change

android:theme="@style/AppTheme" 

to

android:theme="@style/Base.AppTheme"

It work for me.

Yes,AppTheme which inherits from Base.AppTheme is declared only for v23. That's why.

@Arkar-Aung is right, what a mistake, solved here. Thanks for the feedback guys