android apache poi-ooxml causes build error 'app:transformClassesWithDesugarForDebug' - android-gradle-plugin

I have a requirement in my app to implement excel creation and download. I have used Apache POI's HSSFWorkbook to implement the functionality. The app created the required excel (xls) output successfully.
However if I include apache:poi-ooxml in gradle and use XSSFWorkbook to create xlsx file for the same, I am getting the following error:
D:\USERS\PATH_TO_PROJECT>gradlew build
Configure project :app
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
Task :app:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Exception in thread "main" java.lang.IllegalStateException: Expect only the fields in this interface to be initialized. owner=org/apache/xmlbeans/impl/xb/ltgfmt/Code$1, expected=org/apache
/xmlbeans/impl/xb/ltgfmt/Code
at com.google.common.base.Preconditions.checkState(Preconditions.java:721)
at com.google.devtools.build.android.desugar.InterfaceDesugaring$InterfaceFieldWriteCollector.visitFieldInsn(InterfaceDesugaring.java:260)
at org.objectweb.asm.MethodVisitor.visitFieldInsn(Unknown Source)
at org.objectweb.asm.tree.FieldInsnNode.accept(Unknown Source)
at org.objectweb.asm.tree.InsnList.accept(Unknown Source)
at org.objectweb.asm.tree.MethodNode.accept(Unknown Source)
at com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.visitEnd(LambdaDesugaring.java:383)
at org.objectweb.asm.MethodVisitor.visitEnd(Unknown Source)
at org.objectweb.asm.MethodVisitor.visitEnd(Unknown Source)
at org.objectweb.asm.ClassReader.b(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at com.google.devtools.build.android.desugar.Desugar.desugarClassesInInput(Desugar.java:401)
at com.google.devtools.build.android.desugar.Desugar.desugarOneInput(Desugar.java:326)
at com.google.devtools.build.android.desugar.Desugar.desugar(Desugar.java:280)
at com.google.devtools.build.android.desugar.Desugar.main(Desugar.java:583)
FAILURE: Build failed with an exception.
What went wrong:
Error:Execution failed for task ':app:transformClassesWithDesugarForDebug'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.google.devtools.build.android.desugar.Desugar with arguments {--input C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\org.apache.xmlbeans\xmlbeans\2.6.0\29e80d2dd51f9dcdef8f9ffaee0d4dc1c9bbfc87\xmlbeans-2.6.0.jar --output D:\USERS\PATH_TO_PROJECT\app\build\intermediates\transforms\desugar\debug\30.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\design-26.0.0.aar\88757c55175e8007a9a997cb5c307f06\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.0.0.aar\9b22a71aa7416871ab6c4351056e3163\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\constraint-layout-1.0.2.aar\3113031e47d9da0b206f8a6d5dc5ddb5\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\cardview-v7-26.0.0.aar\44a7b81392464ba1ca65bd40f2e71204\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\gridlayout-v7-26.0.0.aar\0d2a4abaa9e93e5e2ca39f668099f366\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\acra-4.9.2.aar\a95cb5a22663d0060239228bd98b8433\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\transition-26.0.0.aar\bf06e65e1453c6ecba1710c6d321fc23\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\adapters-1.3.1.aar\53fb1dbf25549b14049acaaa62d454b7\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\library-1.3.1.aar\54ece89f3ae5343b4010f6a6ec76b51c\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\support-v4-26.0.0.aar\30b6c2f5af04a368bb3ba3da5a12978e\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\recyclerview-v7-26.0.0.aar\ecbf0b20322f38889946e58312686426\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\com.google.code.gson\gson\2.8.0\c4ba5371a29ac9b2ad6129b1d39ea38750043eff\gson-2.8.0.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\com.annimon\stream\1.1.7\a71f0635ac38194d70094e53f6fd89e00a93c834\stream-1.1.7.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\org.apache.poi\poi-ooxml\3.16\76e20fe22404cc4da55ddfdaaaadee32bbfa3bdd\poi-ooxml-3.16.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\org.apache.poi\poi\3.16\ad21c123ee5d6b5b2a8f0d4ed23b3ffe6759a889\poi-3.16.jar --classpath_entry D:\android-studio-preview\gradle\m2repository\com\android\databinding\baseLibrary\3.0.0-beta1\baseLibrary-3.0.0-beta1.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\animated-vector-drawable-26.0.0.aar\e436cd2461e582de2e8dd0f296ecb608\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\support-vector-drawable-26.0.0.aar\0a153ef2b3a29b2746c4ade8c57868f8\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\support-fragment-26.0.0.aar\90abaab734f5b5dc1ebf43c2e1e6a5b7\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\support-core-ui-26.0.0.aar\0c1bca53056184d4f28ea1a21be505f5\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\support-media-compat-26.0.0.aar\912ee7959b738daba3efb4d6cb162083\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\support-core-utils-26.0.0.aar\8052717d55d9db1adc43a2838ce31976\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\support-compat-26.0.0.aar\69023f52457cfb4013657fbef040bfec\jars\classes.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\com.android.support\support-annotations\26.0.0\db09a97f4f0db8892c1a0111a4b966f97920d082\support-annotations-26.0.0.jar --classpath_entry D:\SOFTWARES\AndroidSDK\extras\m2repository\com\android\support\constraint\constraint-layout-solver\1.0.2\constraint-layout-solver-1.0.2.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\transforms-1\files-1.1\multidex-1.0.1.aar\f429f7a46c1e6dc7d9deaabf508265bf\jars\classes.jar --classpath_entry D:\SOFTWARES\android-studio-preview\gradle\m2repository\commons-codec\commons-codec\1.10\commons-codec-1.10.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\org.apache.commons\commons-collections4\4.1\a4cf4688fe1c7e3a63aa636cc96d013af537768e\commons-collections4-4.1.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\org.apache.poi\poi-ooxml-schemas\3.16\9828a49307fc6bebfd42185b677d88b6e4994c63\poi-ooxml-schemas-3.16.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\com.github.virtuald\curvesapi\1.04\3386abf821719bc89c7685f9eaafaf4a842f0199\curvesapi-1.04.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\org.apache.xmlbeans\xmlbeans\2.6.0\29e80d2dd51f9dcdef8f9ffaee0d4dc1c9bbfc87\xmlbeans-2.6.0.jar --classpath_entry C:\Users\USERNAME\.gradle\caches\modules-2\files-2.1\stax\stax-api\1.0.1\49c100caf72d658aca8e58bd74a4ba90fa2b0d70\stax-api-1.0.1.jar --classpath_entry D:\USERS\PATH_TO_PROJECT\app\build\intermediates\classes\debug --bootclasspath_entry D:\AndroidSDK\platforms\android-26\android.jar --bootclasspath_entry D:\AndroidSDK\platforms\android-26\optional\org.apache.http.legacy.jar --bootclasspath_entry D:\SOFTWARES\android-studio-preview\jre\jre\lib\resources.jar --bootclasspath_entry D:\android-studio-preview\jre\jre\lib\rt.jar --bootclasspath_entry D:\android-studio-preview\jre\jre\lib\jsse.jar --bootclasspath_entry D:\android-studio-preview\jre\jre\lib\jce.jar --bootclasspath_entry D:\android-studio-preview\jre\jre\lib\charsets.jar --min_sdk_version 16 --desugar_try_with_resources_if_needed --desugar_try_with_resources_omit_runtime_classes}
I have searched with 'app:transformClassesWithDesugarForDebug' as keyword, but all I get is solution 'app:transformClassesWithDexForDebug'.
Please provide link for solution and explain. I know that desugar transforms class files to desugared class files (to enable new features), as I read on Android docs here. I need to know what files are making these errors.
NOTE: I have even set the multiDexEnabled true in gradle, still same error. Please give me solution for this problem, also please see bold lines in the error stack, I think that is the clue to the answer but I am unable to find it. For time sake, I have used HSSFWorkbook(xls), but I need XSSFWorkbook to create xlsx file.
Thanks...

change your porject/build.gralde
compileOptions {
//sourceCompatibility JavaVersion.VERSION_1_8
//targetCompatibility JavaVersion.VERSION_1_8
}
rebuild .......ok,
I change this file. rebuild ......Compile apk successfully!
Hope it helps you

Related

Can't build an executable JAR using Compose Multiplatform

How do I create an executable JAR file using Compose Multiplatform? I create a JAR artifact from the jvmMain module, create it and get the following error:
Kotlin: [Internal Error] java.lang.IllegalStateException: The provided plugin androidx.compose.compiler.plugins.kotlin.ComposeComponentRegistrar is not compatible with this version of compiler
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerExtensionsFromPlugins$cli(KotlinCoreEnvironment.kt:663)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$ProjectEnvironment.registerExtensionsFromPlugins(KotlinCoreEnvironment.kt:169)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.configureProjectEnvironment(KotlinCoreEnvironment.kt:566)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:199)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:108)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:445)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createCoreEnvironment(K2JVMCompiler.kt:191)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:142)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:94)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:43)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1568)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:691)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:831)
Caused by: java.lang.AbstractMethodError: Receiver class androidx.compose.compiler.plugins.kotlin.ComposeComponentRegistrar does not define or inherit an implementation of the resolved method 'abstract void registerProjectComponents(com.intellij.mock.MockProject, org.jetbrains.kotlin.config.CompilerConfiguration)' of interface org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar.
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerExtensionsFromPlugins$cli(KotlinCoreEnvironment.kt:655)
... 29 more

