R File missing on library dependent project - android

I am trying to use jfeinstein10 / SlidingMenu http://goo.gl/PEZ9M in my android application.First I have added library project of Sliding Menu, then I added ActionBarSherlock too.Sliding Menu library is dependent to ActionBarSherlock.
Also my app is dependent to SlidingMenu app.
My question is that when I add a library project as a dependency to my main project, the R file of the main project disappears and all my R references in main project cannot be resolved.
does anyone know that R file disappearance issue after adding a library project as a dependency?

Use the Project Properties and clicking on the Android section, change the Project Build Target to Android 4.0.3 (API 15). Clean the project after changing the API Level.

Ok I just struggled through this issue for quite some time now I finally resolved it here are the steps I took.
First of all I updated the android SDK for eclipse to the latest version.
Then I updated eclipse itself by going to Help --> Check for updates
next downloaded the latest version of SlidingMenu and ActionBarSherlock and unzipped them to a folder
Then in eclipse import ActionBarSherlock by creating "New Android Project from existing source" and selecting the "library" folder in the unzipped directory
Repeat the above step for SlidingMenu
Very important at this point to make sure you don't have any errors in your both imported library projects
If you have errors in the ActionBarSherlock then right click the project goto "Android Tools" --> "Add Support libraries". This should resolve any issues you have if not then goto project --> clean and clean up the project
The sliding menu will have a target of 2.2 or 2.1 by default (sorry cant remember which one...its really late and my head feels foggy :z)
Right click on the SlidingMenu project and select properties in the window that opens select target build of Google APIs 4.0.3 select ok and do a CTRL + SHIFT + O and any issues or warnings you had should go away.
With that out of the way then once again right click on the SlidingMenu project and select properties. In the window under Android scroll all the way down and add reference to the ActionBarSherlock library. Also make sure the "Is Library" checkbox is checked. Apply and ok.
Next you have to do the same for your project. Right click on it --> Properties under Android Scroll all the way down and add SlidingMenu as a library. Make sure the "Is Library" checkbox is NOT checked.
At this point I encountered Dependency errors. The problem is that in your projects "libs: folder you will have the files: "android-support-v13.jar" and "android-support-v4.jar" causing a conflict.
What I did was delete the v4 and copy pasted the v13.jar file into the libs folder of all 3 projects, my project, SlidingMeny and ActionBarSherlock.
This resolved the above issue and it worked!
Hope this helps someone so they can go to sleep at sane hours of the night! :)

I just ran into this problem and I didn't need to change my build target. What I had to do it make sure my app and any library that implemented the support Library was using the same support Library version. The easiest way to do this:
Right click on each project and library that is in question and select Android Tools -> Add Support Library... *

Related

Reference library project

I'm working on an Android 4.1.2 project, where I'm trying to add a reference to this github project
Following this guide, I've imported the project into the same workspace, and I'm able to select and add the library and get a green checkmark. When I press "Apply" or "OK" the dialog closes, and nothing happens (no rebuild). Then, when I again try to see if it's added, it's not there - not even with a red cross.
I've tried running the project anyway, but it gives me java.lang.ClassNotFoundException: com.handmark.pulltorefresh.library.PullToRefreshGridView
First I choose the library, get the green checkmark
Then I press "Apply" and "OK", and dialog just closes and don't build. When trying to see if library was added, it's not there:
Any suggestions about what's wrong?
Did you or did you not check the "Is Library" option?
You need to reference that library in your android project. Assuming you have imported the library project to eclipse, right click on your project, goto properties, choose android , click add, browse and add the library project.
Clean and build and run. Check if you need to add support library for running on lower versions
Import the library and your project in the same work space. then clean the project and try to add library by the same process you are doing(Properties --> Android --->Add).
Also try restart eclipse.

Adding ActionBarSherlock in Eclipse Juno

