Android SDK Full Javdocs with Maven in Eclipse - android

I have an Android Maven project using maven-eclipse-plugin and android-maven-plugin. Since it grabs the jars and javadocs from Maven Central (which are stubbed), I would like to instead link back to the javadocs in the Android SDK folder.
I have tried two things
Packaging the $ANDROID_HOME/docs/reference folder into a Jar, and then manually installing that as the Javadocs for Android 2.2.1 in Maven using mvn install:install-file.
Manually defining the javadoc location of the android-2.2.1.jar on my build path as $ANDROID_HOME/docs/reference
Neither of these have had any success in actually linking back the correct Javadocs - I remain with the stubbed ones that don't give any actually information about the methods. Any ideas how to fix this?

This should work in your IDE setup.
However Eclipse might be confused since the source and the binary artifact will not correspond to each other again because the original android jar in the SDK as well as in the Central Repository are both stubbed.
That said I have never tried to hook this up together either and I am using IntelliJ so I would not be able to help you with Eclipse much..

Related

How to post an Android Studio .AAR file to a local Artifactory repository

I'm using Android Studio 1.5.1 to build a self-contained library (no external dependencies). Let's call it "myLib.aar".
I've been asked to modify my Gradle build to push the .AAR file into the company's private, local Artifactory repository. I am an experienced developer but know very little about Java repositories.
There are a lot of search hits on this topic, but none of them have so far resulted in a solution for my particular situation. Even more troubling, I can't find any two posts that implement a solution the same way.
I'm further confused why one can't just use an/the Artifactory plugin. Apparently one must ALSO use a Maven plugin -- but why? Some use third-party Maven plugins, some use something which appears to be built into Android Studio.
So my question is simply what lines to add to which Gradle files in order to push my .AAR file into Artifactory?
You should use Artifactory plugin.
Re Maven plugin. The role of Maven plugin is to generate metadata about your package (the pom.xml file). Other option is using Ivy plugin to generate the metadata in an alternative format (the ivy.xml file). One way or another your package needs metadata. Select one of them (by applying maven, maven-publish, ivy, or ivy-publish plugin).
The instructions about Artifactory plugin show configuration examples for all the possible options.
JFrog GitHub repo contains project examples for all the possible options.
Hope that helps.
I am with JFrog, the company behind Bintray and [artifactory], see my profile for details and links.

How to use/install certain library in Android Studio

I found this "amazing" library that i think it would look nice in my small project but i don't find how to use it / how to install.
This is the url:
https://github.com/kmshack/Android-ParallaxHeaderViewPager
Thanks.
It seems to be available via Maven (see here). It might be an old version however. You could also import the project into Android Studio, build the jar and put it in your project's libs folder. A third option would be to make it build as part of your own project. For the latter you can use this for inspiration.

Attaching javadoc for external libraries in Android Studio

Is there a way of linking javadoc to libraries in AndroidStudio? I'm using the June 18 dev build of Android Studio, and my dependency for the android plugin is: com.android.tools.build:gradle:1.2.3.Gradle 2.4 is being used by the wrapper.
If, for example, I delete everything from ~/.gradle/caches and rebuild project then all libraries are downloaded. I resynch in AS and then by navigating eg. to class org.hamcrest.MatcherAssert AS allows me to download or choose sources. That gets me to sourcecode (as opposed to dissassembled code), but how to get linked external javadoc. Is this a bug? Is there a workaround?
https://code.google.com/p/android/issues/detail?id=59220

Packaging a jar for Android

I have modularised some simple classes into their own project for reuse elsewhere. These classes typically contain only fields and accessor methods (i.e. nothing Android specific).
They are later packaged up using ant's jar task and stored in a Maven repository.
In an Android project, I've stored said jar file into a libs directory and added to the build path. On running the emulator however, I get a "class not found" exception relating to my package. Other third party libraries (such as GSon) are being picked up fine.
Are there any specific steps required to make a jar file compatible with Android? (This reply seems to suggest otherwise). How can I debug this further?
No as long as you do not need e.g. classes from javax.* that are not in Android. If I were you I would consider looking at using the Android Maven Plugin for your build though. Check out the morseflash example from the official samples collection. It showcases exactly your scenario.
You only need an Android library project if your going to be reusing Android components and resources. In your case, I believe you added the project to the build path, but I'm sure your not exporting it as part of the dependent project.
So open the project properties, open up the Java Build Path options and make sure that you have your JAR selected as an exported dependency in the Order and Export tab.
UPDATE
This is what your entry should read:
<classpathentry exported="true" kind="lib" path="libs/tlvince-dao-0.1.0.jar"/>
I've also forked an updated version of your gist.
This issue was a result of compiling the jar to Java 7. Android does not support Java 7 (yet).
Compiling to Java 6 bytecode by setting target="1.6" in ant's javac task solved the issue.

Duplicate file when deploying apk

This problem seems to come up for a few people, but I haven't been able to apply the solution suggested in other threads for one reason or another so...
I am trying to build a simple android app with an embedded webserver. The server of choice if jetty. I am using maven to manage dependencies with the maven-android-plugin. I have added jetty-server v8.x as a dependency with the default scope. When I try and deploy my apk to the sandbox I get an error
Found duplicate file for APK: about.html
So the file in question is from the jetty package, or rather it is found in two jetty packages, one being a dependency of jetty-server. Other threads out there seem to be suggest I delete the file from one jar or the other but this is not really a scalable solution as I am not the owner of the jars.
Is there a more general solution to this problem? Something that manages the conflict and build or deploy time?
I should note, I am a bit of a Java noob, and have gone the NetBeans and maven route because this is the toolkit I'm familiar with.
OK, found it. The solution is to build using the following command
mvn android:deploy -Dandroid.extractDuplicates=true
There are a couple of issues:
First, to integrate Jetty, your project is going to need a pom.xml file. The Android APK (as-is) does not know how to resolve a pom with Maven dependencies without some sort of bridge. So, you'll need to install a few plugins for Pom management onto Eclipse. Follow the instructions here: http://rgladwell.github.com/m2e-android/
(I found it easier to create a new project using the method described here rather than converting my existing Android app to a Maven project, but I'm sure it'll work either way.)
Second, once you've installed this, you're going to have to make sure your pom.xml contains the necessary dependencies, build goals, and variables. So, open up your pom.xml, and make sure you have the following:
In the "build" node:
sourceDirectory -> src
defaultGoal -> install (I suppose...)
In the "dependencies" node:
... all the jetty/cometd dependencies (org.cometd.java, org.eclipse.jetty, etc.)
Third, you should know that you can't just click the green run button and launch the app via ADB. You have to install it the maven way (Run As -> Maven build/install/test/whatever)
You should open up your war file and check if you actually have two about.html files in there. Some time ago I had two web.xmls in my war files. If you actually have duplicates then you should try to exclude those files.
Maybe you have one file in your project and the duplicate is generated by the maven plugin.
I also just realized that you're probably already properly using the android-maven plugin. One other important tip: change the scope to runtime on the jetty dependencies. This builds successfully for me, whereas using the default scope (compile) always threw the duplicate file in APK error.

Categories

Resources