How to create a custom Kotlin Inspection for Intellij Idea programmatically

I want to create a plugin for Intellij Idea which provides additional inspections for Kotlin language. Following the example from official documentation for creating inspections for Java, I ended up with following code, which is not working.
Here is the link to a repository with this project: https://bitbucket.org/magycbytes/kotlin-inspections/src/master/
Links to example I followed:
docummentation page: https://www.jetbrains.org/intellij/sdk/docs/tutorials/code_inspections.html
example project: https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples/comparing_references_inspection
This is the provider for inspections.
package com.magicbytes.kotlin.inspections;
import com.intellij.codeInspection.InspectionToolProvider;
import com.magicbytes.kotlin.inspections.ExampleInspection;
import org.jetbrains.annotations.NotNull;
public class ExampleProvider implements InspectionToolProvider {
#NotNull
#Override
public Class[] getInspectionClasses() {
return new Class[]{ExampleInspection.class};
}
}
This is the actual inspection subclass. For the sake of shortness it's doing nothing, but should be loaded. Note: I changed the superclass to AbstractKotlinInspection
package com.magicbytes.kotlin.inspections;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.idea.inspections.AbstractKotlinInspection;
public class ExampleInspection extends AbstractKotlinInspection {
#Nls
#NotNull
#Override
public String getDisplayName() {
return "Kotlin Test";
}
}
My buid.gradle file looks like this:
plugins {
id 'java'
id 'org.jetbrains.intellij' version '0.3.2'
}
group 'com.magicbytes'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
intellij {
version '2018.1.4'
plugins 'kotlin'
}
Mine plugin.xml looks like this:
<idea-plugin>
<id>com.magicbytes.kotlin.inspections</id>
<name>Plugin display name here</name>
<description></description>
<depends>org.jetbrains.kotlin</depends>
<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
<inspectionToolProvider implementation="com.magicbytes.kotlin.inspections.ExampleProvider"/>
</extensions>
<actions>
</actions>
</idea-plugin>
I did all the linking with plugin.xml file. But when I'm running I'm getting exception in testing IDE. Appreciate any insight. NOTE: I'm using runIde to debug the plugin.
Exception which I'm getting..
java.lang.ClassNotFoundException: ExampleProvider PluginClassLoader[com.magicbytes.kotlin.inspections, 1.0-SNAPSHOT] com.intellij.ide.plugins.cl.PluginClassLoader#6f989177
com.intellij.openapi.extensions.impl.PicoPluginExtensionInitializationException: java.lang.ClassNotFoundException: ExampleProvider PluginClassLoader[com.magicbytes.kotlin.inspections, 1.0-SNAPSHOT] com.intellij.ide.plugins.cl.PluginClassLoader#6f989177
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getComponentInstance(ExtensionComponentAdapter.java:96)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getExtension(ExtensionComponentAdapter.java:119)
at com.intellij.openapi.extensions.impl.ExtensionPointImpl.processAdapters(ExtensionPointImpl.java:246)
at com.intellij.openapi.extensions.impl.ExtensionPointImpl.getExtensions(ExtensionPointImpl.java:191)
at com.intellij.openapi.extensions.Extensions.getExtensions(Extensions.java:102)
at com.intellij.openapi.extensions.Extensions.getExtensions(Extensions.java:89)
at com.intellij.openapi.extensions.ExtensionPointName.getExtensions(ExtensionPointName.java:50)
at com.intellij.codeInspection.ex.InspectionToolRegistrar.ensureInitialized(InspectionToolRegistrar.java:54)
at com.intellij.codeInspection.ex.InspectionToolRegistrar.createTools(InspectionToolRegistrar.java:127)
at com.intellij.codeInspection.ex.InspectionSearchableOptionContributor.processOptions(InspectionSearchableOptionContributor.java:34)
at com.intellij.ide.ui.search.SearchableOptionPreloader.preload(SearchableOptionPreloader.java:49)
at com.intellij.openapi.application.Preloader.lambda$null$0(Preloader.java:74)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:543)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:488)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:94)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
at com.intellij.openapi.application.Preloader.lambda$initComponent$1(Preloader.java:72)
at com.intellij.util.concurrency.BoundedTaskExecutor$2.run(BoundedTaskExecutor.java:212)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: ExampleProvider PluginClassLoader[com.magicbytes.kotlin.inspections, 1.0-SNAPSHOT] com.intellij.ide.plugins.cl.PluginClassLoader#6f989177
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.loadImplementationClass(ExtensionComponentAdapter.java:161)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getComponentImplementation(ExtensionComponentAdapter.java:66)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getComponentInstance(ExtensionComponentAdapter.java:73)
... 21 more
Caused by: java.lang.ClassNotFoundException: ExampleProvider PluginClassLoader[com.magicbytes.kotlin.inspections, 1.0-SNAPSHOT] com.intellij.ide.plugins.cl.PluginClassLoader#6f989177
at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:63)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.loadImplementationClass(ExtensionComponentAdapter.java:158)
... 23 more
Caused by:
java.lang.RuntimeException: java.lang.ClassNotFoundException: ExampleProvider PluginClassLoader[com.magicbytes.kotlin.inspections, 1.0-SNAPSHOT] com.intellij.ide.plugins.cl.PluginClassLoader#6f989177
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.loadImplementationClass(ExtensionComponentAdapter.java:161)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getComponentImplementation(ExtensionComponentAdapter.java:66)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getComponentInstance(ExtensionComponentAdapter.java:73)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.getExtension(ExtensionComponentAdapter.java:119)
at com.intellij.openapi.extensions.impl.ExtensionPointImpl.processAdapters(ExtensionPointImpl.java:246)
at com.intellij.openapi.extensions.impl.ExtensionPointImpl.getExtensions(ExtensionPointImpl.java:191)
at com.intellij.openapi.extensions.Extensions.getExtensions(Extensions.java:102)
at com.intellij.openapi.extensions.Extensions.getExtensions(Extensions.java:89)
at com.intellij.openapi.extensions.ExtensionPointName.getExtensions(ExtensionPointName.java:50)
at com.intellij.codeInspection.ex.InspectionToolRegistrar.ensureInitialized(InspectionToolRegistrar.java:54)
at com.intellij.codeInspection.ex.InspectionToolRegistrar.createTools(InspectionToolRegistrar.java:127)
at com.intellij.codeInspection.ex.InspectionSearchableOptionContributor.processOptions(InspectionSearchableOptionContributor.java:34)
at com.intellij.ide.ui.search.SearchableOptionPreloader.preload(SearchableOptionPreloader.java:49)
at com.intellij.openapi.application.Preloader.lambda$null$0(Preloader.java:74)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:543)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:488)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:94)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
at com.intellij.openapi.application.Preloader.lambda$initComponent$1(Preloader.java:72)
at com.intellij.util.concurrency.BoundedTaskExecutor$2.run(BoundedTaskExecutor.java:212)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: ExampleProvider PluginClassLoader[com.magicbytes.kotlin.inspections, 1.0-SNAPSHOT] com.intellij.ide.plugins.cl.PluginClassLoader#6f989177
at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:63)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at com.intellij.openapi.extensions.impl.ExtensionComponentAdapter.loadImplementationClass(ExtensionComponentAdapter.java:158)
... 23 more
After I've imported your GitHub repo and built it locally I've found out that ./build/libs/kotlin.inspections-1.0-SNAPSHOT.jar includes META-INF only, but no classes. I suspect it's because your source code is located under ./src/main/src, not ./src/main/java as it's typical for Gradle projects, so it simply assumes you have no code at all.
After renaming that inner src directory into java the error changed to
class com.magicbytes.kotlin.inspections.ExampleInspection: group display name should be overridden or configured via XML class com.magicbytes.kotlin.inspections.ExampleInspection
java.lang.Throwable: class com.magicbytes.kotlin.inspections.ExampleInspection: group display name should be overridden or configured via XML class com.magicbytes.kotlin.inspections.ExampleInspection
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:123)
at com.intellij.codeInspection.InspectionProfileEntry.getGroupDisplayName(InspectionProfileEntry.java:230)
at com.intellij.codeInspection.InspectionProfileEntry.getGroupPath(InspectionProfileEntry.java:239)
at com.intellij.codeInspection.ex.InspectionToolWrapper.getGroupPath(InspectionToolWrapper.java:161)
at com.intellij.codeInspection.ex.InspectionSearchableOptionContributor.processOptions(InspectionSearchableOptionContributor.java:40)
at com.intellij.ide.ui.search.SearchableOptionPreloader.preload(SearchableOptionPreloader.java:49)
at com.intellij.openapi.application.Preloader.lambda$null$0(Preloader.java:74)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:580)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:525)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:85)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
at com.intellij.openapi.application.Preloader.lambda$initComponent$1(Preloader.java:72)
at com.intellij.util.concurrency.BoundedTaskExecutor$2.run(BoundedTaskExecutor.java:212)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
which is much better and looks like a separate problem with your code violating some contract.

