Here is my directory structure within the "java" folder,
The problem is in my MainActivity file when I write.
import api.gitapi;
import model.gitmodel;
I get a warning message saying "Unused Import"
In my MainActivity file, I get an error on line,
gitapi git = restAdapter.create(gitapi.class);
and,
public void success(gitmodel gitmodel, Response response) {}
saying that the symbol gitapi and gitmodel cannot be resolved. I have tried "Invalidate caches/restart" but the problem still exists.
Any help is appreciated, thanks in advance!
PS: If it helps, I'm using this tutorial
You have placed the gitapi and gitmodel classes into a test source folder, meaning that they are available to be imported by other classes in the test folder, but not in the main folder (where your activity lives). Create those classes in the main source folder and your activity will be able to import and reference them.
just need to refract the classes into the package containing MainActivity.class and it might solve your problem and you will get the result what you want.
Related
I am attempting to generate a JavaDoc for my project. To do so, I use Tools > Generate JavaDoc. I check Whole Project and set the output directory. It starts to work then returns with
error: package android.content does not exist
import android.content.Context;
Along with a bunch of other package does not exist errors and
cannot access ViewGroup
public class MainMenu extends AppCompatActivity {
^
class file for android.view.ViewGroup not found
Thus far I haven't been able to find any sort of solution. My project builds and runs fine on both the emulator and actual devices. Any thoughts? Thanks!
I was able to find a work around. I loaded my project in intelliJ IDEA, and while it still showed those errors, it still was able to generate the javadoc that correctly contains all the classes and methods needed.
I have to write an extension code and am confused. Here's what I have:
import info.gridworld.actor.Bug
public class ZBug extends Bug
With the rest my code below that. I keep getting an error message saying that "the import info cannot be resolved" I'm not sure what I'm doing wrong
You are missing a semicolon at the very least:
import info.gridworld.actor.Bug;
Then, you may miss some of the dependencies.
Make sure that the info.gridworld.actor.Bug class or the JAR which contains it is in the project's build path.
If it is a Maven project, make sure to include the required <dependency>.
I have the following directory structure :
MessManagement is the parent directory.
Under that i have 3 directories :
student , messconvener,messmanager
The student directory contains the Student.java and Student.class files. The messconvener contains the MessConvener.java this requires the Student class as MessConvener is extended from Student itself.
How should i do the packaging of the classes....??
What i have tried so far.
Code :
This is Student.java
package MessManagement;
import java.sql.*;
public class Student
{
}
This is MessConvener.java
package MessManagement;
import MessManagement.student.Student;
public class MessConvener extends Student
{
}
But this does not seem to work.Error Meesage :
MessConvener.java:2: error: package MessManagement.student does not exist
import MessManagement.student.Student;
^
MessConvener.java:3: error: cannot find symbol
public class MessConvener extends Student
^
symbol: class Student
2 errors
The error you're getting makes sense. The Student class is located in MessManagement package not MessManagement.student package.
So either remove your import of Student in MessManagement or change the package name in Student to MessManagement.student.
For me, I got this error for a different reason and this was in a maven project. It began to occur after I made major changes to the classes and copied in a lot of new classes. There were no conflicting package names as in your case.
The solution was to do mvn clean.
After this, I didn't get that error anymore.
There are two possible reasons why this happens
Is the root of your directories included in the classpath? You need to specify when starting a java program. See the documentation on how to do that or this variant for unix.
Are your classes public? If you forget the public modifier, classes will have package visibility and cannot be accessed from other packages.
Oh well, nobody expects the spanish inquisition ... check your spelling carefully, including capitals.
I recently had this issue and it was because I had a class file in the same directory as the java file that I was compiling. You need to delete all .class files in that directory.
I deleted the out folder and the problem was solved
For me it happened after updating java to jdk_16.
it was solved after I changed the "misc.xml" file inside ".idea" folder.
changed languageLevel="JDK_15" to languageLevel="JDK_16".
In Intellij, try
Go to File
Invalidate Caches/Restart
You can choose only Invalidate and restart
See this answer
Well I guess I am literally 8 years late, but today I had this problem and I managed to solve it just re-writing the state of the class. Seems that if you comitted your project, pulling it back could make you have that problem, but writing again the "public" state of your class worked for me. I Hope it works for you guys. chrss.
I Have DataLayer and logicLayer as packages in my project. I want to delete the default package since I do not need it. But When I delete I got the following error.
Error: Could not find or load main class
How can I slove this problem?
Move your main class from the default package to any other package and then a simple refresh would solve the problem.
The problem is that the default packeg is contains a class which is empty but cause problem.As soon as I delete that class the package is delete automatically.
hi all
i use the javazoom.jl.player.Player package but it is says The import javazoom cannot be resolved. i am using eclipse and doing Android project. i clean the project still the same error is shown. please correct me.
If eclipse can't resolve a package fragment of an import statement, then it tells you (with that error), that there is no library on the classpath that contains a class from that package (or from a package whose name starts with the missing part).
An easy way for standard java/eclipse:
create a folder lib in your projects root directory (with the eclipse workbench!)
copy and paste the jar into that folder
right-click the copied jar and select "add to build path".
This should eliminate the compiler errors immediately.
(Previous part of the answer)
Taking the error message literally, it looks like you have a line of code like that:
import javazoom;
This would be wrong, because we don't import packages but classes from a package. To import all classes from the javazoom package, we'd say:
import javazoom.*;
You should download the .jar of jLayer ( http://www.javazoom.net/javalayer/sources.html )
And add into classpath in the way Andreas_D told you.