I´m new to Android World but I really like it, I programmed some apps and now I would like to try the ActionBarSherlock specially for the tabs menu.
I have Eclipse Juno version 4.2, I use jdk-7u5 and the latest version of SDK (v.20)
I want to install ActionBarSherlock version 4.1
As in Eclipse Juno there is no "Select Create project from existing source" option I imported Sherlock library as a existing project on Eclipse and a red cross appears in almost all packages in src.
Then, I added it as library on my own project. Now a red exclamation mark appears on my Android Aplication Project.
I´m using android:minSdkVersion="7" android:targetSdkVersion="14"
I read a lot about different problems with the library ActionBarSherlock and I tried everything they say in the forum, even install Eclipse Helios to use
the option "Select Create project from existing source", but I had an Installation Problem with ADT.
Thank you in advance everybody.
I found this tutorial wich solve the problem I had with ActionBarSherlock.
Here it is http://androiddevelopmenttutorial.co/actionbarsherlock-getting-started/
From this web http://www.grokkingandroid.com/adding-actionbarsherlock-to-your-project/
Getting ActionBarSherlock and adding it to Eclipse
The first thing you have to do, is to download the library from actionbarsherlock.com. After this unzip/untar it. The download contains three folders: library, samples and website. The samples folder contains four sample projects to showcase what you can do and to show you how to do it. You should have a look at them. The website folder contains the code of the project website. The library folder finally contains ActionBarSherlock’s source code.
Now go to Eclipse and add the ABS-library as an Android project. Do not use Eclipse’s import tool to import the ActionBarSherlock library – it would not work immediately and you would have to fix some settings. Instead use the project creation wizard of the Android Developer Tools.
Open File -> New -> Project -> Android Project From Existing Code.
Creating an Android project from existing source
In the next screen select the folder, which Eclipse then uses to search for projects. If you select the ActionBarSherlock root folder, Eclipse suggests a list of projects to create. Leave the “library” project checked and uncheck all others:
Select the library project
Click “Finish” to create the project.
Eclipse will now create a new project named “library”. I prefer a more useful name, so select the project called “library” and hit F2 to rename the project. I have renamed the project in Eclipse to “ActionBarSherlock”, so all following screens will refer to this name.
Adding the library to your project
Now that ABS is a library project you have to tell your own project to use it. I will use the project of my last post for this. Go to FragmentStarter’s project settings and switch to the Android tab.
If necessary scroll down until you see the Library panel. Click “Add”:
Adding libraries to an Android project
In the next window all available library projects will be listed. Select ActionBarSherlock and click “Ok”.
Select ActionBarSherlock from the list of libraries
When the window disappears the library should be listed in the library panel of the Android properties tab:
Check if the library has been added succesfully
Then appears an error: Jar mismatch! fix your dependencies, to solve it there is to copy the file android-support-v4.jar from your_project/libs and paste it on library/libs.
Before you can use ActionBarSherlock you have to extends your Activity like this: public class MainActivity extends SherlockActivity and change the theme in Manifest: android:theme="#style/Theme.Sherlock.Light.DarkActionBar"
This is the way to add ABS to your project. Hope it works for all

ActionbarSherlock not working