java.lang.UnsupportedClassVersionError: org/jetbrains/kotlin/preloading/Preloader : Unsupported major.minor version 52.0 while compile kotlin

I am beginner in Kotlin. I am getting the following exception while doing following:
kotlinc sample.kt -include-runtime -d sample.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError:
org/jetbrains/kotlin/preloading/Preloader : Unsupported major.minor
version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
Code
fun main(args: Array<String>){
var a : Int
a = getLength("Hello")
println("length of word is $a")
}
fun getLength(word : Any) : Int? {
if (word !is String) return null
return word.length
}
And kotlin version is Kotlin version 1.2.21-release-88 (JRE 1.7.0_79-b15)
JDK version which was used to build sample.jar is built with java version newr than one which you're using to compile kotlin file.
You have 2 ways:
Rebuild sample jar with your current version of JDK
Update JDK on your computer and try compiling again
Install an updated JDK, Go to File > Project Structure. Select the newer JDK version.
Then you'll be ready to go.

Jackson + ProGuard: can't deserialize class that uses custom deserializer

My app uses Jackson. I got minimized builds mostly working with this configuration:
# don't obfuscate Jackson classes
-keep class com.fasterxml.** { *; }
# don't strip runtime annotations
-keepattributes RuntimeVisibleAnnotations
# keep members with Jackson annotations
-keepclassmembers public class * {
#com.fasterxml.jackson.annotation.JsonCreator *;
#com.fasterxml.jackson.annotation.JsonProperty *;
}
But minimized builds are still unable to deserialize one class that uses a custom deserializer, which in turn uses a factory. The factory, deserializer, and mapper are all produced by Dagger2. The error is:
com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class com.mycompany.myapp.c.y]: can not instantiate from JSON object (missing default constructor or creator, or perhaps need to add/enable type information?)
at [Source: N/A; line: -1, column: -1]
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(Unknown Source)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(Unknown Source)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(Unknown Source)
at com.fasterxml.jackson.databind.ObjectMapper._readValue(Unknown Source)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(Unknown Source)
at com.fasterxml.jackson.databind.ObjectMapper.treeToValue(Unknown Source)
at com.mycompany.myapp.c.x.a(Unknown Source)
at com.mycompany.myapp.c.x.a(Unknown Source)
at com.mycompany.myapp.c.x.deserialize(Unknown Source)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(Unknown Source)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(Unknown Source)
at com.mycompany.myapp.c.ag.d(Unknown Source)
at com.mycompany.myapp.c.ag.a(Unknown Source)
at com.mycompany.myapp.c.at.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4508)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
at dalvik.system.NativeStart.main(Native Method)
The error message suggests that my class lacks a default constructor, which indeed it does because instances are created by the custom deserializer using the factory. This works fine when I disable ProGuard. What do I need to do to make it work with ProGuard?
I accidentally discovered this handy troubleshooting technique:
-keepnames class * { *; }
This revealed the true culprit to be a private static nested class inside my custom deserializer. The solution was to remove public from the class specifier on this option:
-keepclassmembers class * {
#com.fasterxml.jackson.annotation.JsonCreator *;
#com.fasterxml.jackson.annotation.JsonProperty *;
}

