I am using merge list in my android project and up until now I have just been shoving the source into my src root with the rest of my code. However I'm not modifying anything so I figured it was time to include this stuff as libraries. I clone the first repo and:
$ ant
Buildfile: /Users/user/dev/projects/cwac-sacklist/build.xml
BUILD FAILED
/Users/user/dev/projects/cwac-sacklist/build.xml:49: taskdef class com.android.ant.SetupTask cannot be found
using the classloader AntClassLoader[]
Total time: 0 seconds
It looks like this ant script is looking for some stuff created by the "android" tool.. but I don't see any docs.. but I see the missing prop sdk.dir.. so I create that in local.properties.. but then I get:
/Users/user/dev/libs/android-sdk-mac_x86/tools/ant/lib_rules.xml:126: Reference android.libraries.src not found.
What is the right way to go about packaging this stuff so I can shove it in my local maven repo? Or better yet, where can I find it pre-packaged or in an existing maven repo?
UPDATE - 2014-07-08
It looks like commonsware now has all this stuff in a proper repo:
from: https://github.com/commonsguy/cwac-sacklist
repositories {
maven {
url "https://repo.commonsware.com.s3.amazonaws.com"
}
}
dependencies {
compile 'com.commonsware.cwac:sacklist:1.0.0'
}
Your first error is a standard one, caused by a discrepancy between the build files in the repo and your version of the build tools. Simply run:
android update project -p ...
where ... is the path to the project in question, to update the build files.
Your second error is solved by adding the following lines to build.xml, just after the <setup/> tag:
<path id="android.libraries.src"><path refid="project.libraries.src" /></path>
<path id="android.libraries.jars"><path refid="project.libraries.jars" /></path>
You will see those lines in the MergeAdapter edition of build.xml, though they apparently are not in the SackOfViewsAdapter build.xml file, as I have not touched that project in some time.
Or better yet, where can I find it pre-packaged or in an existing maven repo?
If there is one, it's unofficial, as I am not a Maven user.
Related
I have to create an application that makes extensive use of charts.
Reading the web I chose achartengine that seems to have everything I need.
I downloaded the jar file, I plugged in the libs folder, I selected "add to library" and I lunch the gradlew clean.
Result in the sources where I do the import of org.achartengine.xxxx I always returned the error that fails to resolve symbols .
Do you have suggestions?
Thank you
Andrea
I am able to use this library in my Android Studio project, this topic explains how to add AChartEngine repo to your project.
What I did:
Added following to project-wide build.gradle (one from the project root):
allprojects {
repositories {
...
maven {
url "https://repository-achartengine.forge.cloudbees.com/snapshot/"
}
}
}
For every module that uses the library, add this to its build.gradle (you may put this to the top-level build.gradle if it should be included in all modules):
dependencies {
...
compile group: 'org.achartengine', name: 'achartengine', version: '1.2.0'
}
Now I can use the library in the project, I see the classes in code assist popups and build runs as succeeds.
It seems like the new version (1.2.0) is not available for download anymore in the http://www.achartengine.org/ site. and that's why the gradle/maven method doesn't work (or the snapshot file was removed).
I succeeded using and adding it to my project by downloading the jar file from here:
https://github.com/ddanny/achartengine/files/460139/achartengine-1.2.0.zip
I trying include to project Cling, but before I never used manually install from maven.
On page instructions is:
Install Maven 3.2.3 or newer.
Install the Android SDK and set the ANDROID_HOME environment variable
to the SDK install directory.
Clone the Cling source:
git clone https://github.com/4thline/cling.git
Change into the cling/ directory.
Install everything into your local ~/.m2 Maven repository (this will
take a few minutes if all dependencies have to be downloaded for the
first time).
mvn clean install
If your build fails with Android/dex packaging errors, you forgot the clean.
Use Cling in your pom.xml with:
don't know why, but pom.xml not insert here
you can see pom.xml on github page
I have done 1,2,3,4 steps, but what is "Install everything" in step 5, how to do it ?
And last step with pom.xml, where need to put it?
Step 5 comes down to running the command mvn clean install from the command line.
Maven is configured with the help of a file, called the POM file. It is an XML file named pom.xml. This file contains everything that Maven will do during the build. One of those things is to compile the Java sources into a final artifact. To compile the source code, it needs to resolve its dependencies; that is, other libraries that Cling depends on. All of those required libraries are declared in this POM file.
Maven will automatically download every dependency of the project. It will store them (or install them in the Maven jargon) into a local repository. This repository is just a directory structure on your local drive that will contain every JAR and POM that Maven will have downloaded from the Internet (more precisely from remote repositories configured for the project).
Maven will only do that process once. When all the dependencies are installed in your local repository, it won't download them again (by default). That is why the very first build will be longer that the subsequent builds.
So, to go through step 5, you need to:
Open a command prompt
Go into the directory where you checked out Cling with the command git clone https://github.com/4thline/cling.git at step 3.
Go into the cling subdirectory.
There should be a pom.xml file here. This is the main entry point for Maven. Run the command mvn clean install from this location.
Step 6 targets the project you are building. When steps 1 to 5 are done, you have compiled and installed the latest version of Cling. Now is the time to use it then!
Well to use it, you need to create a Maven project (there are facilities for that with every major IDE like Eclipse or IntelliJ) and declare that your project will have a dependency on Cling. That declaration is done with this bit of XML in the POM file of your project.
<dependencies>
<dependency>
<groupId>org.fourthline.cling</groupId>
<artifactId>cling-core</artifactId>
<version>2.1.1-SNAPSHOT</version>
</dependency>
</dependencies>
I strongly suggest that you read the Maven book from Sonatype to get you acquainted with using Maven.
I saw two method of adding external jar.
First is copying to libs folder and then adding manually in build.gradle.
compile files('libs/commons-net-3.1.jar')
Other is the graphical method: right click on app folder> import external .jar > then adding dependency........
I choose the first one but this gives me and error:
/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java - Dfile.encoding=UTF-8 -jar /Users/abhimanyuaryan/AndroidStudioProjects/UniSnap/app/libs/commons-net-3.1.jar
no main manifest attribute, in /Users/abhimanyuaryan/AndroidStudioProjects/UniSnap/app/libs/commons-net-3.1.jar
Process finished with exit code 1
Your problem is better solved by not including a local jar at all, but by a remote artifact.
Make sure your build.gradle has to following to load from maven central -
repositories {
mavenCentral()
}
and add the following to your dependencies block --
compile 'commons-net:commons-net:3.1'
Do a gradle sync after making these changes.
The format is 'group:name:version'. See the docs on dependencies for more info. To find libraries you are interested in, check their install docs for a maven or gradle artifact description, or you can search Maven Central.
Lastly, want to point out that 3.3, not 3.1, is not the most current version of Apache Commons Net.
I have to create an application that makes extensive use of charts.
Reading the web I chose achartengine that seems to have everything I need.
I downloaded the jar file, I plugged in the libs folder, I selected "add to library" and I lunch the gradlew clean.
Result in the sources where I do the import of org.achartengine.xxxx I always returned the error that fails to resolve symbols .
Do you have suggestions?
Thank you
Andrea
I am able to use this library in my Android Studio project, this topic explains how to add AChartEngine repo to your project.
What I did:
Added following to project-wide build.gradle (one from the project root):
allprojects {
repositories {
...
maven {
url "https://repository-achartengine.forge.cloudbees.com/snapshot/"
}
}
}
For every module that uses the library, add this to its build.gradle (you may put this to the top-level build.gradle if it should be included in all modules):
dependencies {
...
compile group: 'org.achartengine', name: 'achartengine', version: '1.2.0'
}
Now I can use the library in the project, I see the classes in code assist popups and build runs as succeeds.
It seems like the new version (1.2.0) is not available for download anymore in the http://www.achartengine.org/ site. and that's why the gradle/maven method doesn't work (or the snapshot file was removed).
I succeeded using and adding it to my project by downloading the jar file from here:
https://github.com/ddanny/achartengine/files/460139/achartengine-1.2.0.zip
I am trying to use RobolectricSample application for unit testing Android application.
In the instruction for installation of application with Maven the first step is
ant maven-setup. I could not understand why is this command required and what it will do?
Any explanation will be great help.
According to the Ant build file build.xml, ant maven-setup does two things:
maven-install-jars:
Install 2 required jar libraries (guice-2.0-no_aop.jar & maps.jar) into Maven local repository.
maven-set-android-sdk:
Reset Android SDK path in pom.xml iff <path> is defined in android-maven-plugin.
This is not a elegant solution, ideally all those tasks should be handled purely by Maven. However, as this project provide both Ant and Maven build, it reuse the script from Ant in Maven build lifecycle for convenience.