I am getting the following error while trying to use the google maps api using googleplayservices in android.
I have added the google play services library as dependency project and declared it in android manifest also.
Please help me i am unable to proceed and i have done every possible solution I found in stakeoverflow to solve this error.
Error:
Official solution is
Allow src/doc attachement for 3rd party jars in libs/
Since those jars
are added dynamically through a classpath container, the devs cannot
set the source path and the javadoc through Eclipse UI (container
don't allow editing those). To fix this, and to make sure that both
paths are picked up not only by the current project, but also by other
projects (if the current project is a library project), the value is
set by a file sitting next to the jar file. The file is name after the
jar file, adding .properties at the end. For instance foo.jar ->
foo.jar.properties It can currently contain 2 properties: src:
relative or absolute path to the source folder (or archive). doc:
relative or absolute path to the javadoc.
Check following question for more details
The Jar of this class file belongs to container 'Android Dependencies' which does not allow modifications to source attachments on its entries
Related
I have some points with me!!
1) Where can I found custom Android UI View library's in the web. I have searched a lot and failed obtaining a working one.
2) I haven't got any *.jar files inside the *zip I've downloaded.
3) Android studio can't support zip library's but Eclipse can.
4) Where is Graddle file located in Eclipse.
Now my question is...
Even I've added one custom UI library and built. The layout editor palette window's CUSTOM VIEW Tab in Eclipse will not shows any VIEWS from that added library? Why so? Do I manually write the XML? Please help me..!!! Also where can I find good attractive and colorful UI element library in web?
1) Where can I found custom Android UI View library's in the web. I have searched a lot and failed obtaining a working one.
ans : It depends on what type of custom ui want. You have got search specific custom ui widgets. Ex : button,TextView etc. You get it library project most of the time so you have advantage customise further as per your need. Jar will be very less.
2) I haven't got any *.jar files inside the *zip I've downloaded.
Ans : As my previous ans zip what you got is library project. Its not jar project. And im sure sure you have got more zip from github repository.
3) Android studio can't support zip library's but Eclipse can.
Ans : You have to unzip and add it as dependency library to project.
4) Where is Gradle file located in Eclipse
Ans : Gradle file is nothing but build.gradle file or settings.gradle
1) Good point to start is Android Arsenal
2) A lot of library can be add to Android Studio Project manually as Module or providing single file with aar extension.
Jar file is not very useful for custom control, because it cant store android xml resources file, so you cant declare strings or attributes. Best choice is aar library format.
3) If library contain only class files just rename it from zip to jar and add it to project as usually.
4) Eclipse does`t support graddle build system at all.
In any case, be sure that you add library to Eclipse project and press refresh button on custom view tab.
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 want to use the ${sdk.dir} variable in my project.properties file, so I can check this into version control and use the same file on different setup machines.
My working setup looks like this:
My project.properties:
target=android-18
android.library.reference.1=..\\..\\..\\sdk\\extras\\android\\support\\v7\\appcompat
android.library.reference.2=..\\..\\..\\sdk\\extras\\google\\google_play_services\\libproject\\google-play-services_lib
My local.properties:
sdk.dir=C:\\adt-bundle-windows-x86_64-20130917\\sdk
this setup compiles with ant from the command line. but when I replace the ..\\..\\..\\with ${sdk.dir} I get the error:
project.properties how I want it to use:
target=android-18
android.library.reference.1=${sdk.dir}\\extras\\android\\support\\v7\\appcompat
android.library.reference.2=${sdk.dir}\\extras\\google\\google_play_services\\libproject\\google-play-services_lib
results in:
BUILD FAILED
C:\adt-bundle-windows-x86_64-20130917\sdk\tools\ant\build.xml:460:
Failed to resolve library path:
C:\adt-bundle-windows-x86_64-20130917\sdk\extras\android\support\v7\appcompat
so the variable ${sdk.dir} is replaced correctly but somehow it cannot be resolved. Any ideas?
update Edit
Using the Variable for the proGuard setup in the same file (project.properties) is working fine what so ever:
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
This doesn't solve your issue, per se, but I hope it will help you.
My issue was that I needed to reference the Google Play Services SDK as a library in my project. However, our app is built automatically on a separate box using Ant.
I found that library projects cannot be referenced using absolute paths; they must be relative to your project, as explained here:
Library project storage location
There are no specific requirements on where you should store a library project, relative to a dependent application project, as long as the application project can reference the library project by a relative link. What is important is that the main project can reference the library project through a relative link.
I used the ant.properties file to set the android.library.reference.1=../../../../Program Files/Android/android-sdk/Android/android-sdk/extras/google/google_play_services/libproject/google-play-services_lib library. This reference is solely for the build server and this path is relative to the library location on the build server.
For development, I use Eclipse. So, the library's relative path is referenced using the project.properties file and is relative to my development box. This means that whenever I trigger a build on the server (which uses Ant), the reference in the ant.properties is used as opposed to the project.properties file.
The ant.properties file is lower level and therefore will override anything written in the project.properties/local.properties files.
As you can see this is not the answer I am sure you're looking for, but it is a limitation of Ant. My final bit of advice is that you move away from Ant and use Gradle.
I am working on an android library, and wish to export a JAR file that I can distribute for others to use in their apps. I don't want to distribute the source code as it contains details on posting to my web server.
I have tried using the JAR file that is created in the bin directory and copying the jar file to my project and referencing it within my project and ticking the export button.
When I try and run my project referencing the library that I've copied, my app throws an exception with NoClassDefFoundError. I've done some Googling and everything I have found suggests you have to provide the source code and let the user import into their IDE and then reference that project into their app which I don't want to do. It must be possible as other companies provide JAR files for libraries that can be included.
Thanks for your help.
I don't want to distribute the source code as it contains details on posting to my web server.
Bear in mind that anyone who wants to can get that data out of the JAR.
It must be possible as other companies provide JAR files for libraries that can be included.
AFAIK, this recipe still works:
Create an Android library project, with your source code, resources, and such, and get it working
Compile the Java source (e.g., via Ant) and turn it into a JAR file
Create a copy of your original Android library project to serve as a distribution Android library project
Place the compiled JAR from step #2 and put it in libs/ of the distribution library project from step #3.
Delete everything in src/ of the distribution library project (but leave the now-empty src/ directory there)
Distribute the distribution library project (e.g., ZIP it up)
This effectively gives you what you see with the Play Services SDK -- a library project with no source code, but instead a JAR in libs/, along with the resources and such.
I will be reconfiming this recipe tomorrow and will try to remember to update this answer if I find that it needs adjusting for the current crop of tools.
And the new Gradle-based build system supports the AAR package for distributing libraries and such, though I have not played with this yet.
UPDATE
This recipe works, so long as the library project does not itself have dependencies upon another JAR or library project. In those cases, things seem to get messed up in the build process -- everything can compile, but class references from the dependencies cannot be resolved at runtime.
Did you try putting your jar file in libs folder?And if you are exporting a jar library for android be sure it has no /res folder. As you know you can't reference to your res folder from a jar therefore you have to use library project to reference your res folder (drawable,xml,ect...)On the other hand you cant make your code safe (the part you say about posting to your web service) by using it as jar since it is so easy to retrieve by reverse engineering. you better use some encoding (like base64 or any algorithm that bouncycastle provides)
Since I updated android SDK tools to rev19 my external Library Projects discontinued to be visible by referencing projects.
With new dependency behavior I moved jars to /libs folder which has fixed references with external jars.
Addining a link to the LIbProject
Link added with the absolute path
When properties reopened again the link appears broken
This link helped with external jars. http://tools.android.com/recent/dealingwithdependenciesinandroidprojects
This is literally what I'm getting, not with jars but Library Projects.
http://code.google.com/p/android/issues/detail?id=27490
How to reference external projects now?
Edit:
Somehow reference to the Library Project is broken. From the referencing project I add link to a LibProject. Project->Properties->Android->Library->Add. When the lib project added, reopening properties shows that the link is broken. Projects are on different logical disks. If projects in a common root folder then linking works.
Where to store the actual library project does not matter, as long as you use a relative link to reference it. Check out the Library Projects - Development considerations:
Library project storage location
There are no specific requirements on where you should store a library project, relative to a dependent application project, as long as the application project can reference the library project by a relative link. What is important is that the main project can reference the library project through a relative link.
Check out my answer here to see the screenshot examine how correct (by using relative path) and broken (by using absolute path) library reference links are shown in Properties window.