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.
Related
I am a new developer in Android Studio,
My Problem is when building my app using Kotlin Class in MainActivity Class, the error gives me not exists.
MainActivity is Java Code.
Other Classes are some Kotlin and some Java.
The picture below shows the error:
image_url
C:\Users\ammar\AndroidStudioProjects\SPMBot\app\src\main\java\com\infinitytechno\spmbot\MainActivity.java:11: error: package com.infinitytechno.spmbot.background.services does not exist
import com.infinitytechno.spmbot.background.services.Actions;
^
package com.infinitytechno.spmbot.background.services does not exist
if com.infinitytechno.spmbot is your package name, check your project directory, make sure background and services is in the right order .
seems your project has some red error lines, fix them before build them.
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.
I am trying to make some changes to a legacy code of a plugin which was written using Java version 4. I am trying to extend a class from an imported package.
import org.eclipse.wst.xml.core.internal.document.XMLModelContext;
public class XMLModelContextForPma extends XMLModelContext
{
}
I'm quite new to plugin development. I couldn't figure out why the compiler shows
The type org.eclipse.wst.xml.core.internal.document.XMLModelContext is not visible error. Also, most of the codes in classes of this particular package are using .internal. packages which are giving Discouraged access warnings. I'm googled here and there and found it's because of non-standard/API classes.
But this is quite strange. I have the jar files in the build path but not sure what is wrong here.
I'm developing in Eclipse Juno, Mac OS X, Java 6
It looks like the class XMLModelContext is private or protected and in a different package.
If a class is declared as protected, you can only use it in other classes within the same package or any of it's sub packages.
Add that jar(org.eclipse.wst.xml.core.internal.document.XMLModelContext containing jar) to your project file path.
Here are the steps I have followed so far, with no luck. I am extremely new to Java projects so I suspect I may be missing something obvious.
Using Eclipse, I have created a simple Java project called TestSDK, created within that a package called com.test.testsdk, and within that the following class:
package com.test.testsdk;
public class TestClass {
public void TestMethod() {
}
}
This compiles without errors or warnings.
I then export this as a JAR file (TestSDK.jar) using Eclipse and the standard export options (export generated class files and resources, compress the contents of the JAR, generate manifest file). I have tried both sealing and not sealing the JAR which makes no difference.
I then create a new Android application project from File->New->Project in the Wizards list. This compiles and runs without warnings or errors on both the Android emulator and my test device (I get the hello world message).
I then add a reference to my TestSDK.jar file (using a variety of different methods as I will expand on shortly), import it into the main (and only) Android activity, and try to instantiate my TestClass and call TestMethod on it, like so:
package com.apptest.mobilesdktestapp;
import android.app.Activity;
import android.os.Bundle;
import com.test.testsdk.TestClass;
public class MobileSDKTestAppActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TestClass test = new TestClass();
test.TestMethod();
}
}
This compiles fine without warnings or errors. When trying to run it on the emulator or the device, however, I get the following error in my LogCat window:
AndroidRuntime Uncaught handler: thread main exiting due to uncaught exception
AndroidRuntime java.lang.NoClassDefFoundError: com.test.testsdk.TestClass
Searching the web for the NoClassDefFoundError results in a lot of suggestions on how to import the JAR file such that the class path is correct. As a result, I have tried all of the following methods of importing the JAR file:
"Add External JARs..." from the Libraries tab of Java Build Path in the project properties, followed by checking (or not checking, I tried both) the JAR in the Order and Export tab. Also tried moving the JAR to the top of the Order and Export list, which made no difference.
Creating a "libs" folder in the project, and adding the JAR there. I confirmed that the JAR is then also added to the "Android Dependencies" thing in the project list. Also tried right-clicking the JAR file and selecting Build Path->Add to Build Path which made no difference.
Moving the JAR into my Android Application project directory and doing "Add JARs..." instead of external JARs as in step 1, also all permutations of exporting or not and moving it to the top of the order list or not.
I have subsequently downloaded other 3rd party SDKs that are packaged as JAR files and included those in the very same Android application project, and those have all worked fine using any of the 3 methods above (I am able to instantiate classes from those SDKs and use them without error), which leads me to believe I am missing something or doing something wrong in my TestSDK project and/or class which is preventing it from being used in the Android Application project.
As I said, I am very new to Java, so I'm hoping it's something simple that I've overlooked. Any help or guidance would be appreciated.
If you are on R17 or higher version of the Android tools and ADT in Eclipse, then the first sentence of #2 is the correct answer; everything else listed in your question is unnecessary at best or harmful at worst.
I would recommend that you create a clean project, create the test activity, create the libs/ folder, copy the JAR into the libs/ folder, code to the JAR's API, compile, and run. If that works, then your original project still has stuff lingering around from your previous efforts that is causing you grief. If it fails, then something fairly strange is going on. The JAR itself is presumably fine, otherwise you would get compile errors.
I think I figured out what the issue was (or at least how to fix the issue, I'm still not 100% sure what I did)--
When I created the original TestSDK java project, I let it target the default JRE in the project creation dialog (jre7).
Checking the project properties of a new Android Application project, the Java Compiler section has "Compiler compliance level" set to 1.5. So, I tried recreating my TestSDK project again, but told it to use J2SE-1.5 as the execution environment instead of the defalut jre7.
After doing this, exporting the JAR and importing it to the Android project's libs directory, I am now able to instantiate the TestSDK classes and use them just fine without the NoClassDefFoundError exception.
Best guess is that the Android application was being compiled against an older version of the JRE than my TestSDK class (which I believe was targeting JavaSE-1.7), causing the issues. Matching the two versions up has solved it.
The problem is that the Eclipse compiler do not see any layout or ids, or even strings and values in res folder, though R class is generated well (I've opened it, but of course didn't change enything). So I've tried to Clean and Build project and even restart Eclipse, compare the ids - the problem is still Eclipse don't see anything from res.
What should I do? May be someone solved this yet?
The SDK generates resource classes in the root package of your project. So, if your root package is com.project, and you're trying to use it from some other package (which is or is not directly under the root package), you need to import com.project.R.
i think importing import android.R; you can't see any ids or layouts or strings
change it in import com.companyname.projectname.R;
Get package name from android manifest file.and import like import packageName.R;