xamarin Android App Error - android

I am starting with Xamarin with Visual Studio and created my simple first blank project but getting below error when adding an Android Layout
java.lang.UnsupportedClassVersionError: mono/android/AndroidDesignerHost : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: mono.android.AndroidDesignerHost. Program will exit.
Exception in thread "main"

Related

I have an error when im trying to compile an apk

I've been trying to make an apk and got the following error:
Error:Internal error: (java.lang.UnsupportedClassVersionError) org/jetbrains/jps/android/model/impl/JpsAndroidModelSerializerExtension : Unsupported major.minor version 52.0
java.lang.UnsupportedClassVersionError: org/jetbrains/jps/android/model/impl/JpsAndroidModelSerializerExtension : 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:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:274)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:363)
at java.util.ServiceLoader$1.next(ServiceLoader.java:445)
at com.intellij.util.containers.ContainerUtilRt.copy(ContainerUtilRt.java:179)
at com.intellij.util.containers.ContainerUtilRt.newArrayList(ContainerUtilRt.java:168)
at org.jetbrains.jps.plugin.impl.JpsPluginManagerImpl.loadExtensions(JpsPluginManagerImpl.java:18)
at org.jetbrains.jps.service.impl.JpsServiceManagerImpl.getExtensions(JpsServiceManagerImpl.java:59)
at org.jetbrains.jps.model.serialization.JpsModelSerializerExtension.getExtensions(JpsModelSerializerExtension.java:46)
at org.jetbrains.jps.model.serialization.library.JpsLibraryTableSerializer.getRootType(JpsLibraryTableSerializer.java:185)
at org.jetbrains.jps.model.serialization.library.JpsLibraryTableSerializer.loadLibrary(JpsLibraryTableSerializer.java:115)
at org.jetbrains.jps.model.serialization.library.JpsLibraryTableSerializer.loadLibrary(JpsLibraryTableSerializer.java:92)
at org.jetbrains.jps.model.serialization.library.JpsLibraryTableSerializer.loadLibraries(JpsLibraryTableSerializer.java:65)
at org.jetbrains.jps.model.serialization.JpsGlobalLoader$GlobalLibrariesSerializer.loadExtension(JpsGlobalLoader.java:128)
at org.jetbrains.jps.model.serialization.JpsGlobalLoader$GlobalLibrariesSerializer.loadExtension(JpsGlobalLoader.java:121)
at org.jetbrains.jps.model.serialization.JpsLoaderBase.loadComponents(JpsLoaderBase.java:61)
at org.jetbrains.jps.model.serialization.JpsGlobalLoader.loadGlobalComponents(JpsGlobalLoader.java:83)
at org.jetbrains.jps.model.serialization.JpsGlobalLoader.load(JpsGlobalLoader.java:73)
at org.jetbrains.jps.model.serialization.JpsGlobalLoader.loadGlobalSettings(JpsGlobalLoader.java:59)
at org.jetbrains.jps.model.serialization.impl.JpsSerializationManagerImpl.loadModel(JpsSerializationManagerImpl.java:38)
at org.jetbrains.jps.cmdline.JpsModelLoaderImpl.loadModel(JpsModelLoaderImpl.java:45)
at org.jetbrains.jps.cmdline.BuildRunner.load(BuildRunner.java:78)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:266)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:125)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:232)
at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:44)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Please help me to solve this issue.
This issue you might got due to following reasons:
You might using some library in your projects which are either compiled using newer java version or older java version which is not supported by your machines jvm.
It might be possible that your Android Studio is corrupted so reinstalled it.
If you are trying to read the serialize object, which is serialized using old java version of new java version, and not supported by the jvm.
Hopefully this will help you.
Cheers

AndroiStudio test fails with Class Not Found Exception

