How do I "use a Theme.AppCompat theme"?

63 views
Skip to first unread message

Rodney McKay

unread,
May 9, 2023, 1:45:17 PM5/9/23
to Android CameraX Discussion Group
I'm just getting started with Kotlin, and trying to follow this tutorial

But it doesn't work.  I'm getting the following error (along with many others, but this is the first one and appears to be the cause of the others).

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

Adding "import androidx.appcompat" to MainActivity did not solve the problem, just caused a different error.

Rodney McKay

unread,
May 9, 2023, 8:28:23 PM5/9/23
to Android CameraX Discussion Group, Rodney McKay
The solution is, instead of 
  1. In Android Studio, create a new project, and select Empty Activity when prompted.
do
       1.  In Android Studio, create a new project, and select Empty _View_ Activity when prompted.

As of Android Studio Flamingo, starting the project as an "Empty Activity" will not create the file activity_main.xml in the location where this tutorial expects it.

Also, in "MainActivity.kt," make sure the import statement
"import com.example.cameraxapp.databinding.ActivityMainBinding"

does not include "android" in it.

Rodney McKay

unread,
May 9, 2023, 8:29:48 PM5/9/23
to Android CameraX Discussion Group, Rodney McKay
[SOLVED]
Reply all
Reply to author
Forward
0 new messages