IntelliJ Android Runtime Exception: ClassNotFound, Didn't find Class on path - java

Using IntelliJ 14.0.3, my Android project was working until I built the project few times after each other and BANG, it doesn't come up anymore and it throws an Runtime Exception:
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.rahil.ecat/com.rahil.activity.Activity_Main}:
java.lang.ClassNotFoundException: Didn't find class
"com.rahil.activity.Activity_Main" on path:
DexPathList[[zip file "/data/app/com.rahil.ecat-1.apk"],
nativeLibraryDirectories=[/data/app-lib/com.rahil.ecat-1,
/vendor/lib, /system/lib]]
I've searched SO and found some answers which weren't for IntelliJ and they are all for Eclipse and I'm quite confused how to fix this and it's driving me crazy.
Any ideas?

Ok I figured it out myself, using intellij 14.0.3 follow the below:
settings -> Build, Exclusion, Deployment -> Compiler -> Excludes
then you have to remove the excluded class from the list.
Note: The excluded classes have a little 'x' near their class icons.

Since ADT update to revision 22 (May 2013) you have to check "Android Private Libraries" check box in
Project -> Properties -> Java Build Path -> Order and Export in Eclipse for your older projects to get rid of this exception ...

Related

My Bukkit plugins has a plugin.yml but it gives this error [duplicate]

I am trying to create a Spigot plugin that allows players to use a compass to track other players. While exporting and running the server, I noticed that it was giving me an error:
[21:57:15 ERROR]: Could not load 'plugins\Manhunt.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:172) ~[patched_1.16.5.jar:git-Paper-683]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:148) ~[patched_1.16.5.jar:git-Paper-683]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:389) ~[patched_1.16.5.jar:git-Paper-683]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:252) ~[patched_1.16.5.jar:git-Paper-683]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1066) ~[patched_1.16.5.jar:git-Paper-683]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:290) ~[patched_1.16.5.jar:git-Paper-683]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_291]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
... 7 more
I have never seen this error before and I'm not sure how to fix it. I have made sure to export the .yml file while in Eclipse, but it still shows me this error.
The plugin.yml file is a required part of a SpigotMC plugin that defines some basic information about the plugin like its name and the version of the Spigot API that it uses. For example, here's one for a Minecraft plugin I'm currently working on.
The error you're getting comes from that file not getting bundled into the jar. As a result, when the Spigot server tries to load your plugin, it can't find the plugin.yml because it's literally not present in your compiled jar.
I recommend setting up a build system like Gradle or Maven that will handle the complexities of building the jar for you independent of the IDE you use.
Set up a SpigotMC plugin using Maven
Set up a SpigotMC plugin using Gradle
I personally use Gradle, so feel free to see how I implemented it in one of my plugins. If you'd prefer Maven, there are many examples available including the popular Multiverse-Core.
You need the plugin.yml to run your plugin. If you're using spigot or bukkit, you should make your plugin.yml inside the src folder, in there, you need to include a minimum of:
name: (plugin name, no spaces allowed in name)
author: (your name)
version: (your plugin version)
api-version: (use 1.14)
main: (your main class)
description: (optional description, otherwise delete this line)
then you can export or rebuild the jar
This is an example of what my plugin.yml looks like:
name: ThornsPlugin
version: 1.0
author: MOREORLESS
api-version: 1.14
main: com.MOREORLESS.plugin.plugin
description: MC Stuff
Learn more about Plugin.yml here: https://www.spigotmc.org/wiki/plugin-yml/

Eclipse java.lang.module.FindException and java.lang.ClassNotFoundException

I recently installed Eclipse 2020-06 and am using JDK 10.0.2. I wanted to test Eclipse using a simple Hello world program:
package eclispeTest;
public class eclipseTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Hello");
}
}
But I get the error: Error occurred during initialization of boot layer java.lang.module.FindException: Module eclispeTest not found
One quick fix I see for this to delete the module-info.java file but when I do this I get the error: Error: Could not find or load main class eclispeTest.eclipseTest Caused by: java.lang.ClassNotFoundException: eclispeTest.eclipseTest
I saw one potential fix that told me to go to "Check your project build-path and enable specific output folders for each folder. Go one by one though each source-folder of your project and set the output folder that maven would use."
from: Eclipse - java.lang.ClassNotFoundException
But I am new to Eclipse and have no idea what they are talking about.
I have also noticed that when I open the problems tab at the bottom of Eclipse there is one problem that is repeated about 8 times: Description Resource Path Location Type The project was not built due to "Failed to init ct.sym for C:\Program Files\Java\jre-10.0.2\lib\jrt-fs.jar". Fix the problem, then try refreshing this project and building it since it may be inconsistent eclispeTest Unknown Java Problem
Could someone help me figure out what I should try, with baby steps for how I should do it.
Thank you in advance.
PS in case it helps here is a picture of my Eclipse window after I try to run my code:
EDIT: I made a new java project and below is my java project cration window
(I still got the same error)
Fist of all, In order to work the line " System.out.println("Hello");"
you will require two classes
1)java.lang.System
2)java.io.PrintStream
using above two classes the code runs.you don't have to import these class,because JRE(Java Runtime Environment) automatically does for you.
If you are gettting this error
Error occurred during initialization of boot layer java.lang.module.FindException: Module eclispeTest not found
Which means You didn't setup your "Java project" properly with "JRE"
Let create new project to solve this problem
1)Open Eclipse IDE
2)click FILE (top left most)
3)New
4)java project
5)give you project name (make sure that- "use default location checkbox" clicked)
6)IN JRE section - select use an execution environment JRE(edition as required)
7)Then click finish
This would have solved your problem , go create a Class do your eclipseTest. This time it should work.
java project creation should look like this

