Did anyone encounter the same issue? When using Dokka to document a data class
/**
* Data class for which we want documentation
*/
data class DokkaData(
/** A String value */
val aString: String,
/** An Integer value */
val anInt: Int,
/** Yes, a Boolean value. My favorite. */
val aBoolean: Boolean) {
/**
* Checks that all values are representation of `1`
*/
fun isOne() = aString == "1" && anInt == 1 && aBoolean
}
the documentation is correctly displayed in Android Studio
But then, when exporting library to mavenLocal using dokkaJavadoc:
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'maven-publish'
id("org.jetbrains.dokka") version "1.6.10"
}
android {
compileSdk 31
defaultConfig {
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
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.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
task dokkaJavadocJar(type: Jar, dependsOn: dokkaJavadoc) {
archiveClassifier.set("javadoc")
from dokkaJavadoc.outputDirectory
}
publishing {
publications {
release(MavenPublication) {
groupId = "com.dokkatests.testlib"
artifactId = "lib"
version = "2.1-dataDoc"
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
artifact(dokkaJavadocJar)
}
}
}
the generated library javadoc is correctly displayed for methods, but not for the data class level
Note: The html documentation is complete, the issue is only for the documentation displayed in Android Studio. I didn't find any other reference to this issue, which is strange because it looks like a blocker to me.
Any clue?
Move KDoc comments of property of data class to be at class level and use #property or #param
example
Related
Dao Interface Image
In this in the line
#Insert(onConflict = onConflictStrategy.IGNORE)
android studio says
Unresolved reference: onConflictStrategy
and in the line
#Query("Select * from notes_table order by id ASC")
The whole string is of green color while the words Select, from, order by and ASC should be orange
Here is my build.gradle
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-android'
id 'kotlin-kapt'
}
android {
namespace 'com.example.scribbles'
compileSdk 33
defaultConfig {
applicationId "com.example.scribbles"
minSdk 21
targetSdk 33
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
}
packagingOptions {
exclude 'META-INF/atomicfu.kotlin_module'
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "androidx.appcompat:appcompat:1.6.1"
implementation "androidx.activity:activity-ktx:1.6.1"
// Dependencies for working with Architecture components
// You'll probably have to update the version numbers in build.gradle (Project)
// Room components
implementation "androidx.room:room-runtime:2.5.0"
implementation "androidx.room:room-ktx:2.5.0"
kapt "androidx.room:room-compiler:2.5.0"
androidTestImplementation "androidx.room:room-testing:2.5.0"
// Lifecycle components
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.5.1"
implementation "androidx.lifecycle:lifecycle-common-java8:2.5.1"
// Kotlin components
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.20"
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
// UI
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation "com.google.android.material:material:1.8.0"
// Testing
testImplementation "junit:junit:4.13.2"
androidTestImplementation "androidx.arch.core:core-testing:2.1.0"
androidTestImplementation ("androidx.test.espresso:espresso-core:3.4.0", {
exclude group: 'com.android.support', module: 'support-annotations'
})
androidTestImplementation "androidx.test.ext:junit:1.1.5"
}
package com.example.scribbles
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
#Entity(tableName = "notes_table")
class Note(#ColumnInfo(name = "text")val text:String) {
#PrimaryKey(autoGenerate = true) var id = 0
}
I checked the dependencies version are up to date and imported androidx.room.OnconflictStrategy
but it was saying unused import directive.
Change onConflictStrategy to OnConflictStrategy and yo'll be fine.
It's a highly discussed problem on SO, but I couldn't find an up-to-date solution after hours of searching. Sadly I can't add comments anywhere.
I'm setting the versionName and versionCode in my build.gradle using the gradle-android-git-version Plugin. I now want to alter the name of the build outputfile from my-sdk-release.aar to my-sdk-release-versionName.aar or similar.
However, any solutions presented did not work, because properties were not found. The documentation on that matter seems to be outdated as well, OutputFile is long deprecated.
Going with the newest one I could find:
afterEvaluate {
android.libraryVariants.all { variant ->
variant.variantData.outputFactory.apkDataList.each { apkData ->
if (apkData.outputFileName.endsWith('.aar')) {
apkData.outputFileName = "${project.name}-${buildType.name}-anything-you-want.aar"
}
}
}
}
which is giving me the error No such property: outputFactory for class: com.android.build.gradle.internal.variant.LibraryVariantData on Gradle 7.3.3
My build.gradle goes as follows:
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
id 'com.gladed.androidgitversion' version '0.4.14'
}
android {
compileSdk 33
defaultConfig {
minSdk 24
targetSdk 33
versionName androidGitVersion.name()
versionCode androidGitVersion.code()
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
kotlinOptions {
freeCompilerArgs += [
'-opt-in=kotlin.RequiresOptIn',
'-Xexplicit-api=strict'
]
}
afterEvaluate {
android.libraryVariants.all { variant ->
variant.variantData.outputFactory.apkDataList.each { apkData ->
if (apkData.outputFileName.endsWith('.aar')) {
apkData.outputFileName = "${project.name}-${buildType.name}-anything-you-want.aar"
}
}
}
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'no.nordicsemi.android:ble-ktx:2.5.1'
implementation 'no.nordicsemi.android.support.v18:scanner:1.5.1'
implementation 'commons-codec:commons-codec:1.13'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.2'
testImplementation 'junit:junit:4.13.2'
}
What did I do wrong?
I have been trying to implement comet Chat sdk into my project. I followed the documentation for kotlin but each time i try to initialize comet chat i get several errors. Here are my codes. 1. Main Activity
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
initCometChat()
}
private fun initCometChat() {
private val appID = "208314db190ca55b"
private val region = "us"
val appSettings = AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(region).build()
CometChat.init(this, appID, appSettings, object : CallbackListener<String>() {
override fun onSuccess(successMessage: String) {
}
override fun onError(e: CometChatException) {
}
})
}
project level build gradle
plugins {
id 'com.android.application' version '7.1.1' apply false
id 'com.android.library' version '7.1.1' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The CometChat.init() function returns an error marked with red. I am new to kotlin and so i do not know how sdks work. Please help me. Thank you
app level build gradle
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.chat.comet"
minSdk 21
targetSdk 31
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.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.cometchat:pro-android-chat-sdk:3.0.4'
}
It seems that my Android Studio is not recognizing the 'androidx.core:core-ktx:1.2.0' package. Android Studio version: 3.6.1
My gradle.properties:
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
My app module build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
defaultConfig {
applicationId "cz.nn.example.myapplication"
minSdkVersion 25
targetSdkVersion 29
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.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
}
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}
When I try to use extension functions like:
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val manager = systemService<NotificationManager>()
SharedPreferences.edit {
}
}
}
functions systemService<NotificationManager>() and edit are not recognized. What am I doing wrong?
TL;DR
You are using them wrongly
First of all SharedPreferences.edit() extension function is not static and needs an instance of SharedPreferences to be used on. Try this:
val prefs = getSharedPreferences("com.example.yourapp", Context.MODE_PRIVATE)
prefs.edit { putString("myString", "myValue") }
Secondly, the method is called getSystemService, not systemService. So, this will work:
val manager = getSystemService<NotificationManager>()
I added it when I made the project. AndroidX Artifact(checkBox) has not been mqt communication since then. What is the problem?
Androidx is used to use BiometricPrompt.
Below is my mqtt code.↓
private lateinit var mqttAndroidClient: MqttAndroidClient
val CLINET_ID: String = MqttClient.generateClientId()
fun connect(applicationContext : Context) {
val context: Context = applicationContext
mqttAndroidClient = MqttAndroidClient ( context.applicationContext,"tcp://13.124.231.98:1883",
CLINET_ID )
try {
val token = mqttAndroidClient.connect()
token.actionCallback = object : IMqttActionListener {
override fun onSuccess(asyncActionToken: IMqttToken) {
Log.i("Connection", "success ")
//connectionStatus = true
// Give your callback on connection established here
// publish("test", "open")
}
override fun onFailure(asyncActionToken: IMqttToken, exception: Throwable) {
//connectionStatus = false
Log.i("Connection", "failure")
// Give your callback on connection failure here
exception.printStackTrace()
}
}
} catch (e: MqttException) {
// Give your callback on connection failure here
e.printStackTrace()
}
}
Errors in the code above -> val token = mqttAndroidClient.connect()
My Build
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 28
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-
rules.pro'
}
}
buildToolsVersion '28.0.3'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.core:core-ktx:1.2.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
//fingerPrint
implementation 'androidx.biometric:biometric:1.0.0-beta01'
//mqtt
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.2'
implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
}
Is it a version problem?
I tried BiometricPrompt. in the version other than androidx to solve this problem, but an error occurred in the code that generated the Fragment and failed to resolve it.
Finally, I thought it would be good to run mqtt on Androidx, so I tried several times but failed.
If you've had a similar experience with me and you've solved it, help.
You should add the following dependencies to with androidx
androidx.legacy:legacy-support-v4:1.0.0
androidx.localbroadcastmanager:localbroadcastmanager:1.0.0
Find the conversion of the issue in GitHub here