My android application, built inside Eclipse, suddenly fails to build with dozens of errors. The most obvious are errors indicating that all the android imports cannot be resolved.
import android.os.Bundle;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
All of these are flagged as unresolvable. I've tried removing and re-adding the JRE System Library. I've tried cleaning and rebuilding. I've tried the "Quick fix" option to "Fix Project Setup..." but that simply responds with a dialog box that say...
"No proposals have been found to fix the unresolvable reference to 'android.app.Bundle'. Click here to manually configure the build path of project 'Silent Mode Toggle."
I'm new to Android development and this one has me completely stumped.
Thanks in advance for any help you can provide.
Rich
It seems that your eclipse-workspace (or at least your Project) is broken somehow.
Have you moved your android-sdk/Project recently? If it's not an Android Project anymore, try to look at Preferences->Android for a valid android sdk-location.
If this is correct, try to open a complete new Workspace, and import your sources with File->import->Android Project from existing Source.
If this still doesn't help, make a new android Project and copy the sources manually inside your Project from outside Eclipse. Re-open Eclipse after that, and make a Project->clean
What all the others said.
Specifically, I recommend you go to Project > Properties > Java Build Path > Libraries and make sure you have exactly one copy of android.jar referenced. (Sometimes you can get two if you're importing a project.) And that its path is correct.
Sometimes you can get the system to resolve this for you by clicking a different target SDK in Project > Properties > Android, then restoring your original selection.
right click on project->properties->android->select target name as "Android 4.4.2" --click ok
since DocumentsContract is added in API level 19
I just had the same problem after accepting a Java update--scores of build errors and android import not recognized. On checking the build path in Project=>Properties, I found that the check box for Android 4.3 had somehow gotten cleared. Checking it resolved all the import errors without my even having to restart the IDE or run a project clean.
try this in eclipse: Window - Preferences - Android - SDK Location and setup SDK path
This import android packages cannot be resolved is also occurs when your using some library and that library is not in the same path where your application is there, or if you are importing the library and not coping library to the workspace
May be you are using this checking :
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
}
To resolve this you need to import android.provider.DocumentsContract class.
To resolve this issue you'll need to set the build SDK version to 19 (4.4) or higher to have API level 19 symbols available while compiling.
First, use the SDK Manager to download API 19 if you don't have it yet.
Then, configure your project to use API 19:
In Android Studio: File -> Project Structure -> General Settings -> Project SDK.
In Eclipse ADT: Project Properties -> Android -> Project Build Target
I found this answer from here
Thanks .
RightClick on the Project > Properties > Android > Fix project properties
This solved it for me. easy.
To import android packages, ADT plugin of eclipse is required, only after this you
can add it in the java build path.
Go to your eclipse market and download the Android AD extension.
Related
Trying to create a android junit ui test.
I've installed on my mac android studio, from project structure added Library Dependency of junit4, then added Module Dependency of android and uiautomator.
Gradle took care of setting up dependencies.
I went ahead to ApplicationTest class, and added import clauses for junit ui automation:
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiScrollable;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
but I get an error Cannot resolve symbol 'UiObject'. It can't find these packages
What am I doing wrong?
I encountered the same issue.
Firstly, please make sure you are using new call tree
import android.support.test.uiautomator.UiObject
If you still face this issue, then try:
File > Invalidate cache / restart should resolve this issue
Good evening, everybody.
I'm trying to debug the In-App Billing project. The sourse which I use, is
https://github.com/blundell/SimpleInAppPurchaseV3
I'm facing the problem from time to time:
Suddenly the project in file Log.java gives two errors:
1. The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
The error shows near the first symbol of the file.
R.java cannit be resolved! And gen-folder doesn't recreate! No errors in xml-files.
IabHelper.java shows the error: The import com.android.vending.billing.IMarketBillingService cannot be resolved
So if delete com.android.vending.billing/IInAppBillingService.aidl file and recreate it (by copy-paste) nothing happens.
What am I doing wrong?
I think your problem is just the latest update of the SDK.
Test the following operations on two projects :
In the project properties (eclipse) -> java build path -> order and export make sure that all your jars in the libs folder are checked.
And "Android Tools -> Fix Project Properties"
And "Project -> Clean"
If your problem persists try this:
Remove your project
Close eclipse
Import your project again
I hope you have helped!
Try this one.
1) project properties-> java build path-> order and export
make sure you have checked true all files that I have listed below:
Android Private Libraries,
Android Dependencies,
your all jar and libraries you have added.
2) check your SDK manager you have updated all required versions for
--> Tools: SDK Tools, SDK platform tools, SDK build tools.
--> Android 4.2 or what ever you are using, Google Map and SDK Platform should be updated latest.
--> Extras: Google Play Services,Google play billing libraries
also make sure you have not imported wrong variables or any class.
Hope it will help you.
Simple solution.
Rename your package name from com.android.vending.billing to com.android.vending.billing2.
Refresh project.
And after that again rename to com.android.vending.billing. And it will work.
In Android Studio click "Make Project" after adding "IInAppBillingService.aidl" file to your project. Then Android Studio can import "IInAppBillingService" class after press Alt+Enter on IInAppBillingService class.
I tried to use Android-PullToRefresh in my project.
I am used to importing library by "File -> New -> Other... -> Android -> Android Project from Existing Code" in Eclipse, but this time, it said that "Select at least one project" when I choose the "library" folder in that project.
What is the correct way to import this library? Please help. Thanks!
If your workspace having the project with the same activity name as the activity in your library, this time also it will show select atleast one project. check if you work space contains any
If you are trying to import a library into Eclipse, then you may refer to this post Adding a library/JAR to an Eclipse Android project
If you are trying to import the project, then you select the entire project folder.
For some reason, after going through Phonegap's non-inclusive instructions (it doesn't even mention setting up ANT, or the headaches with Ant and JDK), this doesn't work at all:
package com.HealthTrustSoftware.AndroidTemplate3;
import android.app.Activity;
import android.os.Bundle;
import org.apache.cordova.*;
public class AndroidTemplate3 extends DroidGap
{
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
}
It gives 5 errors referencing the fact that org.apache.cordova can't be resolved. I'm entirely sure what to do at this point. Please help. This is after 3 hours of trying to get the sdk working and finally being able to open a project within eclipse. After following the steps on their documentation, I am left with a wasted 3 hours unless I can figure this out.
I just ran into the same problem. Following what was written in here, I finally made it work.
After you download cordova from phonegap github page, you will find cordova-2.2.0.jar and cordova-2.2.0.js in lib/android folder. After running "./create ...", copy cordova-2.2.0.jar into your projects libs folder and cordova-2.2.0.js into your www folder. Then import the project into eclipse and it should work.
I had to go to "Project -> Properties -> Android" and select a newer SDK (I selected the latest one available on the list) and than run the "Project -> Clean" as well.
In addition to copying cordova-2.2.0.jar from the phonegapp download to the libs folder of the project I had to manually add it to the projects libraries.
Procedure: Project -> properties -> Java Build Path -> Libraries -> Add JARs... Then select the libs from the project itself
Android studio: File -> Invalidate cache / Restart. Worked for me...
I initially got around this using one of the solutions posted above: about downloading the phonegap from github and pasting in the cordova-2.2.0.jar and cordova-2.2.0.js files into the generated directories.
After fiddling around with the path and environment variables these files are already in place (project/libs/cordova-2.2.0.jar and project/assets/www/cordova-2.2.0.js) now for me after running the "create" command on command line.
I am using the ANT that came bundled with Eclipse so my PATH variable includes:
C:\Program Files\Eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730\bin;
and I added an environment variable for ANT_HOME of:
C:\Program Files\Eclipse\plugins\org.apache.ant_1.8.3.v20120321-1730
I tested adding \bin or removing it to both the PATH and environment variable for ANT_HOME and this was the winning combination.
Run cordova -d build. If it says anything about "Unable to locate tools.jar", fix that. Then completely rebuild the application by running cordova platform rm android. Also remove the project from eclispe. Then recreate the app by running cordova platform add android + cordova build. Finally add the project in eclipse again.
org.apache.cordova should now be included and everything should be working.
Replace your header with some miner changes like bellow
import com.google.android.gcm.GCMRegistrar;
import org.apache.cordova.api.CallbackContext;
import org.apache.cordova.api.CordovaInterface;
import org.apache.cordova.api.CordovaPlugin;
Step 4 in the getting started guide is the only part specific to phonegap. The rest is setting up a general android development environment. Instead of eclipse classic, get the ADT bundle from http://developer.android.com/sdk/index.html - that includes a custom version of eclipse with most of the android stuff ready to go.
The default link to cordova-2.2.0.jar worked fine for me, though it did take a bit of effort to work out that if you want to use a custom build of cordova it needs to be set up as an android library dependency in project properties.
Download apache cordova jar and add it to lib folder and classpath.
I imported my current Android Project to Eclipse on my (Mac OS) device via SVN.
The code shows up alright, but Ecipse shows tons of errors (see screenshot) which do not appear on the device I first used - I am not very experienced with Eclipse but I guess some libraries were not imported?
I installed the current JRE(1.7), Eclipse, the Android plugin which also installed the current Android SDK (4.1).
Any clues?!
Place the sdk path in Window->Preference->android.
And then Click apply.
If you already do it. Then right click the project and goto Properties->android->select android version
Right click on Project -> Android Tools -> Fix Project Properties
Go to menu -> Project -> Clean
For that go to each java file import all required packages or try CTRL + SHIFT + O
then resolve all errors in RES folder.
Then it will generate R.java for you
then import yourpakagename.R; where ever required.
remove import android.R;
hope this will help you