Struts Action Invocation Framework for Struts 1.3

I'm trying to integration SAIF plugin to intercept my struts action. I learn from
http://struts.sourceforge.net/saif/index.html
I've write configuration like this:
struts-config.xml
<plug-in className="net.sf.struts.saif.SAIFPlugin">
<set-property property="interceptor-config" value="/WEB-INF/interceptor-config.xml" />
</plug-in>
interceptor-config.xml
<interceptor-config>
<interceptor name="componentInterceptor" type="net.sf.struts.saif.ComponentInterceptor"/>
<interceptor name="testInterceptor" type="net.sf.struts.saif.TestInterceptor"/>
<default-interceptors>
<interceptor name="componentInterceptor"/>
</default-interceptors>
<action type="org.apache.struts.webapp.example.EditRegistrationAction">
<interceptor name="testInterceptor"/>
</action>
</interceptor-config>
I got error like this:
javax.servlet.UnavailableException: Specified RequestProcessor not compatible with saif.
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:402)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3996)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4266)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
can you help me to solve this problem ?
Quoting this message from the struts users mailing list:
It's unlikely that SAIF would work
with the default S1.3 config since the
request processor is different--you
could try using the old request
processor if your application doesn't
rely on it.
AFAICT SAIF wouldn't work with
anything other than the standard (old)
request processor, but it might be
possible to hack it up so it would.
I haven't worked with the Struts Action Invocation Framework before but the exception message is familiar to me from Tiles. Tiles throws a message like this: Specified RequestProcessor not compatible with TilesRequestProcessor so I think that besides the familiarity of the message (in your case Specified RequestProcessor not compatible with saif) there is also a chance that the cause be the same.
Here is an article that fixes this on the Tiles plugin. Might help you.
When the Struts Servlet is initialized it does an init of all the plugins. The message should come from the init method of your plugin and if it is the same as Tiles then a test with Class.isAssignableFrom should be the cause.
EDIT: Looked up the source code for the SAIF plugin and found this in it:
protected void initRequestProcessorClass(ActionServlet servlet, ModuleConfig config) throws ServletException {
.........
.........
ControllerConfig ctrlConfig = config.getControllerConfig();
String configProcessorClassname = ctrlConfig.getProcessorClass();
.........
.........
// Check if specified request processor is compatible with saif.
try {
Class saifProcessorClass = SAIFRequestProcessor.class;
Class saifTilesProcessorClass = SAIFTilesRequestProcessor.class;
Class configProcessorClass = Class.forName(configProcessorClassname);
if (!saifProcessorClass.isAssignableFrom(configProcessorClass)
&& !saifTilesProcessorClass.isAssignableFrom(configProcessorClass)) {
String msg = "Specified RequestProcessor not compatible with saif.";
throw new ServletException(msg);
}
} catch (Exception ex) {
throw new ServletException(ex);
}
.........
.........
}
It seems to be the same as with Tiles plugin so the article that I indicated contains the answer.