Testing Java code with Groovy under Intellij: unable to resolve class GroovyTestCase

I need to write a short test for some Java code. I used CTRL+SHIFT+T to generate one with IntelliJ, and selected "Groovy JUnit" as the testing library, then wrote the following test:
package util
class FibonacciHeapTest extends GroovyTestCase {
FibonacciHeap<Integer> heap
void setUp() {
super.setUp()
heap = new FibonacciHeap<>()
}
void testAddInOrder() {
testForItems 1..1000
}
private void testForItems(Range<Integer> items) {
items.each {heap << it}
assertEquals heap.size, items.to
items.each {assertEquals heap.remove(), it}
}
}
However, when I right click on the test case in the project window, I don't get the "Run All Tests" option that I normally do with JUnit tests, and the compiler throws the following error:
Information:2/4/15 8:15 PM - Compilation completed with 2 errors and 0 warnings in 2 sec
/home/patrick/IdeaProjects/hackerrank/src/test/java/util/FibonacciHeapTest.groovy
Error:(3, 1) Groovyc: unable to resolve class util.FibonacciHeap
Error:(9, 1) Groovyc: unable to resolve class GroovyTestCase
Trying to import GroovyTestCase or FibonacciHeap manually causes the same error. IntelliJ does not add any import statements when I let autocomplete finish the names for me, like it usually would with Java code.
What am I doing wrong?
This worked for me :
Open Gradle window (on right side in my case)
Click on refresh button
Done
I had a similar problem with creating test classes in IntelliJ, and it was solved when creating a new directory outside of the com.company folder (where I had the class I wanted to test).
Create a new directory for the test classes on the same level as your src folder
Right click on your new test directory, and "Mark directory as" --> "Test Resources Root"
Now create a test class, which should automatically be added to your test directory.
Build -> Rebuild project in the IDE itself (as opposed to maven, in my case) did it for me.
In my case, what I did to resolve the issue was rather simple.
Close IntelliJ
Open the attached homepage...
Remove your project by clicking on the x then...
Click on Import Project, Navigate to the build.graddle file of your project and open.
That was it and all the Red highlightings disappeared.
maybe you need add groovy-all rather then groovy,such as :
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovy.version}</version>
</dependency>
You have to configure Groovy SDK first. See the screenshot
More detailed description in the official document: Configuring Global, Project and Module SDKs
As #sman591 pointed out in a comment, if you are getting the error:
groovyc: unable to resolve class groovy.util.GroovyTestCase
and you already have groovy as a dependency then you are probably just missing the junit dependency.
In IntelliJ IDEA I re-imported the project. It worked then.
I closed idea. I removed .idea folder in the project. And I imported the project.
Then I needed to set up Groovy, see previous answers, mark test directory as test source in all modules of my project.
I was selecting the root folder which had build.gradle file in it, but it didn't work.
Steps followed are similar to #Pila
close the project from intellij
remove .idea, log, out folders
go to intellij dashboard
import project from existing resources
select build.gradle file <-- this is important
now you should see all the tasks are getting build in the background, and once build is finished all red lines are gone.

Didn't find class on path: dexpathlist

