8000 Plugin crashes on Android Studio 4.1 · Issue #19 · gilday/dark-mode-sync-plugin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

Plugin crashes on Android Studio 4.1 #19

Closed
drewhamilton opened this issue Jun 16, 2020 · 10 comments
Closed

Plugin crashes on Android Studio 4.1 #19

drewhamilton opened this issue Jun 16, 2020 · 10 comments
Assignees

Comments

@drewhamilton
Copy link

If I enable this plugin on Android Studio 4.1 beta 1, the plugin crashes immediately when the IDE is opened. Here's the stack:

Plugin 'com.github.gilday.darkmode' failed to initialize and will be disabled.  Please restart Android Studio.

java.lang.UnsupportedClassVersionError: com/github/gilday/darkmode/DarkModeSync has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:757)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:636)
    at com.intellij.util.lang.UrlClassLoader._defineClass(UrlClassLoader.java:380)
    at com.intellij.util.lang.UrlClassLoader.defineClass(UrlClassLoader.java:376)
    at com.intellij.util.lang.UrlClassLoader._findClass(UrlClassLoader.java:340)
    at com.intellij.ide.plugins.cl.PluginClassLoader.loadClassInsideSelf(PluginClassLoader.java:259)
    at com.intellij.ide.plugins.cl.PluginClassLoader.tryLoadingClass(PluginClassLoader.java:205)
    at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:113)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at com.intellij.serviceContainer.ComponentManagerImpl.registerComponent(ComponentManagerImpl.kt:288)
    at com.intellij.serviceContainer.ComponentManagerImpl.registerComponents(ComponentManagerImpl.kt:194)
    at com.intellij.serviceContainer.ComponentManagerImpl.registerComponents(ComponentManagerImpl.kt:157)
    at com.intellij.idea.ApplicationLoader$registerAppComponents$1.apply(ApplicationLoader.kt:93)
    at com.intellij.idea.ApplicationLoader$registerAppComponents$1.apply(ApplicationLoader.kt)
    at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:616)
    at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:591)
    at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488)
    at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1975)
    at com.intellij.idea.ApplicationLoader$initApplication$2.accept(ApplicationLoader.kt:379)
    at com.intellij.idea.ApplicationLoader$initApplication$2.accept(ApplicationLoader.kt)
    at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:774)
    at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:750)
    at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488)
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1609)
    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)

It works fine on Android Studio 4.0.

@gilday
Copy link
Owner
gilday commented Jul 30, 2020

Oh no. We upgraded the plugin build to use JDK 11, because JetBrains Platform now runs on Java 11 by default. It seems your Android Studio is configured to use Java 1.8.

I see that Android Studio 4.0.1 uses JetBrains Platform 2017.1.2 which runs on Java 1.8 and is fairly old. I'm surprised Android Studio allows the plugin to be installed at all, because the minimum supported platform version is 2020.1.

Downgrading the project to build with JDK 1.8 would be unfortunate but not that hard. I'm more worried about having to downgrade the platform all the way to 2017.1.2. I don't want to leave Android Studio users out of luck though. Let me look into the best way to handle this.

@gilday
Copy link
Owner
gilday commented Jul 30, 2020

I just installed the latest Android Studio then I installed the Dark Mode Sync plugin. If you open Android Studio's Troubleshooting Info window, you'll see that it is using Java 1.8 and it installs an old version of the plugin since the latest version is not yet supported by Android Studio's underlying platform.

=== About ===
Build version: Android Studio 4.0.1 Build #AI-193.6911.18.40.6626763 June 24, 2020
Java version: 1.8.0_242-release-1644-b3-6222593x86_64
Operating System: Mac OS X (10.15.6, x86_64)
JVM version: OpenJDK 64-Bit Server VM JetBrains s.r.o

=== System ===
Number of CPU: 8
Used memory: 160Mb 
Free memory: 87Mb 
Total memory: 247Mb 
Maximum available memory: 1237Mb

=== Displays ===
Displays: 
Display 0: 2880x1800; scale: 2.00

=== Plugins ===
Custom plugins: [macOS Dark Mode Sync (1.1.0)]
Disabled plugins:[]

I'm going to close this issue out, but I will consider changing the plugin so that it is compatible with the old versions of JetBrains Platform that Android Studio uses. As a former Android developer, it makes me sad that it doesn't work on Android Studio.

