I've been working on my local windows system to develop an android app, all working fine in Eclipse. In order to implement some git versioning in a neat and tidy way alongside all my web-app based projects, I'm trying to move my project to a Linux box, accessible via a samba share over the local network. The samba all works fine.
Can someone guide me or point me to a guide to move a project which also includes class dependencies? Im fairly new to Android, Eclipse and Java so please forgive this novice. Thank you.
I've found this video-tutorial very helpful: http://www.youtube.com/watch?v=uVO0_UdQ_Wg
What I've done:
exported project (inc dependencies) as general archive file
Switched workspaces to the network drive.
Imported existing project from archive file
The errors I'm getting are:
SherlockActivity cannot be resolved to a type (SherlockActivity is a class dependency project)
Project has no project.properties file! Edit the project properties to set one.
Here is what I would do:
Keep Eclipse work space in local disk.
Copy Android project from Eclipse work space to Samba share (assuming the drive name is X), X:\repo\myproject.
Here, if necessary, delete Eclipse generated folders and files like bin, gen, .project, .settings.
Pull fresh copy of ActionBarSherlock to X:\repo\ActionBarSherlock.
Delete myproject and ActionBarSherlock from Eclipse (via Package Explorer), probably by checking "Delete project contents on disk (cannot be undone)" as I already have copies on Samba drive.
Create new "Android Project from Existing Code" and choose X:\repo\ActionBarSherlock\actionbarsherlock as a root directory.
Here, leave "Copy projects into workspace" unchecked.
Create another new "Android Project from Existing Code" and choose X:\repo\myproject as a root directory.
Here, again, leave "Copy projects into workspace" unchecked.
(Probably, myproject will fail to build with "SherlockActivity cannot be resolved to a type" error) Right click on myproject and choose "Properties" menu, go to "Android" tab and add actionbarsherlock from "Add library" field.
Related
I am currently following this tutorial on how to make a Minecraft mod. I have done everything that he has done, but when I open Eclipse and try to open the Minecraft project it give me an error saying:
'Open Project' has encountered a problem.
The project description file(.project) for 'Minecraft' is
missing. This file contains important information about
the project. The project will not function properly until
this file is restored.
How can I fix this error so I can make my mod?
Edit: Here is the errors that I am having...
You need to execute the command:
gradlew setupDecompWorkspace eclipse
from the commandline before you can use eclipse.
go to your start menu
type in cmd
then navigate in the command prompt to your folder where you extracted the mdk
then execute in that folder the abovementioned command.
Then open eclipse and point it to the working directory(eclipse in the mdk folder)
I'm not familiar with modding Minecraft, but from the information you've provided there are a few possible solutions. First you need to check if the .project file actually exists or if it is really missing. Go to the workspace folder as per the video and it should be in the root folder of the project in there.
If it does exist check that you have selected the correct folder for your workspace and the project. If these are wrong Eclipse might not know where to look to find the .project file.
If it does not exist you will need to create one in order to load the project. The easiest way to do this is:
Open Eclipse at the workspace specified in the video. I'm assuming here that you have already downloaded and extracted everything. I think the workspace is a folder named eclipse
Create a new project (File->New->Project). Don't try to open the broken project.
Navigate to the workspace in windows explorer. In here you will see a folder for the broken project and one for the new one you have just created.
Open the folder for the broken project and copy the entire contents.
Go back and open the folder for the new project. Paste everything here. Some things may be overwritten but there shouldn't be anything that causes a problem.
Go back to Eclipse and refresh the new project (Right click on project in left pane->Refresh)
You may want to rename the new project to have the same name as the old project. If you want to do that you'll have to delete the broken project.
Did you move the anything in the Eclipse project folder after creating it?
I used to teach modding to kids and this was the most common error. If you start moving things around without right-click -> Refactor -> Move then Eclipse will become confused and could cause this error.
Another error I'd often run into is if the kid was using a parent's machine and they did not have administrative permissions OR if the internet connection was particularly slow. This caused certain files to be lost when downloaded during those cmd line commands.
Here's how I set my project up assuming you're also on windows:
download forge src (looks like you're using 1.7.2)
extract the contents into an empty folder
point a cmd prompt to this location
run "gradlew setupDecompWorkspace" (will take a while, should exit with "BUILD SUCCESS")
run "gradlew eclipse" (will take a much shorter, should exit with "BUILD SUCCESS")
open eclipse and switch your workspace to the "eclipse/" directory in the same folder you extracted forge into. (e.g. C:\Users\ME\Desktop\FORGE_FOLDER\eclipse)
If follow these slowly and carefully there should not be any issues. If there is then that means you may not have admin privileges or may be on a restrictive internet connection.
Edit: the package declaration issue on line one is because in your project explorer it says src/main/java/com...etc when it should be src/main/java and then that contains the package starting with "com"
To do this, right-click src/main/java/com... -> Build Path -> "Remove from build path".
After this you must drop down src, drop down main, drop down java. right-click java -> Build Path -> "Use as source folder"
Edit: easy way to access cmd in right folder is to open the folder where you extracted Forge and click in the address bar at the top of file explorer and delete what's there, type "cmd" hit enter.
I checked the src folder (inside the same folder that I have my eclipse folder in) to make sure all the class files were there. There were none, in fact it looked completely different and out of sync from my project.
Is there some other folder or place where eclipse keeps my code ?
By the way, I use Mac. Also, don't think it should be a problem but I keep my eclipse application on a flash drive (the actual install location for eclipse is on my computer, though).
Right click on your code base in eclipse & select properties. In the properties tab you will find the disc location of your project.
When you first setup eclipse you are asked to choose a workspace. The workspace is where your code is saved. If you right click on your project and click properties, in the resource section there is a spot labeled Location: The file path there is where that project is saved. (It will be under your workspace folder)
I've spent all afternoon getting absolutely nowhere with this.
I've downloaded Eclipse, downloaded the SDK, installed the updates, but every new Android project I create something's wrong.
Firstly, it would not generate the R.java file, at all, now it does but there's a separate project it's created automatically called appcompat_v7. I don't know what this is, but it's causing problems with any other new project.
This is the error a normal project produces:
The container 'Android Dependencies' references non existing library '/home/omar/workspace/appcompat_v7/bin/appcompat_v7.jar'
I have absolutely no idea how to fix this. What is causing this?
EDIT
It appear this is only with KitKat, every other API platform doesn't produce ANY source files at all.... any idea how to combat this?
It's a support library which presumably your project refers to. You will need to build it as a library project in your workspace. This process is described here Support Library Setup under Adding libraries with resources.
You will find the project you need to copy in your SDK in the folder:
\yourSDKlocation\tools\android-sdk-windows4.4\extras\android\support\v7\appcompat
(It's no use just copying a jar, you must build it as a library project.)
I had this problem when I moved a project to a different laptop. I solved it like this:
If appcompat_v7 is not available in Eclipse:
From the File menu, choose New then Project.
Next, choose Android and Android Project from existing Code, then click next
Browse to find your appcompat_v7 project folder
Make sure there’s a check mark next it in the ‘Projects to Import’ list
If the appcompat_v7 project folder is not currently in your workspace, select ‘Copy projects into workspace’, then click Finish
Now that the library project is available in your workspace, it can be added to a project:
Choose your project from the Project Explorer and open the project properties (on a mac it’s in the Project menu)
Click on Android in the left list
Next to the Library list, click the Add button
Choose appcompat_v7 from the list
You should be good to go now.
My directory structure in the Project seems to have disappeared. The first picture is the "bad". I recently upgraded to 12.1 and the vim emulator at about the same time. I don't know if I missed a dialog that reset something? I can't figure out how to get it back like the second picture.
I've tried to re-import the project but it has not helped. I keep the project on Dropbox and have another PC where I have not reloaded project. Is there a way to get my view from that machine?
The picture is the "good" and how I want it to look.
I've come across this problem a few times myself. What happened is that intellij lost the module in my project settings. Here's my steps to fix it:
File -> Project Structure -> Click on modules (notice empty list) ->
Click on '+' -> Click on import module -> Find existing myProj.iml
I also have quite a few IntelliJ projects and also git folders of text files. I found IntelliJ does not always reconstruct the .idea files correctly. However the following methods work for me.
Open IntelliJ in the top folder where there is no .idea folder. Often IntelliJ will just construct a new .idea folder and works.
Copy an .idea folder from a similar project and modify to fit. The xml files in the .idea are reasonable to modify.
Open IntelliJ in the root project level works for me.
I have a mixed project folder tree like the following:
git_root
- proj_android
- proj_ios
- proj_react
- lib
- src
My problem is that when I open IntelliJ on my proj_react folder, I could not see my src folder or lib folder. (My proj_react is one level down from my git_root.)
Then I open IntelliJ on git_root, I could see everything. The problem is solved.
If you are working on a software development project where you are using Maven, Gradle, Flash Builder etc., the below mentioned steps should restore the project structure:
Ctrl+Alt+Shift+S (or) File>>Project Structure
Select 'Modules' in 'Project Settings'
Alt+Insert (or) Select '+' to add a new module
Select 'Import Module'
Select the folder you want to import the module from(Generally the parent folder)
Select 'Import module from external model' and the corresponding external model
This resets your project structure.
You can sometimes rescue projects like these by going and resetting their content root in the module settings. Or even recreate the module as another answer suggests.
This is something that would happen to me if I opened an IntelliJ project in PhPStorm, then tried to open it in IntelliJ again.
However as was mentioned the project format changed recently, so you should use the same version of intelliJ to work on your project.
If you have a content root for a project module that intersects with another content root, then this problem will occur. For example:
Project A (content root)
- source for A
- module B (content root)
- source for B
If you have a project that has a source root for "Project A" and you add a source root for "module B" you will end up with missing structure, such as your first picture. This happens because the content root for module B is within project A structure.
This worked at one time, as I have the setup above with multiple modules. When I upgraded to 12.1.6 this stopped working. If you have overlapping source roots you will see this problem.
I'm using 12.1.6 on windows 7.
On Mac:
Preferences
search for Project Structure or go directly to:
Project: Your_Project_Name / Project Structure
Mark all as Sources (mine was marked as "Excluded")
What did you update from? If you did a few major versions update, intellij really changed how their projects are laid out. You probably need to edit the projuct structure and add a new java module.
This issue is 8 years old and the problem still exists in IntelliJ. For projects with many modules, it can be a real pain reconstructing them after each time this occurs. I suggest that once you reconstruct the modules, back up the .idea folder so you can easily restore it next time
In the bottom left corner of IntellIJ you'll find an icon, using which you can fetch project structure, etc..,
This is the quick fix that i have done:
Close the IDE and open the project folder in file manager
Delete the .idea folder and reopen the project in IDE.
To view the hidden folder and files:
Open the folder and press cntrl+H (in linux), And in windows Go to folder options and check view hidden files option.
I am using Eclipse to develop an Android board game.
I have developed the UI in an Android project.
On the other hand, I have developed the AI in a regular Java project, because I wanted to be able to test it without all the constraints of the Android emulator (I didn't find any other way to run the code using my Windows JVM).
Now comes the times when I want to 'join' both projects (which work fine independently), that is to use the AI Java classes from the UI.
This is what I have tried:
In my Android project Properties > Projects References, I ticked the Java project.
This allows me to build without error the Android project (which instantiates an AI object).
But it fails at runtime with this error:
Could not find class 'my.package.AI', referenced from method my.otherpackage.UI.onStart
What would be the correct way to include the AI Java Project into my Android Project ?
(NB: I still want to be able to develop and test the AI as a regular Java app, so I think using a jar or copying all the sources to the Android Project would not suit my needs)
EDIT:
I was hoping that the new ADT v17 would solve the problem, but it didn't. I have tried virtually every option available to include a project in my Android project:
Adding or linking a source folder
Adding a Project (Java Build Path > Projects tab)
Adding a Class Folder or a Library (Java Build Path > Library tab)
Ticking all the previously imported projets/libraries as Exported
The only way that allows compiling and running without error is adding the JAR of the Java Project to the Android project build path.
Projects References only add the dependent project source code (your AI project) as a soft (perhaps weak is a more accurate word) reference, your AI project is not added into you Android Project Build path. so the actual ai.jar is not exported into the final apk when Eclipse build your app.
You should add AI project into Android project build path:
Right-click on your android project, select Build Path - Configure Build Path, in Projects tab (Required projects on the build path), add your AI project here.
Then in Order and Export tab (Build class path order and exported entries), tick your newly added AI project appeared int the list.
Step 2 is probably optional, this should add AI project as a reference in Android project and export the ai.jar to final.apk when Eclipse build your Android project.
Update from ADT 17.0.0:
Android Dev Team just release SDK r17 with ADT 17.0.0, which claims to handle this use cases properly now:
Eclipse specific changes
The dynamic classpath container called “Library Projects” has been renamed to “Android Dependencies” as it now contains more than just Library Projects.
The container will now also be populated with Java-only projects that are referenced by Library Projects. If those Java projects also reference other Java projects and/or jar files they will be added automatically (jar files referenced through user libraries are supported as well).
Important: this only happens if the references are set to be exported in the referencing project. Note that this is not the default when adding a project or jar file to a project build path.
Library Projects (and the content of their libs/*.jar files) is always exported. This change only impacts Java-only projects and their own jar files.
Again, duplicates (both projects and jar files) are detected and removed.
More in this link.
Edit: After much testing, reading and found my solution. Problem is (as of this writing) that you can't reference another project from an Android project, although it works fine for a normal Java application project.
Workaround for me (Windows with NTFS filesystem):
In a prompt (admin rights) make a symbolic folder link using mklink /D command pointing to your source project folders, and refresh in Eclipse as needed.
The obvious limitation is you cant use the same package names in source project and target project, and then there is the problem with libs in the common project.
example:
cd \java\workspace\AndroidProject\src\your\package
mklink /D common c:\java\workspace\CommonProject\src\your\package\common
Clarification: You can reference another project from an Android project to make it compile, however when you run, the referenced classes from the included project are not put in the apk classes.dex (verified with dex decompiler).
Using ADT 21.0.0 64bit on Windows 7 64bit. I tried adding project to build path. Ticked in the Order and Export, played with order. I read the official solution, the detailed explanation of that solution, exported as JAR, added to libs. Did not work, while the source was without errors. Read in the comments that the solution didn't work for everyone.
Was fed up with it and tried a simple but somewhat messier solution: linked the Java project's source to the Android project. That did the trick. Hope that this will help others too.
Don't add it to the project references area, instead go into the Android pane (in the Project Properties), scroll down to the bottom, and add it under Libraries.
This sometimes works but sometimes produces bizarre Eclipse issues (not sure why), in which case copying the jar directly into the project seems to work best.