I am new to Android development so I apologize for anything I forget to clarify. I am working on a group project in Android studio, checked out from Git. I previously was able to build the project fine, but after a recent pull I suddenly have many compilation errors coming from the package
projectname\tess two\jni\com_googlecode_tesseract_android\src\java\com\google
It seems that I have a big mess of unresolved symbols, like "cannot resolve symbol (piccolo2d, Color, event, swing), which appear at import statements like these at the top of my classes underneath this project
import org.piccolo2d.*;
import java.awt.Color;
import java.awt.event.*;
import javax.swing.Timer;
I am wondering what might cause these unresolved symbols. I have tried deleting the project and re-pulling it from Git, re-building the project, etc.
Any help or direction would be great, I realize I did not give a lot of context, mostly because I myself am confused at where these problems could suddenly come from.
Anything related to awt or swing will inevitably fail; those toolkits are not available on Android. Someone or something is accidentally importing symbols from the wrong place. It's probably android.graphics.Color you want instead of java.awt.Color, etc.
I suspect that if you delete those imports, and then select Optimize Imports from the Code menu in Android Studio, the correct symbols will be imported.
Related
I have been using Eclipse for about 6 months now, and I noticed that I rarely can import someone else's project into Eclipse. I get so many errors in many files. For example, I tried to import a friend's project that I know works just fine, but I get a lot of "R" errors, like Eclipse can't recognize "R" as a field, and then other weird ones like ActionBarActivity is not recognized or an entire imports like android.support.v4.app.Fragment that visually are in the library but are not being recognized by Eclipse as being there, and I check them and they are definitely marked "Is library" and added properly to the project. Anyone know why this is or how to fix? It's frustrating because to learn, sometimes you need to see someone else's app run first, then look at their code, but you can't. Thanks in advance.
My usual way of importing a project is to do File -> Import -> General -> Existing Projects into Workspace. Also, I have tried cleaning the project, but it doesn't work.
try this File -> Import -> Android -> Existing Android Code into WorkSpace ->then browse-> select your project->make sure the checkBox"copy the project into workSpace" is marked
Check your Build Path. In the Android Section, try using some other API level click on Apply and after your project finishes with the building workspace, again revert back to the original API and click on OK.
Also check for any Build Path errors.
So thanks to the help of everyone of this post, and others on another post, the problem was finally fixed and took several steps.
Turns out that the ActionBarActivity error had a quick fix (hover over it, you get quick fix options) of importing the appcompat_v7 library. I never chose that before, because I thought it was already installed, hence the conflict with android-support-v4.jar (meaning there were doubles of that library), but I chose to import it anyway and that error went away.
But I discovered that android-support-v4.jar was actually a component of appcompat_v7, so that was causing the "Jar mismatch!" error in the console. So I deleted android-support-v4.jar from the libs folder, and the jar mismatch went away.
Lastly, my layout files were all not being recognized, even though I knew the variable names were all correct. So the error was from when I tried to refresh my imports in the very beginning of the problem (using shift+command+O), thinking it was an import problem (which it was), but at that time, refreshing did nothing. BUT... Eclipse took away import com.laurengariepy.android.gridimagesearch.R; and replaced it with android.R;, which is what was causing all the layout errors. So once I put that com.laurengariepy.android.gridimagesearch.R; back, then all errors went away.
So the take-away to this story, is be careful with Eclipse version 22.6. The auto-import of the appcompat_v7 library will cause a lot of trouble when you try to import other people's projects, because they were likely not created in an IDE with appcompat_v7 already there.
I need to share an android project with another pc and still be able to edit it on both sides.
For some reason I can't get this to work. I have tried a lot of different combinations to import it and still be able to edit and push changes.
When I try to import the project into my workspace, there is a lot of errors like this:
the type java.lang.object cannot be resolved. it is indirectly referenced from required .class files
Then I tried importing the JRE System library (JRE 7)
After doing this I still get errors. for example this:
Activity cannot be resolved
Then I imported the Android library to the project (API 18). But after doing this, there is a red cross on the project, but not in any classes, files or like..
Therefore I tried to clean the project, which removed the "R.java" and gave me a bunch more errors.
I don't know exactly what I am doing wrong here so I hope someone can help me out.
What is the "right" way to import eclipse projects and still be able to edit and push/pull?
(Btw. I am using BitBucket and SourceTree and trying to import it into my eclipse workspace. )
Found out what was wrong.
By navigating to "Window > Show view > Problems", I found out that the necessary API wasn't available at that eclipse version. So I downloaded it the software and it worked.
I have an Android project in Eclipse that previously had one library imported, zbar. And now something peculiar happened when I added a second library, one which I put together myself. At first, the project wouldn't build because of android-support-v4 mismatch. So I updated the minSDK of my application project to reflect the one in my library. That seems to have worked.
Next, I wanted to make use of my new library, so I created an object of a type defined inside it, and thus had to import the code. What happened next was Eclipse started to complain about one of the imports to zbar.
import net.sourceforge.zbar.Symbol;
And what i don't understand is, it says "The import net cannot be resolved", and only the word "net" is underlined in red. As if it didn't see the period following "net". What's going on here?
I have tried removing the library and then adding it, as well as changing the minSDK version back. Nothing has worked so far.
edit: I think removing the android-support-v4 from my custom library solved this.
I'm trying to build Google's open-source Calendar app for Android (source here: https://github.com/android/platform_packages_apps_calendar), so that I may pick apart its code a little bit. When I import the freshly-cloned project into eclipse, I get a bunch of ____ cannot be resolved to a type errors. Looking closely at the types that aren't resolved, the root cause seems to be:
The import com.android.common cannot be resolved
The import com.android.ex cannot be resolved
I've been googling and I can't seem to figure out what's going on? I must be missing some library? I have everything in the Android SDK Manager installed, even the optional libraries. I've tried cleaning and fixing build path properties, etc. The errors remain.
Anyone have any idea what I can do to get this thing to compile?
I have managed to add almost all the required dependencies and now i got an almost-running version.
Kindly, check it out from here
You can also check the last commit, it contains all what i did to get this running version.
Have a nice day :)
IntelliJ is moaning if I don't have the following imports in my activities :
import com.jameselsey.apps.romandroid.R;
I've got several other apps which don't require an explicit import of the R file, however this one will not compile if I remove it, I get the following error :
\src\main\java\com\jameselsey\apps\romandroid\activity\RomanToArabicConverterActivity.java:[31,24] package R does not exist
Understandably there are various other questions on SO on how to resolve this (none of which appear to work for me), but my question is : Does it really matter? Is there any reason why I should be wildly concerned here, or just go ahead and import it?
Tripled checked all my config xml, can't find anything that would prevent R being regenerated, mvn clean install still failing...
I would go ahead and import it. I don't believe you should be concerned.
i wouldn't worry about it.
On a side note. If you want to regenerate R, you need to do a clean build after ensuring that there are no errors in the xmls.