My android project is using ant build, And I cant upgrade to gradle build since im using gameclosure, a 3rd party game development tool.
Now I need to upgrade my google play services library.
I found that the required modules are:
play-services-base
play-services-basement
play-services-plus
play-services-play
from $SDK-PATH/extras/google/m2repository/com/google/android/gms
So I created individual android lib projects from above modules and added all as library project of main project.
Issue is that, play-services-base libs project whose package name is "com.google.android.gms.base", some of the class is referencing R.class file from package "com.google.android.gms". But correct value is present inside package "com.google.android.gms.base".
How to change to project settings/configs so that this R.class is generated in proper package???
Try to follow the instructions in this related thread. It suggested to try changing the android library reference to a relative path (relative to the current directory) instead of an absolute path. You may also check on this blog.
The Play library has to be included in your project.properties file like android.library.reference.1=../google-play-services_lib
because it has resources that need to be included. However, Ant will fail your build because Google no longer provides a build.xml for the Play library. You can generate the build.xml in the Play library by running android update lib-project --path <playlib_path>.
Hope this helps!
Related
I have a fairly latest version of android studio, I have created a module under a project which is basically supposed to be a library, when I build it, it creates an ".aar" file , what I want is .jar file as this library is supposed to be used with eclipse as well.
The library contains activity as well, is there any way by which I can create a .jar file which I can use on Eclipse as well Android Studio ?
I have already created this module and tried building , as a result it generated .aar file and not a .jar file.
I found a way to achieve this, plain simple, using Gradle 2.2.1:
task jar(type: Jar, dependsOn: 'assembleRelease') {
from fileTree(dir: 'build/intermediates/classes/release')
}
Place this in your library module.
It will compile it as release and produce a JAR file in: build/libs.
bash gradlew jar or use your IDE to target that jar Gradle task.
aar is not related to AS or eclipse but is an AndroidARchive for Android applications like JavaARchives are for java applications.
Because Android is java based, jars can be used. But to take android specialities into account, like resource bundles, an aar is the right thing to use.
Currently gradle based builds doesnt seems to be allowing to create jar with android studio, I decided to go for Intelij it has necessary option and does what i want , i can use community edition.
***Update****
Even the jar produced by Intelij with resources don't work , obviously its not easy to have a jar with resource , so decided to opt for .aar and hoping that Eclipse also gets support for .aar when gradle supports lands there, as that was my main concern.
Add this in your library's gradle file:
task deleteJar(type: Delete) {
delete 'libs/traylib.jar'
}
task createJar(type: Copy) {
from('build/intermediates/packaged-classes/release/')
into('libs/')
include('classes.jar')
rename('classes.jar', 'traylib.jar')
}
createJar.dependsOn(deleteJar, build)
You need to check path of your generated classes.jar: build/intermediates/packaged-classes/release/
Create lib folder in your lib's root folder if it is not there
Go to gradle build: Android Studio --> View --> Toll Windows --> Gradle
Select your module(:library) --> Tasks --> other --> Double click on createJar task
You can just simply unzip the aar file to get the separated pieces of files.
I've created an Android project in Eclipse and I would like to add the Volley library to it. Searching on the web, I've tried these approaches:
Copy the .jar into the libs folder and right-click and add it to build-path.
Open the library as an android project, mark it as library and add it as a reference in my android app.
Nothing works. I still cannot access the classes provided by the library by importing the classes like follow: com.android.volley
Someone has a solution for this ?
The Solution:
Try this:
Add volley.jar to the libs folder. Don't add it to the build
path.
In Eclipse go to Project and make sure Build Automatically is selected.
Now in Project, click on Clean:
Project -> select Clean -> select the project.
As Volley doesn't have any resources like styles, layouts etc., its not necessary to reference it as a library project. The above should work, provided all steps are followed.
If this doesn't work ...
Make sure the library has not been added to the build path. If it is, then remove it. Now, try:
Closing and re-opening the project.
Restarting the IDE (last resort).
The build process for Volley has changed to Gradle. If you just want to use the library without building it, you can get the Jar from Maven or scroll down to the instructions to building it yourself lower in this answer.
Maven
An easier way to obtain the Jar file is to download it directly from Maven Central. You can find the latest version with this search:
http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.mcxiaoke.volley%22
At the time of writing the 1.0.19 version can be found here:
http://search.maven.org/remotecontent?filepath=com/mcxiaoke/volley/library/1.0.19/library-1.0.19.jar
Gradle
The new way to do it is to build the project using Gradle.
You can do this by running:
git clone https://android.googlesource.com/platform/frameworks/volley
gradle build
This will create a file in
build\intermediates\bundles\release
Then add this file into your libs folder and add it to your project.
I'm trying to add https://github.com/astuetz/PagerSlidingTabStrip to my project. Looking at it, I notice that it has files in res and depends on its own R.java file. When I make it a JAR I continue to get errors because the dependencies aren't all there. I'm not sure how to get this to work.
I keep getting errors like
import android.support cannot be resolved and everything else too. I tried referencing different answers on StackOverflow but none of them yielded a working solution.
The resources won't be packaged into the JAR file. Google is working on a new packaging scheme called AAR which is supported by Android Studio.
In order to use this third-party library in your own project, you should clone it to a local repo. Then you can import it directly into your Eclipse workspace and then add the Eclipse project to the classpath of your app's project.
Download the whole source code from https://github.com/astuetz/PagerSlidingTabStrip by git tool.
On your Eclipse IDE, import the library as exsisting source code at Android option.
Add the library your add before into your project.
I've searched everywhere I could for a solution to my problem an I couldn't find one, so I hope there's someone outhere who can help me.
I have a .jar library that I want to include into my project, I've followed a fews guides I found, but no one has worked for me so far, despite the fact that I can compile and generate my APK.
After installing the APK and launching the app, when a class member is called (the one from the library I want to import), my app crashes, and logcat gave me this :
Could not find class 'net.rdrei.android.dirchooser.DirectoryChooserActivity', referenced from method com.azsde.myApp.Settings$1.onPreferenceClick
I then decompiled my apk because I was curious to see if the class has been included or not, and I found that it has not be included in my apk, here's a the result of a tree command listing my files:
http://pastebin.com/wcdK37FM
Here are my Java Build Path settings:
What did I do wrong and why isn't my library included in my APK?
Adding the JAR to your project's build path yourself as if it were a plain Java project will not work.
You add libraries to an Android project by copying the JAR to the libs folder at the root of your project (if the folder does not exist, then create it); ADT will then automatically add it to your build path and set up your project to bring the JAR into your APK.
You can learn more here http://tools.android.com/recent/dealingwithdependenciesinandroidprojects
I've just updated some things with the SDK and donwloaded update for the ADT. Now I get a red exclamation mark in the Project folder.
The console tells this:
Found 2 versions of android-support-v4.jar in the dependency list,but not all the versions are
identical (check is based on SHA-1 only at this time). All versions of the libraries must be the
same at this time.
Versions found are:
Path: C:\Media\Eclipse Workspace\project1\libs\android-support-v4.jar
Path: C:\Media\adt-bundle-windows-x86_64-20130522\sdk\extras\google\google_play_services\
libproject\google-play-services_lib\libs\android-support-v4.jar
Jar mismatch! Fix your dependencies
Had to say, that I created a project importing google-play-services_lib to set as library in other projects ass this where I had to use google maps.
In Java Build Path\Android Private Libraries I've got 2: google-play-services.jar and android-support-v4.jar.
The console is telling you that you have to different copies of the support library. When Eclipse sets up the project for the first time it will add a copy of the support library. This copy is probably different than the one that comes with google play services library. Make sure that there is a consistent version of the support library across your project.
Dont Include the android-support-v4 in the library , instead you can add it to your project as an external jar using build path menu > add external jar
You can refer to
This and This
.
For each project and library, right click on your project in Eclipse go to Android Tools > Add Support Library. This will download the latest version. Upon doing this on each referenced project and library, they should all then have the same version of the support library and you should no longer see this error message.
Finally I solved.
I removed and installed the "Google Play Services" from the SDK.
Import again the google-play-services_lib project
On Other project's properties in the android tab delete the library and add again
Copy the lastest android-support-v4.jar to the libs folder