Why would I use $version instead of '2.7.0'? - android

I would like to understand the practise of not putting the version codes in your dependencies.
Why would I choose one practise over the other:
dependencies {
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-moshi:$moshi_version"
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
}
vs
dependencies {
implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-moshi:2.9.0"
implementation "com.squareup.okhttp3:okhttp:4.9.0"
}

Simply because it may be that the version is important for several dependencies. For example, like here:
implementation "androidx.navigation:navigation-runtime-ktx:$navigation_version"
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
So you only need to adjust the version once and don't run the risk of forgetting a change.

Related

Usage of TextField Causes NochSuchFieldError

Simply adding a TextField to a composable in Android causes a NoSuchFieldError when executing. The application works perfectly fine when I remove the TextField (the application does not contain another TextField so far).
I think it might be a dependency issue (hence the dependencies below). But I am at my wits end. What is happening?
I have already tried to invalidate cache and restart, as well as clean and rebuild the application.
Code:
TextField(
value = "text",
onValueChange = {
}
)
Error:
java.lang.NoSuchFieldError: No static field $stable of type I in class Landroidx/compose/foundation/text/KeyboardActions; or its superclasses (declaration of 'androidx.compose.foundation.text.KeyboardActions' appears in /data/app/~~uEpWT9N7xCnbk8jjsQk_yg==/xx.xxx.xxx.dev-Q5085dpAd5iQ0tK6W7b8rA==/base.apk)
at androidx.compose.material.TextFieldKt.TextField(TextField.kt:207)
Dependencies:
dependencies {
implementation 'androidx.core:core-ktx:1.9.0'
implementation "androidx.compose.ui:ui:1.3.3"
implementation "androidx.compose.material:material:1.3.1"
implementation "androidx.compose.material:material-icons-extended:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:1.3.3"
implementation "androidx.navigation:navigation-compose:2.5.3"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
implementation 'androidx.activity:activity-compose:1.6.1'
implementation 'androidx.paging:paging-common-ktx:3.1.1'
implementation "androidx.paging:paging-compose:1.0.0-alpha17"
implementation "com.google.accompanist:accompanist-systemuicontroller:0.29.0-alpha"
implementation "org.jetbrains.lets-plot:lets-plot-kotlin:3.0.0"
implementation "androidx.room:room-runtime:2.5.0"
implementation "androidx.room:room-paging:2.5.0"
annotationProcessor "androidx.room:room-compiler:2.5.0"
kapt "androidx.room:room-compiler:2.5.0"
testImplementation 'junit:junit:5.8.1'
testImplementation "io.mockk:mockk:1.13.4"
testImplementation 'org.junit.jupiter:junit-jupiter'
debugImplementation "androidx.compose.ui:ui-tooling:1.3.3"
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation "io.insert-koin:koin-android:3.2.0"
implementation "io.insert-koin:koin-androidx-compose:3.2.0"
}
Your accompanist version does not match the compose UI version.
As you can see in this page, if you use compose UI 1.3.X you should use accompanist 0.28.0

Is there a resource on the web that would help me build a clean android studio app is correct implementation versions?

I've been working with Android Studio only for a short time and it's giving me a lot of grief. I have a project that (so far) requires
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0"
implementation 'androidx.core:core-ktx:1.7.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
// added 8/29
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.3.1"
implementation 'androidx.activity:activity-compose:1.3.1'
// added
implementation 'androidx.navigation:navigation-compose:2.4.0'
// hilt
implementation "com.google.dagger:hilt-android:$hilt_version"
implementation 'androidx.datastore:datastore-core:1.0.0'
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
implementation("androidx.hilt:hilt-navigation-compose:1.0.0")
// datastore
implementation "androidx.datastore:datastore-preferences:1.0.0"
where
compose_version = '1.1.0-beta03'
hilt_version = '2.40'
kotlin_version = '1.5.30' //'1.4.32'
I've spent several hours trying to find a good set that does result in build warnings because of conflicting JDK version reported as well as messages saying I have to build using API 32 or 33 when I really want API 29. If I can build at 33 but still have minSDK of 29, that would work too.
I think a web tool where I could list the libraries and the API and it would give me the version numbers of the libraries, that would solve my problem.
Any suggestions? BTW - I'm using the Chipmunk.

I want to use one core library with different versions of JUMIO SDK for different purposes but I'm getting following error

