I want to use the appcompat for my project in AIDE.
so I downloaded the jar file, add it into lib folder & coded my project.
but when I theming, by putting the code
android:theme="#style/Theme.AppCompat"
into AndroidManifest.xml, it gets an error, showing that no resources found that matches the name.
I modified the project.properties file, but still the same thing happens.
what shall I do?
AppCompact is a Library project. You must reference it in your Andorid Project instead of adding it as a jar.
Read
No resource found that matches the given name '#style/Theme.AppCompat.Light'
Related
While create an Android project in eclipse, it created 2 projects.
appcompat_v7
MasterCopy <- This is the name of my project
I understand that appcompat_v7 is a library project that android automatically created for me.
Once the above projects are created I got an error message 'The container 'Android Dependencies' references non existing library'. To address this I just build the appcompat_v7 project and that clears the error.
Basically I don't want appcompat_v7 as a separate project. This is how looks like.
If I delete the appcompat_v7 project I got the 'Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar' in styles.xml file.
Is there a way I add appcompat as external library or JAR file into the MasterCopy project and keep one project as whole without loosing the functionality?
I am not sure whether I am making any sense here... But this is how I asked to create the project.
Explanation
The issue you're going to have is that resources, such as styles like Theme.AppCompat.Light.DarkActionBar, cannot be packaged simply in a jar file. As Google's documentation explains:
Some Support Libraries contain resources beyond compiled code classes,
such as images or XML files. For example, the v7 appcompat and v7
gridlayout libraries include resources.
Google has specific documentation for how to include libraries that contain resources, which it appears you've followed:
https://developer.android.com/tools/support-library/setup.html#libs-with-res
The reason why it's a good idea to keep this in a separate project, is that it allows you to easily upgrade, build, and otherwise manage that project separate from your own as the compatibility library changes.
(Unrecommended) Solution
That said, if you really want to have a single project, you could manually copy everything from the sample project for the app compat library (located in <sdk>/extras/android/support/v7/appcompat/) into your project. Notably, you'll need to copy everything from the res/ folder and merge it with your own resources, or rename google's XML files such as res/values/strings.xml to strings-appcompat.xml, and of course the appcompat jar file itself.
Again though, you'll have to go through this process every single time you want to update the version of the compatibility library that you use.
(Good) Alternative Solution
Google has specifically created the AAR format, which bundles resources with a jar file. If you transition to a Gradle build system (easy if you're using Android Studio), then all you have to do is refer to this app-compat-v7 aar artifact (also explained at the link above), and you can maintain a single project.
I'm using Facebook SDK project on my own project by adding it as a library inside my workspace, like:
Project properties -> Android -> Add.. -> Facebook SDK
Like this i have access to classes and resources inside this project. For example in one of my layout files i have:
android:drawable="#drawable/com_facebook_loginbutton_blue_normal"
But if i want to change the way i use this Facebook SDK project, and simple export it as jar file, and add it to libs folder in my app, i have the error:
error: Error: No resource found that matches the given name (at 'drawable' with value '#drawable/com_facebook_loginbutton_blue_normal').
How to access the resources inside my jar file?
The short answer is, you can't. The Facebook SDK is an android library, and is being shipped as such, and should be used as such. Trying to import it as just a jar file will not work. Do you have a specific use case that requires you to only use jar libraries?
From what i can understand..
That,s because that drawable resource is in different package than yours, try accessing it with full package name
EDIT
What I meant was add
android:drawable="#packageName:drawable/com_facebook_loginbutton_blue_normal"
Like this:-
android:drawable="#com.google.android:drawable/com_facebook_loginbutton_blue_normal"
I don't know what package name is defined in Android SDk so change package name accordingly.
Hope this helps.
How can I build one Android project to jar that is can included in other android project? When I use eclipse export an Android project to jar and use the jar to other android project ,The "R" file and the resource files will be error。
Android resource files (which are represented in your R.java files) cannot be put into Jars. That is why libraries such as ActionBarSherlock require to be opened as library projects, instead of simple Jars.
You can build Android Library Project to jar, but within library project you should prevent using R class, Instead of R class you can use reflection to load resources.
For example if you need to load string from strings.xml file
int id = context.getResources().getIdentifier("string_name", "string", context.getPackageName());
String value = context.getString(id);
But this is what they mentioned about getIdentifier method:
Note: use of this function is discouraged. It is much more efficient to retrieve resources by identifier than by name.
You can build Android Project to jar file but don't use any Resource file.
B'coz when you will try to use that jar file in your application at run time Resource not Found exception will come.
So while creating jar file please unchecked res,gen,Manifest, etc.
You can Define your Base Activity class, Base Interface, Database Manager, GPS Manager
in your library project and use it in your our application it will surely work.
So see the below screen shots.
Thanks
I've included ActionBarSherlock in my project as a library, though it is not path independent. Thus, when I push it into my repo, the library path gets muddled up. How do I change that? How do I make it path independent?
If it were a Jar file, I could have included it in the lib folder of my project, but it is a library in itself. What to do about it?
Check your project.properties file to see where it is pointing to in regard to ABS..
if it says something like:
android.library.reference.1=/myfiles/location/bleh/blah/foo/ActionBarSherlock
and your project that references it is also in /myfiles/location/bleh/blah/foo/ (its nice to keep them in the same folder for simplicity)
you can change it to :
android.library.reference.1=../ActionBarSherlock
That way when you check out your repo all of your library references will be intact (provided that folder structure is intact on the actual repository).
and yes, despite the project.properties file saying "do not change me ohh nooo!" you can change it without any problems
I am trying to use phonegap inside an android library project. The library project compiles just fine but when i try to start an activity that extends DroidGap, i get this error
01-02 10:12:17.575: W/dalvikvm(316): Unable to resolve superclass of Lcom/***/***.
I think this is because the phonegap.jar file is not included in the compiled jar file of the android library project. I have tried using ant to build but it doesn't seem to work.
Edit: I am building a android library that can be used in other android projects. I am using the standard android library project but activities in this lib project that extended DroidGap class in phonegap.jar are crashing with the above error.
I´m afraid that is not possible yet. The result jar file will contain all classes and resources defined in the android library project, but will not include external jar files added to the build path. You will have to add those to your final Android Projects using that library. You can also find similar questions in SO like this one
create one folder 'lib' in your project. put your .jar file in lib folder. select your .jar file right clicked on ,select buid path --->'add to build'. will add your .jar file. now you can use this .jar file classes.
I would suggest not making the 'lib' folder manually.
Instead:
Right click Project --> Properties --
Select Java Build Path
Make sure Libraries is the tab selected at the top
Click Add External JARs
Then find your JAR...
Basically, the same way you may have added the PhoneGap.jar
The ADT (Android Development Tool Eclipse plug-in) has built-in support for the creation and reference of library projects. See the example in section 5 of this tutorial.
Try changing the name of the folder to libs instead of lib.
have you added required permission in manifest file..
see the below links
http://docs.phonegap.com/en/1.4.0/guide_getting-started_android_index.md.html