-3

My app does not use AppCompat since my minSdkVersion is 15. I want to use smart-app-rate library in it but I am getting (which is expected):

java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

Please note that I can't change my app to AppCompat because A) there is no real need and B) if I do, my app looks totally different that it should.

So, I tried to download the library as ZIP and transformed it to not use AppCompat. I did the steps mentioned in this answer but now I get a whole bunch of errors (like ContextCompat.getColor, which I would need to replace with non-AppCompat function) and I am not sure if this is the right way to do this.

How do I solve this easily?

Primož Kralj
  • 5,534
  • 14
  • 65
  • 125
  • There's no "if your min SDK is greater than X then you should not use AppCompat" statement. The support libraries are recommended to be used (especially if your min SDK is < 21 since there's a big break in the APIs) because the support components provide a unified interface for interacting with elements without the developer's need to check for certain API level requirements. Also, if defining `Theme.AppCompat` as your parent style for your current app theme modifies the look-and-feel that much, there's probably something wrong with your current approach. – Gergely Kőrössy Sep 16 '17 at 19:31
  • @GergelyKőrössy, thanks; obviously I am missing some knowledge and need to read-up. When I change my app to use AppCompat, [this is the difference](https://i.imgur.com/aLCVaMJ.jpg). It looks real bad and even the sliders are missing. Do you have any tip where I should look further in my code? – Primož Kralj Sep 16 '17 at 19:53
  • What kind of components are those? The appbar text color can be fixed by using `Theme.AppCompat.Light.DarkActionBar`as your parent. – Gergely Kőrössy Sep 16 '17 at 19:57
  • Text color fixed, thanks. The (now) missing components are actually `SeekBar`s with rotation of 270. – Primož Kralj Sep 16 '17 at 20:01
  • It seems to be a button because that has the all caps text by default. You should post a new question or edit this with the XML layout included because it's impossible to debug like this. – Gergely Kőrössy Sep 16 '17 at 20:03
  • I will take further look into it with the info you provided and if I can't solve it, I will open another question. Thank you for all the help. – Primož Kralj Sep 16 '17 at 20:04
  • @GergelyKőrössy I posted a new [question](https://stackoverflow.com/questions/46288301/views-gone-after-changing-app-to-use-appcompat) regarding this issue if you want to look at it. Thanks – Primož Kralj Sep 18 '17 at 21:47

1 Answers1

1

but now I get a whole bunch of errors (like ContextCompat.getColor, which I would need to replace with non-AppCompat function)

ContextCompat has nothing to do with appcompat-v7. ContextCompat comes from support-compat, and I strongly recommend the use of the support-compat artifact.

and I am not sure if this is the right way to do this.

You could simply not use the library. Otherwise, you have little choice but to cross-port it to remove its uses of appcompat-v7.

CommonsWare
  • 910,778
  • 176
  • 2,215
  • 2,253