20220110のAndroidに関する記事は4件です。

Android開発におけるドキュメント作成ツール"Dokka / KDoc"について

Dokkaとは "KDoc"形式で記載したコメントを、Javadocと同様な形でドキュメントを作成できる。 JavaとKotlinが混在したプロジェクトのドキュメントも生成可能 導入 project/build.gradle buildscript { ext { dokka_version = "1.6.10" } dependencies { classpath "org.jetbrains.dokka:dokka-gradle-plugin:${dokka_version}" } app/build.gradle apply plugin: "org.jetbrains.dokka" android {} dependencies {} // dokkaHtml 用の設定 dokkaHtml.configure { outputDirectory.set(new File("${buildDir}/dokkaHtml")) dokkaSourceSets { configureEach { // Moduleやパッケージに対するドキュメントを作成する際に指定する includes.from("ModuleDoc.md", "PackageDoc.md") } } } app/ModuleDoc.md # Module app ## パッケージ構成について | Package | Contents | | ---- | ---- | | view | view / ViewModel | | domain | logic / service | | model | Data model | | repository | Repository | | infra.api | Remote Resource | | infra.db | Local DB | | infra.local | Local Resource | app/PackageDoc.md #Package jp.co.foxsal.githubreader.view.repolist リポジトリ一覧 #Package jp.co.foxsal.githubreader.view.repodetail リポジトリ詳細 ドキュメント生成 ./gradlew dokkaHtml または ./gradlew dokkaJavadoc 成果物イメージ dokkaHtml dokkaJavadoc 参考リンク KDoc dokkaHtmlのオプション設定
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Android開発におけるドキュメント作成"Dokka / KDoc"の導入手順

Dokkaとは "KDoc"形式で記載したコメントを、Javadocと同様な形でドキュメントを作成できる。 JavaとKotlinが混在したプロジェクトのドキュメントも生成可能 導入 project/build.gradle buildscript { ext { dokka_version = "1.6.10" } dependencies { classpath "org.jetbrains.dokka:dokka-gradle-plugin:${dokka_version}" } app/build.gradle apply plugin: "org.jetbrains.dokka" android {} dependencies {} // dokkaHtml 用の設定 dokkaHtml.configure { outputDirectory.set(new File("${buildDir}/dokkaHtml")) dokkaSourceSets { configureEach { // Moduleやパッケージに対するドキュメントを作成する際に指定する includes.from("ModuleDoc.md", "PackageDoc.md") } } } モジュールコメント ここで全体的なパッケージ構成を書いておくと理解が進みそう app/ModuleDoc.md # Module app ## パッケージ構成について | Package | Contents | | ---- | ---- | | view | view | | viewmodel | ViewModel | | domain | logic / service | | model | Data model | | repository | Repository | | infra.api | Remote Resource | | infra.db | Local DB | | infra.local | Local Resource | パッケージコメント パッケージに対するコメント app/PackageDoc.md #Package jp.co.foxsal.githubreader.view.repolist リポジトリ一覧 #Package jp.co.foxsal.githubreader.view.repodetail リポジトリ詳細 クラス/メソッド等のコメント KDoc形式で各所に記載する ドキュメント生成 ./gradlew dokkaHtml または ./gradlew dokkaJavadoc 成果物イメージ dokkaHtml dokkaJavadoc 参考リンク KDoc dokkaHtmlのオプション設定
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Gradle 6.7.1以下 -> 6.8以上 にアップデートするとbuild.gradleのdependenciesのexcludeの挙動が変わる

概要 androidアプリを作成中、gradleをアップデートしたら、それまで問題なく使えていたアプリソース中のkotlinファイルでのimport kotlinx.coroutines.CoroutineDispatcherに対してUnresolved reference: CoroutineDispatcherとエラーメッセージがつくようになってビルドができなくなった。  アプリケーションモジュールのbuild.gradleのdependenciesにimplementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:$kotlin_coroutine_ver"を追加してやったところビルドが通るようになった。 理由 アプリで使っているcoroutineライブラリとpagingライブラリに入っているそれとがバージョンが違っていたのでpagingライブラリのほうから抜くためにアプリケーションモジュールのbuild.gradleのdependenciesで以下のようにしていたのだが、gradle 6.8以上にしたところなぜかアプリ全体の依存から除外されるようになってしまったもよう。 gradle6.8だけではなく、6.9.1や7.0.2にしても同様の挙動をしたのでバグではなく仕様と思われる。 gradleのrelease noteも読んでみたけど、軽くさらっただけでは明確な仕様の変更の記述は見つけることができなかった。 dependencies { implementation('androidx.paging:paging-runtime-ktx:3.0.1') { exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-core-jvm" } } 詳細なコード gradle 6.7.1時代 gradle/gradle-wrapper.properties #Sun Jan 09 17:34:51 JST 2022 distributionBase=GRADLE_USER_HOME distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME プロジェクトレベルのbuild.gradle // Top-level build file where you can add configuration options common to all sub-projects/modules. allprojects { repositories { google() mavenCentral() } } buildscript { repositories { google() mavenCentral() } dependencies { classpath "com.android.tools.build:gradle:4.2.2" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } task clean(type: Delete) { delete rootProject.buildDir } アプリケーションモジュールのbuild.gradle buildscript { repositories { maven { url 'https://maven.google.com' } mavenCentral() google() } dependencies { classpath 'com.android.tools.build:gradle:4.2.2' } } plugins { id 'com.android.application' id 'kotlin-android' id 'kotlin-kapt' } android { compileSdk 32 defaultConfig { applicationId "com.kkkkan.coroutineresearch" minSdk 24 targetSdk 32 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' } } dependencies { implementation 'androidx.appcompat:appcompat:1.4.0' implementation 'com.google.android.material:material:1.4.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.1' testImplementation 'junit:junit:4.+' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2' implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1' implementation('androidx.paging:paging-runtime-ktx:3.0.1') { // バージョンが食い違うので除外 exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-core-jvm" } } gradle 6.8 アップデート後 gradle/gradle-wrapper.properties #Sun Jan 09 17:34:51 JST 2022 distributionBase=GRADLE_USER_HOME #以下変更 6.7.1->6.8に distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip #変更終了 distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME プロジェクトレベルのbuild.gradle // Top-level build file where you can add configuration options common to all sub-projects/modules. allprojects { repositories { google() mavenCentral() } } buildscript { repositories { google() mavenCentral() } dependencies { classpath "com.android.tools.build:gradle:4.2.2" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } task clean(type: Delete) { delete rootProject.buildDir } アプリケーションモジュールのbuild.gradle buildscript { repositories { maven { url 'https://maven.google.com' } mavenCentral() google() } dependencies { classpath 'com.android.tools.build:gradle:4.2.2' } } plugins { id 'com.android.application' id 'kotlin-android' id 'kotlin-kapt' } android { compileSdk 32 defaultConfig { applicationId "com.kkkkan.coroutineresearch" minSdk 24 targetSdk 32 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' } } dependencies { implementation 'androidx.appcompat:appcompat:1.4.0' implementation 'com.google.android.material:material:1.4.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.1' testImplementation 'junit:junit:4.+' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2' // 以下追加。gradle 6.8にアップデートしたら、これがないとビルドが通らなくなった。 implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.2" // 追加終了。 implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1' implementation('androidx.paging:paging-runtime-ktx:3.0.1') { // バージョンが食い違うので除外 exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-core-jvm" } }
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

集中力を維持するためのポモドーロタイマー

学内の学生主体で進めるプロジェクトで「ユーザの集中力を持続させるシステム」を構築する機会がありました。 その際にポモドーロタイマーを用いて休憩時間を管理してくれるアプリを作成致しましたので、その内容について少しだけ触れさせて頂きます。 まず今回使用したのはReact Nativeです。iosとandroidの双方に対応できるクロスプラットフォームフレームワークを使用したいという理由から使用しました。 上の画像が実際のアプリ画面です。 左上にタスクに取り組む時間を、右上に休憩時間を打ち込み、開始ボタンを押します。 指定した時間が過ぎると端末が振動し、テキストが変化します。 簡単かつシンプルですが、作っていて楽しかったのでよし!!
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む