Seriously, i don't know what to do to solve this problem.
My android project was working fine, until i needed to import a library with Maven. Since that, everything started to collapse.
What is happening: When i start my application, the following error appears on LogCat and android tells that my app stopped working. I've searched for this similar error here AND on the rest of the internet, but everything people did haven't worked for me.
Error:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.buscaserra/com.buscaserra.main.ActivitySplash}: java.lang.ClassNotFoundException: Didn't find class "com.buscaserra.main.ActivitySplash" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.example.buscaserra-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.buscaserra-2, /vendor/lib, /system/lib]]
Manifest and packages:
Build Path:
Same problem here.
What worked for me was adding android-support-v4.jar as a lib and making sure it was checked on Project properties -> Build Path -> Order & export.
It was mentioned here
I had the same problem when I moved the project folder from a Linux machine to a Mac.
What I did was:
Close the project
Remove the .iml file
Import the project using the "Create new project using existing code"
I am using IntelliJ.
Cheers.
I did the following steps to resolve the issue on Android Studio.
open file ./app/build.gradle
reduce compileSdkVersion (e.g. 22 -> 21)
click 'sync project with gradle file'
change back to the original compileSdkVersion (e.g. 22)
click 'sync project with gradle file'
recompile and it should work.
I have spent way to many hours on this stupid issue but finally got it resolved:
When creating a new project -> package name is causing this stupid dex issue to appear, must not be able to find the main activity during run time with whatever deployment assemply setup. Android Studio doesn't like some of my commonly used package names, I'm completely baffled..I think this is a pretty big bug haha
Given the following new project parameters:
Name: NotificationApp,
packageName: com.stores.business.notificationapp,
saveLocation: /home/me/AndroidStudioProjects/NotificationApp
I would get the following error:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.stores.business.notificationapp/com.stores.business.notificationapp.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.stores.business.notificationapp.MainActivity" on path: DexPathList[[zip file "/data/app/com.stores.business.notificationapp-2/base.apk"],nativeLibraryDirectories=[/data/app/com.cvs.stores.myapplication-2/lib/arm64, /vendor/lib64, /system/lib64]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
My Solution
I resolved it by changing the package name to:com.notificationapp, then File->invalidate caches/Restart..hope this helps someone else haha
Do you have any required projects on the build path? Can't tell from your screen shot but check your "Projects" tab. You may have inadvertently added a Project Library as a required project instead. Remove the project from the Projects tab and then project -> properties. Click Android, add the project as a library instead here...
Make sure that any compatibility lib jars that you're using in your main project (like android-support-v4.jar) are the same versions as those used in any of the projects that your main project references.
I had this same problem and what solved it was to copy and paste the android-support-v4.jar from another library project (that my main project was referencing) and pasting it into my main project's /libs folder.
I had the same issue.
Nothing had changed except Android studio and Gradle updated since I last compiled.
I took a look at the build options under Build>Edit Build Types and noticed that the one option that was different between my project that didn't run and the ones that did work was the Minify Enable option.
I set it to false and now everything works again.
I should understand the problem by just seeing "dex errors".But it took half day to fix the issue.
I fix this by following android developers page's instruction: https://developer.android.com/studio/build/multidex.html
First add this to my gradle.build:
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Then I extend my Application class (or declare the application class in AndroidManifest.xml or override attachBaseContext() function) as instructed by the MultiDexApplication class document on the page. This have fixed my problem.

Problems with MCP 9.03

I'm attempting to create a Minecraft mod using the 1.7.2 release of MCP, version 9.03. I may be doing the installation steps wrong, as when I complete the installation, open Eclipse and select the workspace, it gives me 7 errors that I have no idea how to solve. These are the errors:
Project 'Client' is missing required library: 'jars/libraries/org/lwjgl/lwjgl/lwjgl/2.9.0/lwjgl-2.9.0.jar'
Project 'Client' is missing required library: 'jars/libraries/org/lwjgl/lwjgl/lwjgl_util/2.9.0/lwjgl_util-2.9.0.jar'
Project 'Client' is missing required library: 'jars/libraries/org/lwjgl/lwjgl/lwjgl- platform/2.9.0/lwjgl-platform-2.9.0-natives-windows.jar'
Project 'Server' is missing required library: 'jars/minecraft_server.1.7.2.jar'
Project 'Client' is missing required library: 'jars/libraries/net/java/jinput/jinput-platform/2.0.5/jinput-platform-2.0.5-natives-windows.jar'
The project cannot be built until build path errors are resolved
The project cannot be built until build path errors are resolved
If I attempt to run without making any changes, this is the error that is displayed in the console:
Exception in thread "main" java.lang.NoClassDefFoundError: Start
Caused by: java.lang.ClassNotFoundException: Start
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
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)
Please help me out, I'm not using Forge as I plan to be making changes to base class files.
Open up eclipse and right click on the project "Client", go to build path, configure build path, click on all of the errored files and press remove. Then download the latest LWJGL (http://lwjgl.org/) and extract it to some folder, and import all of the jars. Next, get the natives for all platforms and put them in a new file called LWJGL-Natives.jar and import that as well.
Also, PLEASE do not do a base edit mod! It's bad practice, and will make your mod get little to no use. Try to use either the forge tweak utilities or the official one by mojang: https://github.com/Mojang/LegacyLauncher
Plus, you most likely can do whatever you want to do without ASM or base edits, so please try those before doing base edits.
For project "Server", remove the dependency for the broken resource. It will continue working fine.

Categories

Resources