I need to use Android API 21 (Lollipop) classes. I am using maven to build my Android project. I know I need to define dependency in order to build my project. So I defined the following one:
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
<version>4.1.1.4</version>
</dependency>
But the above latest artifact doesn't contain the support for Android API 21, also maven central repository shows me there is no artifact available for Android API 21 (Lollipop).
In order to make the maven build work, I am thinking to get the artifact jar & install it in my local maven repository.
My question is where can I download the android.jar artifact of Android API 21 (Lollipop) ? If there is no place to download it, what could be a workaround for my maven build?
I'm not sure if there are better ways to solve this from a Maven point of view, but since the question was where you can download the android.jar artifact, here's a solution to that. You can download the stand-alone Android SDK tools and then use SDK Manager to download your desired version of the Android SDK. Once you've downloaded it you'll find the android.jar under ./platforms/android-21/
Related
I need to include appcompat-v7 in a maven build. Please note this is a question about a library with resources and not a jar. It's currently an aar artifact. The documentations on the SDK Deployer does not cover version 23.1.0 or version 23.0.1. I need to know what dependency needs to be in pom to include the compatibility library. Its either aar or apklib, and or also the include of a jar file as well. If anyone has got this working I would appreciate it if you would share the correct pom dependency. This problem appears to have been solved here:
How can I add an apklib dependency to your android maven project?
but this solution expressed in latest Android would be:
<dependency>
<groupId>android.support</groupId>
<artifactId>compatibility-v7-appcompat</artifactId>
<version>23.1.0</version>
<type>apklib</type>
</dependency>
This does not work now because apklib is not what is there. It is aar and changing type to aar does not seem to work either. Resulting in lots of conflicts or missing classes or class conflicts. I can think of no more commonly needed library from SDK Deployer than this. So could someone please answer the quesiton. In addition, I think the documentation of the deployer should reflect current versions, not just versions that are years old. Thanks.
The documentation of the SDK deployer references all dependencies that are custom created in addition to the ones from the repositories of the SDK itself. You can run the deployer and deploy all the components into a repository manager like Nexus and then search there or you can browse the local file system repository in ~/.m2/repository. For example look in the directory ~/.m2/repository/com/android/support/appcompat-v7/
In your case you probably want to use something like
<dependency>
<groupId>com.android.support</groupId>
<artifactId>appcompat-v7</artifactId>
<version>23.1.1</version>
<type>aar</type>
</dependency>
This is all mentioned in the docs. And the deployer is open source and I do accept pull requests ;-)
I'm doing an Android app that needs the latest support library.
If I understand correctly the latest version is 22.2.0
So I'm trying to get the com.android.support - appcompat-v7 version 22.2.0 dependency but it is not found on search.maven.org
As one can see, it is the one required by the gradle dependency on this article:
http://androidgifts.com/navigation-view-using-design-support-library/#comment-11
The latest android sdk android-sdk_r24.3.3-linux.tar does not have it. It only has the 22.2.0 version.
How come Maven does not have it ?
Any way to download it ?
As mentioned here > Android support library setup with maven google actually don't care much for maven users...
One of the answers mentioned there might help you (probably not as easy as you'd like, but...): https://stackoverflow.com/a/22602712/4405559
I'd also advise you to try finding a github repo containing the newest appcompat (the question I've linked has also got an answer mentioning how you can create your own repo, if needed).
I have just followed the steps in this stackoverflow answer in my maven project: https://stackoverflow.com/a/22602712/4405559 and it works perfectly.
<dependency>
<groupId>com.android.support</groupId>
<artifactId>appcompat-v7</artifactId>
<version>22.2.0</version>
<type>aar</type>
</dependency>
The gradle dependency would be:
compile 'com.android.support:appcompat-v7:22.2.0#aar'
(If it doesn't find it you may need to add the local android support m2repository folder to your repositories. See this answer: https://stackoverflow.com/a/25365406/2199475)
Just make sure you have run check for updates in the Android SDK Manager and install the correct api and associated SDK Build-tools.
When I configured my apklib I included:
<dependency>
<groupId>android</groupId>
<artifactId>android</artifactId>
<version>4.0_r3</version>
<scope>provided</scope>
</dependency>
in the dependencies list. If I don't do that it won't recognize the source code in the editor
and won't compile. However, my question is, does the Android SDK then get included into the
project that uses the apklib? It seems so. However, why would it be so? I thought which SDK to use should be only decided by the project that uses the apklib rather then the apklib itself(?). I don't want to use an apklib that for example use api-level 19 when I use api-level 14 in my main project.
In short: Does an SDK dependency in the apklib pom get included into the main project (using Maven)?
I got it.
One should use scope=provided for the dependency.
Then, Maven assumes that the container project supplies the classes, and so the SDK classes don't get imported together with the apklib.
I am building my android app with Maven (ok... trying to build), after several errors I got to this one :
[ERROR] Failed to execute goal on project AndroidPro: Could not resolve dependencies for project com.kowalsk.android.recipe:AndroidPro:apk:1.0.0-SNAPSHOT: Could not find artifact com.google.android:android:jar:4.0.3 in central (http://repo.maven.apache.org/maven2) -> [Help 1]
I used maven-android-sdk-deployer and downloaded all needed libraries, but it haven't solved the problem.
When using maven-android-sdk-deployer : the stub for android libraries will be installed in your local maven repo with the groupId android (i.e. not com.google.android)
The groupId com.google.android is the official groupId used by google to publish some versions of android API. I don't know why only few versions are available (probably because maven wasn't the build tool choose by google for the android platform). We can hope that in a near future (mainly because google choose gradle as new build tool): all versions will be available with the groupId com.google.android in central repo.
In my local repo, the stubs installed with maven-android-sdk-deployer have also a special version number with _rX appended. So to use the 4.0.3 I have the following dependency :
<dependency>
<groupId>android</groupId>
<artifactId>android</artifactId>
<version>4.0.3_r3</version>
<scope>provided</scope>
</dependency>
See the link Maven Android Jar, maven repository does not have the version you mentioned in your pom 4.0.3
use any version mentioned in the link.
I have an Android Project where I need to build multiple versions of the same application from the same sources.
To do this, I use the android plugin for Maven
Each version must be able to include ads from admob. So in my POM I added this dependancy
<dependency>
<groupId>com.admob.android</groupId>
<artifactId>ads</artifactId>
<version>20101109-ANDROID-3312276cc1406347</version>
<scope>system</scope>
<systemPath>THE_PATH\libs\admob-sdk-android.jar</systemPath>
</dependency>
I don't get any errors at build time but, when I execute the application I get this exception
java.lang.ClassNotFoundException: com.admob.android.ads.AdView
So apparently the package is not properly included ?
You can NOT use system scope for runtime required libraries. Deploy the jar into your local repository or your repository server (using e.g. mvn install:installFile ..) and remove scope and systemPath from the dependency declaration.
Update: As of the latest releases my Maven Android SDK Deployer can do the install of the AdMob jar from the SDK into your local Maven repository or repository server for you.
To use the Maven Android SDK Deployer, do the following:
Clone the repo:
git clone https://github.com/mosabua/maven-android-sdk-deployer.git
Go to your SDK Manager and install all APIs (this may take a while if you haven't done it yet)
Make sure you have the correct environment variable set for ANDROID_HOME. For Windows this might be:
set ANDROID_HOME=c:/android-sdk-windows
Run the installer:
c:\Tools\maven-android-sdk-deployer>mvn install
After you have done this you can just use all the android dependencies from your pom.xml, e.g.
<dependency>
<groupId>com.google.android.admob</groupId>
<artifactId>admob</artifactId>
<version>6.4.1-r11</version>
</dependency>
(There's a whole list on the github page)