Apk build error - java

I am trying to build android apk for my application. I have successfully installed java jdk1.7.0_79, using these Instructions (in highest voted answer). My O.S. is Ubuntu 15.10.
When I build apk using both the Jdk (jdk1.7.0_79/80) I get same build error
:app:transformClassesWithDexForDebug
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : 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)
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/jdk1.7.0_79/bin/java'' finished with non-zero exit value 1
Note
1) I have updated jdk location after installing each jdk(by removing previously installed jdk), I have no problem in java installation.
2) I have previously resolved rendering error in layout which is also same as "Unsupported major.minor version 52.0" by unchecking Android API 23:N(preview).

Check if your build.gradle(Module:app) has compile
eg:
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'

Related

How to fix Unsupported major.minor version 52.0 Exception?

I have a spring boot REST API jar file which works perfectly fine when I run it in my local machine using eclipse IDE, however when I upload the jar file to my VPS server I get the following error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/springframework/boot/loader/JarLauncher : 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)
I changed the java version in my POM file from version 11 to java 8:
<properties>
<java.version>8</java.version>
</properties>
In the VPS server I could see that the available java versions are: java 7 (Version : 7u80) and java 8 (Version : 8u92 - 1.8.0_92-b14), however my JRE version is jre 1.8.0_201.
If I keep java 7 in the VPS server I get the exception mentioned above and if I remove java 7 from the VPS server, then I get the following error when trying to run the jar file from ssh using Putty:
[root#vps public_html]# java -jar SpringBootProject-0.0.1-SNAPSHOT.jar
-bash: java: command not found
[root#vps public_html]#
How do I fix this?

Travis CI: java.lang.UnsupportedClassVersionError

I am trying to setup CI for https://github.com/amCap1712/pljava using Travis. But it fails with following log:
find pljava-packaging -name \*.jar | sudo xargs java -jar
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/gjt/cuspy/JarX has
been compiled by a more recent version of the Java Runtime (class file version 53.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.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
The complete build log and travis config is available at https://travis-ci.org/github/amCap1712/pljava/builds/661687014 . I am using OpenJDK9 for this build but it fails for OpenJDK14 as well.
How to fix the error ?

Unity | Android - Failed to sign APK packag: Unsupported major.minor version 52.0

I am trying to build my apk in Unity (2017.3.0f3) but I get the error Unsupported major.minor version 52.0. I have read elsewhere that to fix this download Java JDK 8 and select the path. I have done this with different version of Java 8 and none of them are working. I have tried updating all my android SDK packages but Unity wont build on the latest SDK tools so I had to replace them with the Revision 25.2.5 (January 2017) tools as specified in the following unity answers page:
Unity Answer Page
I am at a loss now, any advice is appreciated. Thanks.
Current settings:
Error Log:
CommandInvokationFailure: Failed to sign APK package.
C:\Users\Jack\AppData\Local\Android\Sdk\build-tools\27.0.3\apksigner.bat sign --ks "E:/JRFApplications/Keystore/jrfapplications_2018.keystore" --ks-pass stdin --ks-key-alias "eggscapade" --key-pass stdin "E:\JRFApplications\Apps\Egg\Temp/StagingArea/Package.apk"
stderr[
java.lang.UnsupportedClassVersionError: com/android/apksigner/ApkSignerTool : 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 java.lang.ClassLoader.loadClass(ClassLoader.java:412)
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)
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Exception in thread "main"
]
stdout[
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.Command.RunWithStdin (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg, System.String[] input)
UnityEditor.Android.PostProcessor.Tasks.TasksCommon.Exec (System.String command, System.String args, System.String workingdir, System.String errorMsg, System.String[] stdin)
UnityEditor.Android.PostProcessor.Tasks.BuildAPK.SignPackage (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.Android.PostProcessor.Tasks.BuildAPK.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
Versions of JDK installed and tested without success:
I managed to solve this issue by changing the unity build system from internal to Gradle in the build settings

Java Exceptions error when trying to execute .jar on Debian Jessie

A teacher of mine created a program on java around 2005, he has always used MacOS. He sent the .jar to me and a classmate, both linux (me Debian 8 and him Ubuntu) and we can't execute the program because it returns a lot of exceptions.
At first I thought it could have been because the program was too old but my teacher can run it in his 1 year old updated mac perfectly fine.
Checked and Debian comes with OpenJDK as default. Havent installed anything, is there anything I should be installing for it to run?
PS: if I double click the .jar I can see the folders.
The exceptions are:
Exception in thread "main" java.lang.NoClassDefFoundError: org/jfree/chart/ChartPanel
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:803)
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 java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2625)
at java.lang.Class.getMethod0(Class.java:2866)
at java.lang.Class.getMethod(Class.java:1676)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: org.jfree.chart.ChartPanel
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
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)
... 18 more
I don't know anything about java so please if you can try to be as basic as you can. I am also new to Debian, so I really don't know if there's a package missing from the default installation.
Edit:
The MANIFEST.MF file is
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.6.0_24-b07-334-10M3326 (Apple Inc.)
Class-Path: lib/Jama-1.0.2-ed.jar lib/jfreechart-1.0.6.jar lib/ant.jar
lib/jcommon-1.0.10.jar
X-COMMENT: Main-Class will be added automatically by build
Main-Class: com.cmcweb.electronicstructure.CompleteDOSPlotter
You have to download JFreeChart.jar libary (http://www.java2s.com/Code/Jar/j/Downloadjfreechartjar.htm) because your teacher didn't include external classes in his jar file.
Put JFreeChart.jar into /your_linux_path/jre/lib/ext folder and after that it should works.
P.S. The same you have to do with Jama.jar and jcommon.jar
Make sure you have all jars with the version from the manifest file downloaded in a lib directory. Lib directory should be placed in the same directory as your jar, the names of dependency jars should be exactly the same as these from classpath in manifest.
So in your case, it may not work with the newest JFreeChart version. You need to find and download version 1.0.6

flink: scala version conflict?

Am attempting to compile the kafka sample from here in IntelliJ. After much fussing with dependencies have run into this issue that I can't seem to get past:
15/10/25 12:36:34 ERROR actor.ActorSystemImpl: Uncaught fatal error from thread [flink-akka.actor.default-dispatcher-4] shutting down ActorSystem [flink]
java.lang.NoClassDefFoundError: scala/runtime/AbstractPartialFunction$mcVL$sp
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.apache.flink.runtime.jobmanager.MemoryArchivist.handleMessage(MemoryArchivist.scala:80)
at org.apache.flink.runtime.FlinkActor$class.receive(FlinkActor.scala:32)
at org.apache.flink.runtime.jobmanager.MemoryArchivist.org$apache$flink$runtime$LogMessages$$super$receive(MemoryArchivist.scala:59)
at org.apache.flink.runtime.LogMessages$class.receive(LogMessages.scala:26)
at org.apache.flink.runtime.jobmanager.MemoryArchivist.receive(MemoryArchivist.scala:59)
at akka.actor.ActorCell.newActor(ActorCell.scala:567)
at akka.actor.ActorCell.create(ActorCell.scala:587)
at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:460)
at akka.actor.ActorCell.systemInvoke(ActorCell.scala:482)
at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:282)
at akka.dispatch.Mailbox.run(Mailbox.scala:223)
at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.lang.ClassNotFoundException: scala.runtime.AbstractPartialFunction$mcVL$sp
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 28 more
I've run across a few notions that suggest this is an issue with the scala version. Current library list:
flink-runtime-1.0-SNAPSHOT
flink-streaming-java-1.0-SNAPSHOT
flink-connector-kafka-1.0-SNAPSHOT
flink-java8-1.0-SNAPSHOT
flink-core-1.0-SNAPSHOT
flink-java-1.0-SNAPSHOT
org.apache.hadoop:hadoop-core:1.2.1
flink-clients-1.0-SNAPSHOT
org.apache.kafka:kafka-clients:0.8.2.2
org.apache.kafka:kafka_2.11:0.8.2.2
flink-optimizer-1.0-SNAPSHOT
org.apache.sling:org.apache.sling.commons.json:2.0.6
de.javakaffee:kryo-serializers:0.28
com.github.scopt:scopt_2.11:3.3.0
org.clapper:grizzled-slf4j_2.9.0:0.6.6
com.typesafe.akka:akka-osgi_2.11:2.4.0
com.typesafe.akka:akka-slf4j_2.11:2.4.0
Suggestions on where I've run astray?
The problem is indeed a Scala version mismatch. You're mixing dependencies which are built for Scala 2.11, e.g. org.apache.kafka:kafka_2.11:0.8.2.2 with Flink dependencies which are built by default for Scala 2.10.
One of the dependencies built for Scala 2.11 pulls in the scala-library:2.11 jar which replaces the scala-library:2.10 dependency required by the Flink dependencies. You either use the binaries built for Scala 2.10 for the non-Flink dependencies or you build and install Flink using Scala 2.11. See https://ci.apache.org/projects/flink/flink-docs-master/setup/building.html#build-flink-for-a-specific-scala-version for how to build Flink with different Scala version.
Kafka example
If you just want to bump the version of the referenced Kafka example to 0.10-SNAPSHOT you have to change the Flink version in the pom.xml file and you have to use the FlinkKafkaProducer instead of the KafkaSink in the WriteIntoKafka.java file. You don't need the SimpleStringSchema then anymore. That is all you have to change (no additional dependencies are required).

Categories

Resources