Below are the dependencies that I'm using
implementation "com.jumio.android:core:4.0.0"
implementation "com.jumio.android:core:3.9.2"
implementation "com.jumio.android:linefinder:4.0.0"
implementation "com.jumio.android:mrz:4.0.0"
implementation "com.jumio.android:nfc:4.0.0"
implementation "com.jumio.android:barcode:4.0.0"
implementation "com.jumio.android:barcode-mlkit:4.0.0"
implementation "com.jumio.android:iproov:4.0.0"
implementation "com.jumio.android:defaultui:4.0.0"
implementation "com.jumio.android:dv:3.9.2"
Error Image is attached,Below is the link of that image
https://i.stack.imgur.com/UeHoI.png
If i include,implementation "com.jumio.android:dv:3.9.2" dependency error occurs.This dependency needs implementation "com.jumio.android:core:3.9.2" Core dependency.

java.lang.NoSuchMethodError startRestartGroup after upgrading Jetpack Compose to 1.0.0‑beta07

I just updated the compose version to 1.0.0‑beta07, and its showing this run time error
No interface method startRestartGroup(ILjava/lang/String;)Landroidx/compose/runtime/Composer; in class Landroidx/compose/runtime/Composer; or its super classes (declaration of 'androidx.compose.runtime.Composer'
....
at com.google.accompanist.coil.CoilImage__CoilKt.CoilImage(Coil.kt:245)
at com.google.accompanist.coil.CoilImage.CoilImage(Coil.kt:1)
below is my gradle dependencies file
implementation 'androidx.core:core-ktx:1.5.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation "androidx.compose.compiler:compiler:$compose_version"
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation "androidx.compose.runtime:runtime:$compose_version"
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
implementation 'androidx.activity:activity-compose:1.3.0-alpha08'
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha05"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation "io.coil-kt:coil-gif:1.2.1"
implementation "io.coil-kt:coil-svg:1.2.1"
implementation "com.google.accompanist:accompanist-coil:0.6.2"
and version compose_version = '1.0.0-beta07'
Every library needs to be recompiled against beta07 to work, as per the Compose release notes:
Note: Libraries dependent on Compose will need to recompile with version 1.0.0‑beta07. Otherwise, libraries may encounter a NoSuchMethodError, such as:
java.lang.NoSuchMethodError: No interface method startReplaceableGroup(ILjava/lang/String;)V in class Landroidx/compose/runtime/Composer; or its super classes. (Ia34e6)
In your case you have to update the accompanist libraries with the 0.10.0.
Change:
implementation "com.google.accompanist:accompanist-coil:0.6.2"
to
implementation "com.google.accompanist:accompanist-coil:0.10.0"
Coil, Glide and Image Loading Core have been removed
After being deprecated in v0.14.0, it's time to remove the coil, glide and imageloading-core libraries. Some discussion about this can be seen on the Kotlin Slack: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1627482619344000. the recommendation is to move to https://coil-kt.github.io/coil/compose/
So Change ;
implementation "com.google.accompanist:accompanist-coil:0.6.2"
to
implementation("io.coil-kt:coil-compose:1.3.2")
Also;
CoilImage removed too, you can use;
Image(
painter = rememberImagePainter("https://www.example.com/image.jpg"),
contentDescription = null,
modifier = Modifier.size(128.dp)
)
Make sure that all your compose libraries are all using the same version 1.0.0-beta07. That should resolve your issue.

Why does the new LiveData builder from Kotlin May update not working in my project

Here are my dependencies:
//Room and Lifecycle Libraries
kapt "androidx.room:room-compiler:2.2.0-alpha02"
kapt 'androidx.room:room-compiler:2.2.0-alpha02'
kapt "androidx.lifecycle:lifecycle-compiler:2.2.0-alpha03"
implementation "androidx.room:room-runtime:2.2.0-alpha02"
implementation 'androidx.room:room-runtime:2.2.0-alpha02'
implementation "androidx.lifecycle:lifecycle-viewmodel:2.2.0-alpha03"
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0-alpha03"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0-alpha03"
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0-alpha03"
implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'
As you can see, I implemented the final versions and yet I do not have access to the liveData builder. How can I fix this?
From the documentation:
For liveData, use androidx.lifecycle:lifecycle-livedata-ktx:2.2.0-alpha01 or higher.
So you're just missing the dependency:
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0-alpha03"

Categories

Resources