I am having problems getting start with the ActionBarSherlock. I downloaded the 4.1.0 version and followed the following tutorial for installing it.
http://www.youtube.com/watch?v=4GJ6yY1lNNY
The Problem I am facing is whenever I make a new project and add the library project of ActionbarSherlock to it. I get the following error.
Description Resource Path Location Type
The container 'Android Dependencies' references non existing library 'C:\Work\JakeWharton-ActionBarSherlock-4.1.0-0-g9598f2b\JakeWharton-ActionBarSherlock-88fc341\library\bin\com_actionbarsherlock.jar' myapp Build path Build Path Problem
Please anybody help me with it.
I just had the same problem: A .jar file is requested, but non-existing. Also, it is okay that the file doesn't exist, because we want to use a Android-Library Project and not an included jar-library.
The steps described by Aqif Hamid are perfectly fine, if the missing import (.jar or library project) would be the root of the problem. But i figured out that the reason for this error is that you have to set both projects (AndroidBar Sherlock and your own Android project) to Java Compliance Level 1.6
To do so go into Project Properties => Java Compiler and set the level to 1.6
Of course, you have to install JDK 1.6 on your computer...
Hope this helps you too!
The only thing that it works for me was selecting at Properties at Java Compiler Tab Compilance Level --> 1.7 (It was 1.6).
After that Android Tools, Fix Project Properties
DO the followings:
just like you have bin, res folders. right click on your project and
add a folder named 'libs' (if libs folder is not already there).
Then copy paste your com_actionbarsherlock.jar file in this libs folder.
Right-click on your com_actionbarsherlock.jar file and click Add to Build Path.
Now clean and build your project. You should be good to go.
Edit:
To add project as a library do this:
Make sure you have your library project in your projects list and it
is open.
Right click on your project in which you want to add your library
project and select Porperties.
Click Android in properties windows, now scroll down, you will see
library section at the bottom. There press Add button.
Now a window will open in which you will see list of library
porjects. Select your required project and press Ok. Now that library
project must be there with a green tick mark.
Press Apply and Ok button.
You should be good to go now.
regards,
Aqif Hamid
I am of the understanding that you cannot include ActionBarSherlock into your project by adding a jar to your lib directory (or just including the jar at all). You will have to create an android project for ActionBarSherlock then link to it as a library:
Create ActionBarSherlock project in Eclipse
Right-click your project and go to Properties
Select Android in the left pane
Then in the right pane, towards the bottom you can Add... the ActionBarSherlock project you created in step 1.
If you are curious why the jar approach doesn't work, I give you Jake's reply in this thread
(although that's a month and a half old at this point).
1 - create a libs folder (parallel to manifest) and put the jar in that
Your Project -> right click -> Properties -> Java Build Path -> Libraries -> Add Jar ->
yourjar.jar
This video might be useful in case you are having some issues.
http://mobile.tutsplus.com/tutorials/android/jar-for-android/
Clean your actionbarsherlock project. It will generate the .jar file for you when it re-builds.
Using the Android Tools option to Add compatible libraries fixed the problem for me.

Cannot Resolve #style/Theme.Sherlock

I'm trying to make use of Actionbar Sherlock 4, targeting sdk 15 and min sdk 8. After following the directions provided on the Usage website and the great videos posted here: http://www.youtube.com/watch?v=avcp6eD_X2k
I'm still encountering a problem. When I try to add android:theme="#style/Theme.Sherlock" to my manifest file , I get the error:
No resource found that matches the given name (at 'theme' with value
'#style/Theme.Sherlock').
I have included the actionbar Sherlock library project into my project, and the import statements are there and not coming up with any errors and I've
extends SherlockActivity implements ActionBar.TabListener
just like in the Demo code and documentation Yet still, eclipse gives me this error. Any ideas out there?
The pitfall I encountered was this: The reference to the ActionBarSherlock project needs to be in the Android->Libraries section of the project properties, while I had been adding it to the Build Path->Libraries.
I encountered a strange anomaly that might help!
Have built android project that uses ABS, running it on Gingerbread works fine, in ICS it crashes, the crash under ICS occurs due to this, check your AndroidManifest.xml (have trimmed out bits for brevity...
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" android:theme="#style/Theme.Sherlock">
It was the android:theme part that caused the crash under ICS, it worked fine under Gingerbread and older versions!. Solution was to remove it completely! Then from your Activity, do this:
#Override
public void onCreate(Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH){
this.setTheme(com.actionbarsherlock.R.style.Theme_Sherlock);
}
super.onCreate(savedInstanceState);
... // MORE CODE ....
}
This fixed up the crash under ICS, the theme style is not liked by ICS, but it works fine for both versions less than 2.3 and 4.0 upwards.. weird error but that I discovered by fluke!
Remember to apply the theme before calling the base class's own onCreate!
My standard procedure for including a library project on Eclipse goes like this:
Import library project
Right click on library project Properties -> Android -> Set Project Build Target (insure library and primary project are the same)
Right click on library project Android Tools -> Fix Project Properties
Select the library project then Project -> Clean...
Select primary project then Project -> Clean...
That should fix whatever ails you.
I finally find the solution:
IMPORTANT! Copy the same android-support-v4.jar in both projects: in library and your project (this is the principal problem).
Import "library" project TO YOUR WORKSPACE
Right click on library project Properties -> Android -> Check "Target Name" 4.x (any, API level 14,15 or 16). Bottom check "Is library".
In properties, go to "Java Build Path", tab "Libraries" And find "android-support-v4.jar" normally in "Android Dependencies". Ok and Close Properties.
Right click on library project Android Tools -> Fix Project Properties
in Menu Project -> Clean... and select to clean the "Library" Project.
In this place, your project "library" must to be done (without errors)
Create or import your own project. Example "MyProject"
In properties, go to "Java Build Path", tab "Libraries" And find "android-support-v4.jar" normally in "Android Dependencies".
Now go to "Projects" Tab. Add... and select "library" project.
Now in properties go to Android -> Check "Target Name" 4.x (any, API level 14,15 or 16). IMPORTANT: Must to be the same of "library" project. Bottom "Is Library" must to be UNCHECKED and in this place press Add... And select "library" project. Ok and Close properties.
Right click on "MyProject" project Android Tools -> Fix Project Properties
in Menu Project -> Clean... and select to clean the "MyProject" Project.
Already, your project must to be done. If the error persist, restart Eclipse.
I resolved this issue by the follwoing 2 steps on my projects:
Remove the "library" from "project properties"/build path and add library in "project properties"/Android/Library
Right Click on project "Android Tools" -> "Add support library"
after importing both projects i.e. library and settingActivity,first clean and build them.
Then right click on settingActivity project->properties->select second option from left menu (i.e android).
on right hand side their is library section just click on add library. prper path will automatically comes in that frame.
Thats solve my problem,i got no errors.

Greendroid or ActionbarSherlock - setup

do you guys know any tutorial on how to use one of the above frameworks in eclipse on windows?
I've downloaded both of them and followed the instructions - but I still get errors in both cases. Frustratin.
I just tried these instructions on ActionBarSherlock, but I'm pretty sure the process was the same when I was using GreenDroid.
Download the .zip/.tgz and extract it somewhere
Go to eclipse and choose File->New->Project
Choose Android Project
Select Create project from existing source and then browse to the library folder inside the folder you just extracted the .zip/.tgz into
Build Target should be 3.2 as of this time
Finish the wizard, then right click on the newly created project and go to properties
Under the Android heading, you should see a section for Library with a checkbox IsLibrary. Make sure that's checked.
Now go to the properties for your Android project, then under the Android heading and the Library section choose Add...
You should see the actionbarsherlock library, add this to your project
Lastly, if you were using the compatibility support you need to delete that jar since it's included in ActionBarSherlock
I had errors on #Override methods because I was using Java 1.5. Switching to 1.6 solved them.
To do this : right click on your project > Properties > Java Compiler > Enable project specific settings > Compiler compliance level > 1.6
It is related to this issue in the project's bug tracker : https://github.com/JakeWharton/ActionBarSherlock/issues/28

Categories

Resources