5

I am trying to generate Javadoc html pages for my Android project in Eclipse. I have tried using the -linkoffline argument, as suggested here, as well as using the -classpath argument pointing to my android.jar file. Neither of these worked, as I still get package android.app does not exist (and other) warnings. I have also tried running the javadoc tool from the command line, rather than using Eclipse.

Ideally I would like to have my own generated pages for my classes, with all android.* and java.* classes linking to the online pages. I am using Mac OS 10.6 with Java version 1.6.0_20.

Community
  • 1
  • 1
idolize
  • 6,455
  • 4
  • 24
  • 34

2 Answers2

3

While trying to resolve a similar issue myself, the two main points I've found have been:

  • To include the android.jar file you're linking to within the classpath attribute of the javadoc Ant task. That means something like the following:

    <javadoc ... 
      classpath="some/local/library.jar;
        C:/Android/platforms/android-8/android.jar;
        D:/another/library.jar" ... >
    
  • To add a link subitem under javadoc task in order to match the online Android Reference URL with a local copy of Android Reference package-list. That means something like the following:

    <javadoc ...>
       <link offline="true" 
         href="http://developer.android.com/reference/" 
         packagelistloc="C:/Android/docs/reference" />
    </javadoc>
    

This was enough for me in order to show Android links within my project Javadoc.

superjos
  • 12,189
  • 6
  • 89
  • 134
  • That worked for me but I still have "package com.mypackage.R does not exist" warning. – bancer Jun 29 '12 at 21:01
  • Sorry not to be helpful. I don't have that environment set up at the moment. – superjos Jul 23 '12 at 10:15
  • @superjos can you tell me please, where do I have to write those lines – 5er Jan 01 '14 at 23:06
  • 1
    @5er usually you have a `build.xml` file for your project, that is an Ant Build file, used to build/compile/package the project source files from the command line (and also from Eclipse UI, if needed). In that file you create a *target* dedicated to doc generation, and within that a Javadoc *task* to perform the actual operation. You can see an example in @junkdog answer on this page – superjos Jan 02 '14 at 00:01
1

Have you tried using an ant script for the javadocs? Name it javadoc.xml or something other than build.xml - else eclipse will pick it up as the default build script. Run the ant script either from inside eclipse (RMB on file | Run As | Ant Build), or from the console: ant -f <file-name.xml>.

Mine looks something similar to this:

<project basedir="." default="doc" name="metagloss api docs">

    <property 
        name="android-sdk-docs"
        value="/home/blackrax/opt/dev/android-sdk-linux_86/docs/reference"/>

    <target name="doc" description="api docs - no piwik" depends="clean, delombok">
        <javadoc destdir="docs">
            <link offline="true"
                  href="http://d.android.com/reference"
                  packagelistLoc="${android-sdk-docs}" />
            <fileset dir="src" includes="**/*.java" />
        </javadoc>
    </target>

    <!-- more implementation, any remaining targets -->
</project>
junkdog
  • 855
  • 7
  • 8