When I try to run my test it gives me this error
Exception in thread "main" java.lang.NoClassDefFoundError: junit/textui/ResultPrinter
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:260)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:116)
Caused by: java.lang.ClassNotFoundException: junit.textui.ResultPrinter
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)
Process finished with exit code 1
I tried most of solution that I could find online but nothing helped to fix and it gets really annoying. Any tips to fix that ?

Unable to start hierarchyviewer

I'm trying to view the hierarchy of my views from my android application. So I read about hierarchyviewer and I installed it sudo apt-get install androidsdk-hierarchyviewer
The problem is that when I type in the terminal hierarchyviwer I got the following error :
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jface/window/ApplicationWindow
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)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jface.window.ApplicationWindow
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)
... 13 more
I'm running Linux Mint version 17.1 x64. What thing should I check or what should I do in order to be able to start hierarchyviewer ?
You can find the hierarchyviewer inside the your Android SDK under the tools directory.

Gradle Error and java.lang.ClassNotFoundException

The first error I had was this:
Android Studio error installing Gradle
And when i fixed that i had a new error:
Internal error: (java.lang.ClassNotFoundException) org.slf4j.LoggerFactory
java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
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:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.gradle.tooling.internal.consumer.loader.DefaultToolingImplementationLoader.<clinit>(DefaultToolingImplementationLoader.java:45)
at org.gradle.tooling.internal.consumer.ConnectorServices$ConnectorServiceRegistry.createToolingImplementationLoader(ConnectorServices.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.gradle.internal.service.DefaultServiceRegistry.invoke(DefaultServiceRegistry.java:175)
at org.gradle.internal.service.DefaultServiceRegistry.access$300(DefaultServiceRegistry.java:47)
at org.gradle.internal.service.DefaultServiceRegistry$FactoryMethodService.create(DefaultServiceRegistry.java:336)
at org.gradle.internal.service.DefaultServiceRegistry$ManagedObjectProvider.getInstance(DefaultServiceRegistry.java:240)
at org.gradle.internal.service.DefaultServiceRegistry$SingletonService.getService(DefaultServiceRegistry.java:275)
at org.gradle.internal.service.DefaultServiceRegistry$OwnServices.getService(DefaultServiceRegistry.java:215)
at org.gradle.internal.service.DefaultServiceRegistry.doGet(DefaultServiceRegistry.java:145)
at org.gradle.internal.service.AbstractServiceRegistry.get(AbstractServiceRegistry.java:65)
at org.gradle.internal.service.SynchronizedServiceRegistry$1.create(SynchronizedServiceRegistry.java:38)
at org.gradle.internal.concurrent.Synchronizer.synchronize(Synchronizer.java:31)
at org.gradle.internal.service.SynchronizedServiceRegistry.get(SynchronizedServiceRegistry.java:36)
at org.gradle.tooling.internal.consumer.ConnectorServices.createConnector(ConnectorServices.java:36)
at org.gradle.tooling.GradleConnector.newConnector(GradleConnector.java:64)
at com.android.tools.idea.jps.builder.AndroidGradleBuilder.doBuild(AndroidGradleBuilder.java:266)
at com.android.tools.idea.jps.builder.AndroidGradleBuilder.build(AndroidGradleBuilder.java:136)
at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1051)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:792)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:823)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:755)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:576)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:339)
at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:180)
at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:129)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:220)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:112)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:132)
at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:41)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
PD: Sorryfor my bad english and the format of the question this is my first question.
I had the same java.lang.ClassNotFoundException exception, trying to include jsoup.
What helped me was opening the terminal, going to the root of the project and executing
gradle clean
gradle assemble

How to run the test project to test another application using JUnit?

I've got this peculiar issue while testing for an android project via a test project.
The test project runs on the emulator but does not run on the device. It shows the following error on the device:
"java.lang.NoClassDefFoundError: android/test/ActivityInstrumentationTestCase2
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
at o rg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: android.test.ActivityInstrumentationTestCase2
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
... 17 more"
Why do I get java.lang.NoClassDefFoundError: android/test/ActivityInstrumentationTestCase2?

Categories

Resources