A release build in Android Studio can stop with ZoomableImageView must extend android.app.Activity [Instantiatable]. The usual cause is that a custom View has accidentally been declared as an <activity> in AndroidManifest.xml. This guide explains the diagnostic, the correct fix, alternatives, and verification steps.
Representative error log
Lint found fatal errors while assembling a release target.
AndroidManifest.xml:54: Error: This class should provide a default constructor
(a public constructor with no arguments)
(jp.co.joker.kazuki.dangerous.substance.lite.ZoomableImageView)
[Instantiatable]
android:name=".ZoomableImageView"
~~~~~~~~~~~~~~~~~~
Error: ZoomableImageView must extend android.app.Activity [Instantiatable]
Cause
Declaring <activity android:name=".ZoomableImageView"> tells Android that ZoomableImageView is an Activity component. If the class actually extends View or AppCompatImageView, it is not a subclass of android.app.Activity. The Instantiatable lint check verifies that manifest components can be instantiated by the framework, so one incorrect declaration can produce both the Activity-superclass diagnostic and a constructor diagnostic.
This is a mismatch between the manifest declaration and the class type, not a confirmed Android Studio or Android Gradle Plugin version bug. There is therefore no applicable “fixed version”; the manifest entry must be corrected.
When it occurs
- The custom class extends
View,ImageView,AppCompatImageView, or another View class. - The class is named in an
<activity>element inAndroidManifest.xml. lintReleaseorassembleReleasetreats fatal lint findings as build failures.- The declaration may also arrive through a product flavor, another source set, or manifest merging from a dependency.
Recommended fix
1. Remove the incorrect Activity declaration
Delete a manifest entry like this:
<activity
android:name=".ZoomableImageView"
android:exported="false" />
2. Use the custom View in a layout
Reference the fully qualified class name as an XML element:
<jp.co.joker.kazuki.dangerous.substance.lite.ZoomableImageView
android:id="@+id/zoomableImageView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
3. Provide constructors appropriate for XML inflation
A custom View used from XML should accept both Context and AttributeSet.
class ZoomableImageView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : AppCompatImageView(context, attrs, defStyleAttr)
Do not keep the incorrect manifest declaration and merely add a no-argument constructor. That does not correct the component-type mismatch.
4. Create a separate Activity if the destination must be launchable
class ZoomableImageActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_zoomable_image)
}
}
Register that Activity—not the View—in the manifest:
<activity
android:name=".ZoomableImageActivity"
android:exported="false" />
Alternatives
You can instantiate the View programmatically with code such as ZoomableImageView(context). If the bad entry comes from another source set or a library, use Android Studio’s Merged Manifest view to identify its origin and fix the source manifest where possible. A manifest-merger removal rule is a last resort and must be checked carefully so that it does not remove a legitimate Activity.
How to verify the fix
- Open Merged Manifest and confirm that
ZoomableImageViewno longer appears under an<activity>element. - Open the layout containing the View and confirm that XML inflation succeeds.
- Run the release lint and build tasks again:
./gradlew lintRelease assembleRelease
Cautions
- Do not make the custom View extend Activity just to satisfy the message. Views and Activities have different roles and lifecycles.
- Do not hide this configuration error with
@SuppressLint("Instantiatable")or a lint baseline. - If only the release variant fails, inspect the Merged Manifest for that exact variant.
- Check for stale manifest entries left behind after a class rename.
Summary
ZoomableImageView must extend android.app.Activity [Instantiatable] usually means that a custom View was registered as an Activity. Remove the View from <activity>, use it in XML or code, and create a separate Activity when a launchable screen is required. Finish by checking the merged manifest and running lintRelease assembleRelease.
