ImagePicker icon indicating copy to clipboard operation
ImagePicker copied to clipboard

Fatal crash when using with jetpack compose

Open dessalines opened this issue 2 years ago • 1 comments

Jetpack compose has the default mainactivity line:

class MainActivity : ComponentActivity() {, not AppCompatActivity.

    val ctx = LocalContext.current

            ImagePicker.with(ctx as Activity)
                .crop()	    			//Crop image(Optional), Check Customization for more option
                .compress(1024)			//Final image size will be less than 1 MB(Optional)
                .maxResultSize(1080, 1080)	//Final image resolution will be less than 1080 x 1080(Optional)
                .start()

Error:

2022-01-17 12:30:10.558 13966-13966/com.jerboa E/ThemeUtils: View class androidx.appcompat.widget.AppCompatImageView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
2022-01-17 12:30:10.570 13966-13966/com.jerboa E/ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
2022-01-17 12:30:10.575 13966-13966/com.jerboa E/ThemeUtils: View class androidx.appcompat.widget.AppCompatImageView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
2022-01-17 12:30:10.577 13966-13966/com.jerboa E/ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
2022-01-17 12:30:10.602 13966-13966/com.jerboa E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.jerboa, PID: 13966
    java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

dessalines avatar Jan 17 '22 17:01 dessalines

it happened to me too @dessalines.

Just change your parent theme on res/value/theme to Theme.AppCompat.Light.xxxxx and don't forget to add AppCompact Dependency to Gradle

kiratheone avatar Apr 07 '22 02:04 kiratheone