1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AndroidStudioでのJavaDocの記述と生成

Last updated at Posted at 2016-03-10

JavaDocの記述

JavaDoc(intellij-javadocs)プラグインをインストールする

  1. Android Studio > Preferences > plugins > Browse repositories...
  2. 検索窓にJavaDocと入力 > JavaDocをインストール

JavaDocプラグインのショートカット

  • To generate javadocs for active element press "shift + alt + G".
  • To generate javadocs for all elements in current java file press "shift + ctrl + alt + G".
  • Remove javadocs on current/selected element: "shift + alt + Z"
  • Remove javadocs on all elements of current class: "shift + ctrl + alt + Z"

JavaDocの生成

app/build.gradleに以下を追記する

// app/build.gradle:

project.ext {
    if (android.hasProperty('applicationVariants')) {
        androidVariants = android.applicationVariants
    }else if (android.hasProperty('libraryVariants')) {
        androidVariants = android.libraryVariants
    }
}
project.androidVariants.all { variant ->
    task("javadoc", type: Javadoc, overwrite: true) {
        title = "YOUR_APP_NAME"
        source = variant.javaCompile.source
        ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
        classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)

        options {
            links("http://docs.oracle.com/javase/jp/7/api/");
            linksOffline("http://d.android.com/reference", "${android.sdkDirectory}/docs/reference")
            setMemberLevel(JavadocMemberLevel.PUBLIC)
            docEncoding = 'UTF-8'
            encoding = 'UTF-8'
            charSet = 'UTF-8'
        }

        exclude '**/BuildConfig.java'
        exclude '**/R.java'
    }
} 

ターミナルで以下のコマンドを実行する

### 環境変数を設定
# java 1.6を使用する
$ export JAVA_HOME=`/usr/libexec/java_home -v 1.6`

# 以下は必要なら行う
$ export ANDROID_DAILY_OVERRIDE=4a50f93953bc93b160920b1956a20e4942372a86

# javadocを生成
$ gradlew javadoc

# javadocを開く
$ open app/build/docs/javadoc/index.html

参考

1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?