8000

@gilday gilday closed this as completed Jul 30, 2020
@gilday gilday self-assigned this Jul 30, 2020
@gilday gilday added the wontfix This will not be worked on label Jul 30, 2020
@drewhamilton
Copy link
Author

Hi! It looks like a slight misunderstanding; I filed this against Android Studio 4.1 (now at beta 5), not 4.0.1. The plugin is actually working fine for me on 4.0.1, because the plugin installer automatically keep Dark Mode Sync on version 1.1.0 for compatibility.

But version 4.1 (beta 5) is updated to a much newer version of IntelliJ I believe, so it allows updating Dark Mode Sync to 1.2.2, and then crashes as described previously.

=== About ===
Build version: Android Studio 4.1 Beta 5 Build #AI-201.8538.31.41.6692364, built on July 19, 2020
Runtime version: 1.8.0_242-release-1644-b3-6222593 x86_64
Operating System: macOS 10.15.5
JVM version: OpenJDK 64-Bit Server VM by JetBrains s.r.o

I notice that it still uses the same 1.8.0 runtime, so this is probably still the root of the problem.

@gilday
Copy link
Owner
gilday commented Aug 5, 2020

You may be able to workaround the issue by changing Android Studio's runtime to use a Java 11 runtime - see https://www.jetbrains.com/help/idea/switching-boot-jdk.html.

I would like to figure out if Android Studio 4.1 Beta 5 is expected to run on Java 1.8. IntelliJ removed support for a Java 1.8 runtime in version 2020.1. Based on that information, I thought it was safe to upgrade this project to target Java 11. I don't see anything in the release notes for Android Studio 4.1 beta that would indicate which version of IntelliJ platform it uses.

@gilday gilday removed the wontfix This will not be worked on label Aug 5, 2020
@gilday
Copy link
Owner
gilday commented Aug 5, 2020

I see now that Build #AI-201.8538.31.41.6692364 corresponds to a JetBrains Platform branch 201 build, where branch 201 corresponds to IntelliJ 2020.1. We know that IntelliJ 2020.1 no longer supports JetBrains Runtime 1.8, so what gives?

I'm going to reopen this issue. I might need to downgrade the build to use Java 1.8 again if there are 201 builds using Java 1.8 out there. Let me chat with JetBrains a bit and figure this out

@gilday gilday reopened this Aug 5, 2020
@gilday
Copy link
Owner
gilday commented Aug 6, 2020

I have some clarity from the JetBrains team

distributed with JBR11 =! doesn’t work with JBR8 anymore

So while IntelliJ distributes with JBR11, Android Studio still distributes with JBR8. I will downgrade the plugin build to target Java 1.8

gilday added a commit that referenced this issue Aug 6, 2020
IntelliJ Platform 2020.1 is distributed with JBR11, but it is still compatible with JBR8, so the plugin needs to target Java 1.8
@gilday
Copy link
Owner
gilday commented Aug 6, 2020

Fixed in 1.2.4

@gilday gilday closed this as completed Aug 6, 2020
@drewhamilton
Copy link
Author

The good news is that 1.2.5 works on Android Studio 4.2 Canary 8, which I understand is the first AS version to ship with Java 11. So when that goes stable around maybe the end of the year (total guess on my part) you can safely go back to Java 11.

The bad news is that 1.2.5 I still gives almost the same stacktrace as be 8000 fore on Android Studio 4.1 RC 1. Though the offending class name is different. Is it possible that some part of this is still compiled with Java 11?

