saulmm / From-design-to-Android-part1

First part of 'from design to android' series
http://saulmm.github.io/from-design-to-android-part1
Apache License 2.0
627 stars 131 forks source link

Unable to open HomeActivity #2

Closed Arkar-Aung closed 7 years ago

Arkar-Aung commented 7 years ago

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.

saulmm commented 7 years ago

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

NanBox commented 7 years ago

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

android:theme="@style/AppTheme" 

to

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

It work for me.

Arkar-Aung commented 7 years ago

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

saulmm commented 7 years ago

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