Skip to content

Android Studio Errors

Li-Wei Yap edited this page Feb 10, 2022 · 5 revisions

Errors encountered whilst building with Android Studio

Cannot find styleable in class that implements Checkable

java.lang.NoClassDefFoundError: com/liweiyap/narradir/R$styleable
	at com.liweiyap.narradir.utils.CheckableObserverImageButton.setDrawables(CheckableObserverImageButton.java:54)
	at com.liweiyap.narradir.utils.CheckableObserverImageButton.<init>(CheckableObserverImageButton.java:27)
	at sun.reflect.GeneratedConstructorAccessor110.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:413)
	at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:203)
	at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:161)
	at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:309)
	at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:417)
	at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:428)
	at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:332)
	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
	at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1123)
	at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
	at android.view.LayoutInflater.rInflate(LayoutInflater.java:1097)
	at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:501)
	at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:328)
	at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:373)
	at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:141)
	at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:713)
	at com.android.tools.idea.rendering.RenderTask.lambda$inflate$6(RenderTask.java:844)
	at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
  1. Toggle issue panel (exclamation mark at top right corner of preview) and select Clear cache.
  2. If this doesn't solve the issue, delete and reclone repo.

Can't find service: package''

Installation did not succeed.
The application could not be installed.

List of apks:
[0] '/Users/leewayleaf/Documents/Repositories/narradir-android/app/build/outputs/apk/debug/app-debug.apk'
Installation failed due to: ''cmd package install-create -r -t --user current --full --dont-kill -S 24118986' returns error 'Unknown failure: cmd: Can't find service: package''
  1. Follow the instructions here. If cold boot does not work, just delete and reinstall the emulator.
  2. To make sure that there is only one instance of the emulator running, I find it helpful to not run the emulator in a tool window within Android Studio but as a "separate" window itself (i.e. the checkbox in Preferences > Tools > Emulator should be unchecked).

Can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [app/build/intermediates/app_classes/release/classes.jar:META-INF/MANIFEST.MF])

  • Linked to this error (which occurs for all 4 ABIs):
Unable to extract native debug metadata from /Users/liweiyap/Documents/Repositories/narradir-android/app/build/intermediates/merged_native_libs/release/out/lib/armeabi-v7a/libsupportjni.so because unable to locate the objcopy executable for the armeabi-v7a ABI.

I followed the instructions here and here, but I wasn't sure how to link the AndroidManifest file with custom_rules.xml.

In the end, I just deleted and recloned the entire repo.

Interestingly, this occurred only on my old device (Android 7), and not on my new one (Android 11).

Emulator skin not showing

  1. View > Tool Windows > Emulator
  2. Preferences > Tools > Emulator > check the box for "Launch in a tool window"

Including emulator skin / device frame in screenshot