java.lang.UnsupportedClassVersionError: com/github/gilday/darkmode/DarkModeSyncThemes has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:757)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:636)
    at com.intellij.util.lang.UrlClassLoader._defineClass(UrlClassLoader.java:380)
    at com.intellij.util.lang.UrlClassLoader.defineClass(UrlClassLoader.java:376)
    at com.intellij.util.lang.UrlClassLoader._findClass(UrlClassLoader.java:340)
    at com.intellij.ide.plugins.cl.PluginClassLoader.loadClassInsideSelf(PluginClassLoader.java:259)
    at com.intellij.ide.plugins.cl.PluginClassLoader.tryLoadingClass(PluginClassLoader.java:205)
    at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:113)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
    at com.github.gilday.darkmode.DarkModeSync.<init>(DarkModeSync.java:37)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.intellij.serviceContainer.ConstructorInjectionKt.instantiateUsingPicoContainer(constructorInjection.kt:53)
    at com.intellij.serviceContainer.ComponentManagerImpl.instantiateClassWithConstructorInjection(ComponentManagerImpl.kt:660)
    at com.intellij.serviceContainer.MyComponentAdapter.doCreateInstance(MyComponentAdapter.kt:35)
    at com.intellij.serviceContainer.BaseComponentAdapter.getInstanceUncached(BaseComponentAdapter.kt:115)
    at com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:69)
    at com.intellij.serviceContainer.BaseComponentAdapter.getInstance$default(BaseComponentAdapter.kt:62)
    at com.intellij.serviceContainer.ComponentManagerImpl.createComponents(ComponentManagerImpl.kt:261)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$loadComponents$5(ApplicationImpl.java:334)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:166)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:627)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:572)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:61)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:153)
    at com.intellij.openapi.application.impl.ApplicationImpl.loadComponents(ApplicationImpl.java:334)
    at com.intellij.idea.ApplicationLoader$startApp$6$loadComponentInEdtFuture$1.run(ApplicationLoader.kt:184)
    at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1640)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:201)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:831)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:310)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:80)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:128)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:46)
    at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:184)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764)
    at java.awt.EventQueue.access$500(EventQueue.java:98)
    at java.awt.EventQueue$3.run(EventQueue.java:715)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:734)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:416)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

@gilday
Copy link
Owner
gilday commented Sep 10, 2020

You're right - some classes are still targeting Java 11. I downloaded version 1.2.5 from the JetBrains plugin repository and found that there's a mix of Java 1.8 and Java 11 classes

$ find . -name '*.class' -exec javap -verbose {} \; | egrep '(Classfile|major)'
Classfile /Users/jgilday/Downloads/dark-mode-sync-plugin/lib/com/github/gilday/darkmode/DarkModeSync.class
  major version: 52
Classfile /Users/jgilday/Downloads/dark-mode-sync-plugin/lib/com/github/gilday/darkmode/DarkModeConfigurable$createPanel$renderer$1.class
  major version: 55
Classfile /Users/jgilday/Downloads/dark-mode-sync-plugin/lib/com/github/gilday/darkmode/DarkModeConfigurable$createPanel$$inlined$panel$lambda$2$1.class
  major version: 55
Classfile /Users/jgilday/Downloads/dark-mode-sync-plugin/lib/com/github/gilday/darkmode/DarkModeConfigurable$createPanel$$inlined$panel$lambda$1.class
  major version: 55
Classfile /Users/jgilday/Downloads/dark-mode-sync-plugin/lib/com/github/gilday/darkmode/DarkModeDetector.class
  major version: 52
Classfile /Users/jgilday/Downloads/dark-mode-sync-plugin/lib/com/github/gilday/darkmode/DarkModeSyncThemes$State.class
  major version: 55
Classfile /Users/jgilday/Downloads/dark-mode-sync-plugin/lib/com/github/gilday/darkmode/DarkModeConfigurable$createPanel$$inlined$panel$lambda$1$1.class
  major version: 55
Classfile /Users/jgilday/Downloads/dark-mode-sync-plugin/lib/com/github/gilday/darkmode/DarkModeConfigurable$createPanel$$inlined$panel$lambda$2.class
  major version: 55
Classfile /Users/jgilday/Downloads/dark-mode-sync-plugin/lib/com/github/gilday/darkmode/DarkModeConfigurable.class
  major version: 55
Classfile /Users/jgilday/Downloads/dark-mode-sync-plugin/lib/com/github/gilday/darkmode/DarkModeSyncThemes.class
  major version: 55
Classfile /Users/jgilday/Downloads/dark-mode-sync-plugin/lib/com/github/gilday/darkmode/DarkModeSyncThemes$Companion.class
  major version: 55

It looks like the Java classes are using 1.8, but the Kotlin classes are targeting Java 11. It looks like I missed a configuration in the Gradle build 🤦‍♂️

@gilday gilday reopened this Sep 10, 2020
@gilday
Copy link
Owner
gilday commented Sep 10, 2020

Fixed in 1.2.6

@gilday gilday closed this as completed Sep 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0