Importing the desk-clock android project into eclipse - android

I copied the code onto my computer via
svn checkout http://desk-clock.googlecode.com/svn/trunk/ desk-clock-read-only
into the folder C:\Programming\desk-clock-read-only
I try to create the project via File/New/Other/Android/Android Project from Existing Source.
I select the C:\Programming\desk-clock-read-only path.
For some reason eclipse only wants to import C:\Programming\desk-clock-read-only\res.
The source files are in C:\Programming\desk-clock-read-only so they don't get imported.
There's just an empty src folder.
What do I have to do to import the project correctly?

I dont't know how the developer of this project managed it to run this but usually the java files belong inside the src folder and the manifest definitely not inside the res folder. If you change this Eclipse(or the IDE of your preference) might recognize it, but you'll maybe get some errors because just putting the java files inside the src folder shouldn't solve it. You actually need a package. Check your manifest for that.

Related

Android - How do I create the assets folder manually?

I'm new to Android development, and I'm trying to manage projects from the command line using the SDK since I cannot get Android Studio 1.2 to work properly in my system (it's unresponsive).
The problem: I created a new project but the asset folder is missing.
Other SO answers (enter link description here) solve this by creating the folder from the IDE, or by pointing to the asset folder in the .iml file, with doesn't work in my case (I trying to mange the projects from the command line entirely)
There's also a solution editing build.gradle, but the project created from command line (using the SDK) doesn't seem to be a gradle project.
Any help would be appreciated.
Just create a directory called "assets" at the root of your project, i.e. in the same directory your AndroidManifest.xml lives. There's no need to "link that folder from the project". At least that's the case on my system, where I'm using Android SDK 24.4.1 (and I'm not using Gradle -- just emacs and ant).
Once I had assets/fonts/aisauc.ttf in there, the following code...
import android.graphics.Typeface;
...
Typeface greek =
Typeface.createFromAsset(getAssets(), "fonts/aisauc.ttf");
mytextfield.setTypeface(greek);
gave me a TextField with characters from the font I wanted.
How do I create the assets folder manually?
You make it the same you make any directory on your filesystem. Whether you use mkdir or a command-line equivalent, or whether you use your desktop OS's file manager, is up to you.
The default location for an assets/ directory is in a sourceset (e.g., src/main/assets/, to go along with src/main/AndroidManifest.xml and src/main/res/ and src/main/java/, where src/main/ is a sourceset). You can have an assets/ directory located elsewhere, if you choose, but then you will need to configure your build.gradle file to teach Gradle the alternative assets/ location for whatever sourceset you are trying to apply it to.
In your left most sidebar or the sidebar that shows the app, manifests, java... etc, right click app > New > Folder (has the green android symbol next to it) > Assets Folder.
On the next screen leave the path as 'main' and click 'Finish'. Then you can drop whatever asset you want into the folder.

How to import res folder of another app to your app in Android Studio?

I want to use layouts,values,dimens., etc of my previous project/app in my new project. Basically, I want to import the whole res folder of my previous project into the new one. I know I can copy-paste the stuff I need, but in this case I need the whole folder as it is. So, is there an easy way to do it? I'm using Android Studio.
You could extract your resources to a libraryproject. Other projects can use this libraryproject as a dependency and can make use of the resources. Changes in the libproject will also affect other projects. So you don't have to copy&paste new code.
If you want to use another project's res folder, you just need to copy and paste it under app folder of android studio project.
You can't address the other Project Directory to your current project.
For Android Development all your resources need to be in your current project's directory within respective folder in "/res/" folder.

Reference Android Library project from another android library project

I have an android library project (say A) in eclipse that is trying to reference another library project (say B). Both projects have res folders, and what I see is that A is unable to reference anything in B's res folder, basically R.java can't be resolved (no strings, no layouts etc).
Am I missing something crucial? Is this even possible?
Thanks!
You could just export one of your library projects as a jar file.
Then create a new folder name "libs" (name is important) and then import that jar file into the project. As long as you've included the right files when creating the jar file, you should be able to reference those files from the second project.
Now when it comes to manipulating files in the res folder, that might get trickier. If you are trying to do any UI stuff where the resources are in the library project, then I'm not sure if this is possible.
Hopefully this helps!
Cheers!
----------------------- Update ------------------------------
I'm not sure where you are going wrong. If you do what I suggested, make sure that you add the "gen" folder when creating the jar file. Then make sure you add the right import, and voila you can reference that file.
For example: say your library file has the package com.test.Test1
then in your gen folder you should have the package com.test.Test1 with your R.java file in it.
Export this project making sure to include that gen folder.
Then in your other project make sure you include "import com.test.Test1"
now in code you can just type R.Whatever. There might be some confusion if you are including another import for R.java.
Now if you want to access the "res" folder, I would imagine you could just change the res folder into a source folder (Build Path->Use as source folder) and then export the jar making sure to add the res folder.
Hopefully this works for you.
Cheers
You should use the full namespace before the R class. For example if the name space on project B is com.projectB.* then you can reference the R from project A by referencing R as
com.projectB.R.xxxx

Android: Source path not being included

In my project I have added some folders that I want included in my project for source files. But no matter what I do, the source never gets recognized. I tried refreshing, clean up, restarting but nothing works. Here is the project's source folder:
I want the folders integration/android added. This is how it is showing up in Eclipse:
And here is what my build configuration looks like:
I could be wrong, but it looks like you have added them as a folder, but not actually added the folder to your project.
The folder should show up in your src folder in the solution explorer window under your other package.
Try creating the package name in your project, then move all the src files into it.
And when its in the src folder, in its correct package, you dont need to include any extra build paths.
(You can have multiple packages in a single application)
Importing someone elses project that is over 2 years old is almost always problematic. I found the easiest solution just to create a fresh project and add the files manually from the old project.

Eclipse Import Custom Class from /src

Hey I'm having a pretty basic problem importing classes into my Eclipse based Android app. I have included the class directory into the /src directory where I figured the classes would be easily included, but Eclipse is saying it "cannot resolve the classes".
One thing I noticed is that the project folder that I included and the subfolders are just regular folder and not package folder icons. Is that a problem? If so, how do I change them to packages? This is an external git repo, so I'd rather not do anything beyond just including them in my project.
Here are some pics of how I set up the project to help:
The Activity where the error is:
Here is the package structure in the project, and the package called "android-utils" where the files I'm trying to import live:
Here is how I'm importing the files:
Btw, these classes are just some utils and I'll be improving and adding to them during the development process.
Let me know if you need any in more info to help me get these files imported the right way. Thanks!
Did you try dragging the .java files from Windows Explorer directly onto the package in Eclipse you want to put the new classes into? It should then ask to copy or link to files.
As your folder contains only java files Add them as Jar File in your Buildpath project, and your problem will be solved.
Also your jar file you can put it under the /libs folder
see this link to lean how you create jar file

Categories

Resources