How can I resolve the error “The minCompileSdk (31) specified in a dependency’s AAR metadata” in native Java or Kotlin? [duplicate]

This question already has answers here: Android app won’t build — The minCompileSdk (31) specified in a dependency’s androidx.work:work-runtime:2.7.0-beta01 (26 answers) Closed 8 months ago. The community reviewed whether to reopen this question last month and left it closed: Original close reason(s) were not resolved The error message: The minCompileSdk (31) specified in a dependency’s … Read more

Error inflating when extending a class

I’m trying to create a custom view GhostSurfaceCameraView that extends SurfaceView. Here’s my class definition file GhostSurfaceCameraView.java: public class GhostSurfaceCameraView extends SurfaceView implements SurfaceHolder.Callback { SurfaceHolder mHolder; Camera mCamera; GhostSurfaceCameraView(Context context) { super(context); // Install a SurfaceHolder.Callback so we get notified when the // underlying surface is created and destroyed. mHolder = getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); … Read more

Any reason to prefer getClass() over instanceof when generating .equals()?

I’m using Eclipse to generate .equals() and .hashCode(), and there is an option labeled “Use ‘instanceof’ to compare types”. The default is for this option to be unchecked and use .getClass() to compare types. Is there any reason I should prefer .getClass() over instanceof? Without using instanceof: if (obj == null) return false; if (getClass() … Read more

Returning null as an int permitted with ternary operator but not if statement

Let’s look at the simple Java code in the following snippet: public class Main { private int temp() { return true ? null : 0; // No compiler error – the compiler allows a return value of null // in a method signature that returns an int. } private int same() { if (true) { … Read more