I want to use LazyVerticalGrid - android

Wow! This is my first question in stackoverflow. And my english is not good yet.
I want to use LazyVerticalGrid. So I try to change compose_version to '1.1.1'.
e: This version (1.1.1) of the Compose Compiler requires Kotlin version 1.6.10 but you appear to be using Kotlin version 1.5.31 which is not known to be compatible. Please fix your configuration (or `suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!).
But I use Kotlin 1.7.0. Oh, tool is Android studio. I already checked android studio Kotlin version.
I changed
build.gradle(:app)
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 32
defaultConfig {
minSdk 30
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
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'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerVersion "1.6.4"
kotlinCompilerExtensionVersion '1.1.1'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
implementation "androidx.compose.compiler:compiler:1.1.1"
implementation 'androidx.core:core-ktx:1.8.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-runtime-ktx:2.4.1'
implementation 'androidx.activity:activity-compose:1.4.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
}
build.gradle(app)
buildscript {
ext {
compose_version = '1.1.1'
kotlin_verison='1.6.4'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.5.31' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
common to all sub-projects/modules.
second error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details
some scripts told me you have to changed dependencies. but how?...
Is there a secret to adding a dependencies that fits the error?

buildscript {
ext {
compose_version = '1.1.1'
kotlin_verison='1.6.4' >>>> Typo
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
you have a typo on kotlin_version
And on the first error, it tells you to use minimum kotlin version 1.6.10.
you just need to change this line from version '1.5.31' to 1.6.10 or the newest version of it.
id 'org.jetbrains.kotlin.android' version '1.5.31' apply false

Related

How to update Jetpack Compose version in a project?

I want to update dependencies to latest version of Jetpack Compose. I tried to change version texts in gradle files but build error. Also I can't find what is the latest version of Jetpack Compose.
build.gradle (Project)
buildscript {
ext {
compose_version = '1.2.0'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.4.1' apply false
id 'com.android.library' version '7.4.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
}
build.gradle (Module:app)
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
namespace 'com.example.android'
compileSdk 33
defaultConfig {
applicationId "com.example.android"
minSdk 24
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
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'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.2.0'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.1'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.compose.material3:material3:1.0.0-alpha11'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
}
I tried and searched on internet for two days but always build error.I'm very noob at this jobs, so it didn't work.
Jetpack compose has switched to using a bill of materials (BOM) to combine compatible library versions.
Check out the documentation:
dependencies {
// Import the Compose BOM
implementation platform('androidx.compose:compose-bom:2023.01.00')
// Import other Compose libraries without version numbers
implementation 'androidx.compose.foundation:foundation'
}
You can find the latest BOM version here.
If you are still getting build errors then you most likely need to update your kotlin plugin version.

Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1 error in compose

I am using Google map for my app with jetpack compose I implemented these dependencies
//Compose Maps
implementation 'com.google.maps.android:maps-compose:2.5.3'
implementation 'com.google.android.gms:play-services-maps:18.0.2'
in my app.gradle file
and I am getting this error
Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.5.1.
I used everything please answer this question.
my app.gradle file:-
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.mapsincompose"
minSdk 23
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
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'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
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-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
//Compose Maps
implementation 'com.google.maps.android:maps-compose:2.5.3'
implementation 'com.google.android.gms:play-services-maps:18.0.2'
}
my project.gradel file:-
buildscript {
ext {
compose_version = '1.1.0-beta01'
}
}
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
id 'org.jetbrains.kotlin.android' version '1.5.31' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The following might help you out:
Obs! Have you followed the implementation of google maps correctly ? This includes created a google cloud account for the API key and implementations of it ?
Update compose to the latest version:
compose_version = "1.3.0-beta02"
Change:
kotlinCompilerExtensionVersion = "1.2.0"
Change the plugin to:
id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
You need to make sure you have all dependencies:
a) Add this to you app.gradle file:
id 'com.google.gms.google-services'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
b) In build.gradle Project:
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' version '2.0.1' apply false
Let me know if this resolved your problem!
in ext block of project level gradle file change compose version like this :-
compose_version = '1.1.0-rc03'
and add this to the dependency in the same file like this
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
}
it worked for me and I hope it will work for every one
explanation:- basically here I just change compose version to the latest version and I change kotlin version according to the compose version support here is the full documentation.

Android Studio - How to upgrade jetpack compose?

I am currently using Android studio (2021.2.1 Patch 2). On choosing empty compose activity, the compose version being used is 1.1.0-beta01 .How can I upgrade it to 1.2.0-beta01 as the earlier one gives error while using LazyVerticalGrid? I am beginner to android. Any help would be greatly appreciated.
Here is the app/build.gradle file of the project :
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.courses"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
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'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
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-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
}
Toplevel build.gradle file :
buildscript {
ext {
compose_version = '1.1.0-beta01'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
id 'org.jetbrains.kotlin.android' version '1.5.31' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have tried changing compose version in toplevel build.gradle file to 1.2.0-beta01 but the build of the project fails.
Please specify in comments if you need some more information.
Thanks
Without seeing the compilation error message I can only guess at what might be the cause. But I see a couple of things that might give you problems.
The Compose Compiler for 1.2.0-beta01 requires Kotlin Plugin version 1.6.21 See Compose Kotlin Compatibility Map
Additionally, from version 1.2.0 onwards they've introduced independent versioning for Compose Compiler from the rest of the Compose libraries, meaning that kotlinCompilerExtensionVersion needs to point to a different version. As of right now the latest compiler version is 1.3.1 which needs kotlin plugin version 1.7.10.
Try these changes.
ext {
compose_version = '1.3.0-beta02' // or 1.2.1 if you want the latest stable version
}
composeOptions {
kotlinCompilerExtensionVersion "1.3.1"
}
plugins {
// others omitted
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
}

Passing Data Between Fragments Using Safe Args

I'm trying to implement data transfer between fragments using Safe Args, but I'm stuck at the moment of setting Gradle.
Project Gradle looks like this
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.1.3' apply false
id 'com.android.library' version '7.1.3' apply false
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Module Gradle is like this
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.main_fragmentargs"
minSdk 21
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'
}
buildFeatures{
viewBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation "androidx.navigation:navigation-fragment-ktx:2.5.0"
implementation "androidx.navigation:navigation-ui-ktx:2.5.0"
}
Wherever I enter this line, Gradle starts to swear.
apply plugin: "androidx.navigation.safeargs.kotlin"
Similar story with
def nav_version = "2.3.3"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
Please tell me how to connect it.
You have to add the plugin to your plugin closure, like described in the documentation.
Add this to your top level build.gradle:
buildscript {
repositories {
google()
}
dependencies {
def nav_version = "2.5.0"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
}
}
...
and this to your app modules build.gradle:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'androidx.navigation.safeargs.kotlin'
}
...
Also make sure that android.useAndroidX=true is set in your gradle.properties files.

Could not resolve all files for configuration ':app:debugCompileClasspath'. using Android Studio Chipmunk | 2021.2.1

I have recorded a video using mobile camera but now i want to trim that video using a library, after adding the below dependency for trimming feature.
implementation 'com.github.a914-gowtham:android-video-trimmer:1.7.0'
i am getting this error:
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugCompileClasspath'.
Here is my app level build.gradle code:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.techease.videome"
minSdk 21
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'
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//trimmer
implementation 'com.github.a914-gowtham:android-video-trimmer:1.7.0'
}
And here is the project level build.gradle:
// Top-level build file where you can add configuration options common to all sub-
projects/modules.
buildscript {
repositories {
maven { url 'https://jitpack.io' }
}
}
plugins {
id 'com.android.application' version '7.2.0' apply false
id 'com.android.library' version '7.2.0' apply false
id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Anyone having idea what i am missing here?
In the android studio from "File" menu call "Invalidate caches..."
After loading android studio build the project again. Every thing will be correct.

Categories

Resources