Why my Gradle is showing Read Time out after adding Realm Database - android

I just add Realm Database in my Project. But now my Gradle giving me error "Read Time out"
Below I'm showing full error image.
I'm Following Realm Documentation as they mention but still getting Error.
Please help me I'm trying to resolve this issue but didn't get any single issue related to this
build.gradle(Project)
buildscript {
repositories {
maven {
url 'https://jitpack.io'
}
google()
jcenter()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
classpath "io.realm:realm-gradle-plugin:10.9.0"
// 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(Module)
plugins {
id 'com.android.application'
id 'realm-android'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.app.model_farming"
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
}
buildFeatures {
viewBinding true
}
}
realm {
syncEnabled = true
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.google.code.gson:gson:2.8.8'
implementation 'com.squareup.okhttp3:logging-interceptor:4.3.1'
// Meow Bottom Navigation Bar -- Not to Update
implementation 'com.etebarian:meow-bottom-navigation:1.2.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.32"
//OTP PinView
//Loading Bar
implementation 'com.github.ybq:Android-SpinKit:1.4.0'
//Shimmer
implementation 'com.facebook.shimmer:shimmer:0.5.0'
// Lottie dependency
def lottieVersion = "3.4.0"
//noinspection GradleDependency
implementation "com.airbnb.android:lottie:$lottieVersion"
implementation 'com.evrencoskun.library:tableview:0.8.9.4'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
}

on build.gradle(Module) , add (id 'kotlin-kapt') before (id 'realm-android')
plugins {
id 'com.android.application'
id 'kotlin-kapt'
id 'realm-android'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.app.model_farming"
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
}
buildFeatures {
viewBinding true
}
}
realm {
syncEnabled = true
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.google.code.gson:gson:2.8.8'
implementation 'com.squareup.okhttp3:logging-interceptor:4.3.1'
// Meow Bottom Navigation Bar -- Not to Update
implementation 'com.etebarian:meow-bottom-navigation:1.2.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.32"
//OTP PinView
//Loading Bar
implementation 'com.github.ybq:Android-SpinKit:1.4.0'
//Shimmer
implementation 'com.facebook.shimmer:shimmer:0.5.0'
// Lottie dependency
def lottieVersion = "3.4.0"
//noinspection GradleDependency
implementation "com.airbnb.android:lottie:$lottieVersion"
implementation 'com.evrencoskun.library:tableview:0.8.9.4'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
}

Related

Cannot resolve symbol 'File' in settings gradle

I'm using the android studios IDE, SDK version 32, build tools 33, and java version 1.8
I keep getting the error
Cannot resolve symbol 'File'
And actually the gradle syncs somehow and the file is created, but I need to solve the error
This is the settings gradle:
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven {
url "https://dl.cloudsmith.io/public/cometchat/cometchat-pro-android/maven/"
}
}
}
rootProject.name = "ViegerT2"
include ':app'
include ':uikit'
project(':uikit').projectDir = new File(rootDir, 'android-java-chat-ui-
kit/uikit/')
This is the project gradle:
// 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.6.10' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is the APP gradle:
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.viegert2"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
manifestPlaceholders = [file_provider: "ViagerT2"]
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
}
packagingOptions {
exclude 'META-INF/proguard/androidx-annotations.pro'
exclude 'META-INF/androidx.cardview_cardview.version'
}
buildToolsVersion '33.0.0'
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.5.0'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.annotation:annotation:1.4.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
//noinspection GradleCompatible
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
apply plugin: 'kotlin-android-extensions'
//implementation 'androidx.core:core-ktx:1.3.2'
//implementation 'androidx.appcompat:appcompat:1.3.1'
//implementation 'com.google.android.material:material:1.4.0'
//implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation platform('com.google.firebase:firebase-bom:29.0.0')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-auth-ktx'
implementation 'com.google.firebase:firebase-database-ktx'
implementation 'com.google.firebase:firebase-storage-ktx'
implementation 'com.cometchat:pro-android-chat-sdk:3.0.0'
implementation 'com.cometchat:pro-android-calls-sdk:2.1.0'
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation 'com.github.bumptech.glide:glide:4.12.0'
//implementation project(path: ':uikit-kotlin')
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
implementation project(path: ':uikit')
}
And I also have this module gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 30
defaultConfig {
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "3.0.9-1"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
renderscriptSupportModeEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
ndk {
abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
java.srcDirs = ['src/main/java', '.apt_generated']
aidl.srcDirs = ['src/main/aidl', '.apt_generated']
res.srcDirs = [
'src/main/res',
'src/main/res-components',
'src/main/res-components/calls',
'src/main/res-components/chats',
'src/main/res-components/cometchatui',
'src/main/res-components/groups',
'src/main/res-components/messagebubbles',
'src/main/res-components/messages',
'src/main/res-components/others',
'src/main/res-components/shared',
'src/main/res-components/userprofile',
'src/main/res-components/users'
]
}
}
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion = '28.0.3'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.preference:preference:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//RecyclerView
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.emoji:emoji:1.1.0-rc01'
implementation 'androidx.emoji:emoji-bundled:1.1.0'
implementation 'androidx.emoji:emoji-appcompat:1.0.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
implementation 'com.google.android.material:material:1.2.0-alpha04'
implementation 'com.facebook.shimmer:shimmer:0.4.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
//cometchat
compileOnly 'com.cometchat:pro-android-chat-sdk:3.0.9'
compileOnly 'com.cometchat:pro-android-calls-sdk:2.2.0'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.0'
}

android - Failed to add navigation dependency

I am trying to add navigation library in android studio but fails to add here is my build.gradle(app)
plugins {
id 'com.android.application'
}
android {
compileSdk 33
defaultConfig {
applicationId "com.example.practice_8"
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
}
buildFeatures {
viewBinding true
}
}
dependencies {
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.lifecycle:lifecycle-livedata-ktx:2.5.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
implementation 'androidx.navigation:navigation-fragment:2.5.1'
implementation 'androidx.navigation:navigation-ui:2.5.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Try this
In your app/gradle, add
plugins {
id 'com.android.application'
id 'androidx.navigation.safeargs'
}
def nav_version = "2.5.1"
inside dependency{ } add
// Kotlin
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
in project/gradle add
buildscript {
repositories {
google()
}
dependencies {
def nav_version = "2.5.1"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
}
}
and sync your gradle
Here is reference
Android Nav

Failed to add navigation dependency

I am trying to Add Navigation in my project but its showing failed to add Navigation dependency,
when i click on 'ok' in the window to add these now , its showing failed to add dependency and my navigation xml editor is not visible
here are some screen shots
my build.gradle (app) :-
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.google.gms.google-services'
id 'kotlin-android-extensions'
}
android {
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.choudhary.myshop"
minSdkVersion 21
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
androidExtensions {
experimental = 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{
viewBinding = true
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
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'
implementation 'com.google.firebase:firebase-auth-ktx:21.0.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.4.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation platform('com.google.firebase:firebase-bom:29.0.4')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation platform('com.google.firebase:firebase-bom:29.0.0')
implementation 'com.google.firebase:firebase-firestore'
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
implementation 'com.google.firebase:firebase-storage-ktx'
def lifecycle_version = "2.5.0-alpha01"
def arch_version = "2.1.0"
// ViewModel
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version")
// ViewModel utilities for Compose
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version")
// LiveData
implementation("androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version")
def nav_version = "2.4.0"
// Kotlin
implementation("androidx.navigation:navigation-fragment-ktx:$nav_version")
implementation("androidx.navigation:navigation-ui-ktx:$nav_version")
// Feature module Support
implementation("androidx.navigation:navigation-dynamic-features-fragment:$nav_version")
// Testing Navigation
androidTestImplementation("androidx.navigation:navigation-testing:$nav_version")
// Jetpack Compose Integration
implementation("androidx.navigation:navigation-compose:2.5.0-alpha01")
}
my build.gradle (project ) :-
buildscript {
ext.kotlin_version = "1.4.32"
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Seems like Navigation with version 2.3.6 - 2.4.* shows that problem
You can change only
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.4.0'
to
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
delete all navigation dependency related , and add this :
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
Add 2.3.4 instead of 2.3.5/2.5.3
It's working...

Autocomplete or Code Analyzer not working in Android Studio

I am currently working on recyclerview adapter. I can not work further because my autocomplete/code analyzer is apparently not working. I need it to generate the implementation of Recyclerview.Adapter automatically. please help me..
I have a hunch that the problem was caused by my gradle configuration. FYI, everything works fine before i resync my gradle (module). here is my current gradle configuration:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.toharifqi.myfavoritesports"
minSdkVersion 21
targetSdkVersion 30
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 "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation "androidx.constraintlayout:constraintlayout:$constraint_version"
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation "com.github.bumptech.glide:glide:$glide_version"
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.recyclerview:recyclerview:$recyclerview_version"
kapt "androidx.room:room-compiler:$room_version"
androidTestImplementation "androidx.room:room-testing:$room_version"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
implementation "com.squareup.okhttp3:logging-interceptor:$logging_interceptor_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
implementation "androidx.room:room-ktx:$room_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "org.koin:koin-core:$koin_version"
implementation "org.koin:koin-android:$koin_version"
implementation "org.koin:koin-android-viewmodel:$koin_version"
}
and this is my gradle configuration for project level:
buildscript {
ext.kotlin_version = "1.4.10"
ext.appcompat_version = "1.1.0"
ext.core_ktx_version = "1.3.2"
ext.constraint_version = "2.0.4"
ext.legacy_support_version = "1.0.0"
ext.junit_version = "4.13.1"
ext.androidx_junit_version = "1.1.2"
ext.espresso_version = "3.3.0"
ext.multidex_version = "2.0.1"
ext.cardview_version = "1.0.0"
ext.recyclerview_version = "1.1.0"
ext.material_version = "1.2.1"
ext.glide_version = "4.12.0"
ext.room_version = "2.2.5"
ext.retrofit_version = "2.9.0"
ext.logging_interceptor_version = '4.9.0'
ext.kotlin_coroutines_version = "1.3.9"
ext.lifecycle_version = "2.2.0"
ext.koin_version = "2.1.6"
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have just found the problem, it was caused by my android core ktx version. previously it was implementation 'androidx.core:core-ktx:1.5.0'. After I changed to implementation 'androidx.core:core-ktx:1.3.2' everything works fine. thank you

Android Studio Arctic Fox | 2020.3.1 Canary 15 |Compose Build error: Could not find androidx.compose:compose-compiler:1.0.0-beta06 |

as the title suggests I can't understand what the problem is when I try to deploy on the device.
The deployment fails when I try to add kotlinCompilerExtensionVersion '1.0.0-beta06' to the gradle
and the error message is "Could not resolve all files for configuration ': app: kotlin-extension'. Could not find androidx.compose: compose-compiler: 1.0.0-beta06."
What I'm trying to do is add a piece of code written in compose starting from an existing project, and I'm following this guide https://developer.android.com/jetpack/compose/interop/interop-apis
I paste my gradle below:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-parcelize'
id 'kotlin-kapt'
id 'androidx.navigation.safeargs'
}
android {
compileSdkVersion rootProject.findProperty("android.compileSdkVersion") as Integer
buildToolsVersion "29.0.3"
defaultConfig {
applicationId findProperty("android.applicationId")
targetSdkVersion findProperty("android.targetSdkVersion") as Integer
minSdkVersion findProperty("android.minSdkVersion") as Integer
versionCode findProperty("android.minSdkVersion") as Integer
versionName findProperty("android.versionName")
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 = JavaVersion.VERSION_1_8.toString()
}
buildFeatures {
dataBinding true
// Enables Jetpack Compose for this module
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.0.0-beta06'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "androidx.core:core-ktx:$ktx_version"
implementation "androidx.legacy:legacy-support-v4:$legacy_version"
implementation "androidx.constraintlayout:constraintlayout:$constraint_layout_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.recyclerview:recyclerview:$recyclerview_version"
implementation "com.google.android.material:material:$material_version"
// Retrofit
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-moshi:$retrofit_version"
implementation "com.squareup.moshi:moshi-kotlin:$moshi_version"
// Navigation
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
// Compose
implementation "androidx.navigation:navigation-compose:$navigation_compose_version"
// Material Design
implementation "androidx.compose.material:material:$compose_version"
// Tooling support (Previews, etc.)
implementation "androidx.compose.ui:ui-tooling:$compose_version"
// Foundation (Border, Background, Box, Image, Scroll, shapes, animations, etc.)
implementation "androidx.compose.foundation:foundation:$compose_version"
// Material design icons
implementation "androidx.compose.material:material-icons-core:$compose_version"
implementation "androidx.compose.material:material-icons-extended:$compose_version"
// Integration with activitie
implementation "androidx.activity:activity-compose:1.3.0-alpha07"
// Integration with ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha04"
// Integration with observable
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
implementation "androidx.compose.runtime:runtime-rxjava2:$compose_version"
// Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutine_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutine_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutine_version"
// Room
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-ktx:$room_version"
// Work Manager
implementation "androidx.work:work-runtime-ktx:$work_version"
// Timber
implementation "com.jakewharton.timber:timber:$timber_version"
// Glide
implementation "com.github.bumptech.glide:glide:$glide_version"
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
I'm using last version at moment I'm writing:
android.targetSdkVersion=30
android.minSdkVersion=28
android.versionCode=1
android.versionName=1.0.0
# gradle.properties
kotlin_version=1.4.30
gradle_version=4.1.1
ktlint_version=9.2.1
safe_args_version=1.0.0
appcompat_version=1.2.0
ktx_version=1.3.2
legacy_version=1.0.0
constraint_layout_version=2.0.4
lifecycle_version=2.3.1
recyclerview_version=1.2.0
material_version=1.3.0
retrofit_version=2.9.0
moshi_version=1.9.2
navigation_version=2.3.5
navigation_compose_version=1.0.0-alpha10
compose_version=1.0.0-beta06
coroutine_version=1.4.2
room_version=2.3.0
work_version=2.5.0
timber_version=4.7.1
glide_version=4.12.0
I'm following the official setup but not seem woking
https://developer.android.com/jetpack/compose/setup
I had this issue yesterday. What I did was adding compiler in the compose option.
composeOptions {
kotlinCompilerVersion "1.4.32"
kotlinCompilerExtensionVersion "1.0.0-beta06"
}
Found somewhat similar issue to yours in stackoverflow here. You may need to upgrade your gradle version.
Also here, (if you haven't already) set ext.kotlin_version = ..... in the project gradle
buildscript {
ext.kotlin_version = "1.4.32"
ext { .... }
repositories {
mavenCentral()
google()
}
allprojects {
repositories {
mavenCentral()
google()
maven { url "https://jitpack.io" }
}
}
}
Finally found the problem.
Inside build.gradle (project level) I was using:
classpath "com.android.tools.build:gradle:$gradle_version"
So creating new Compose project I found how to fix the problem. In particular:
build.gradle (project level) is like:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.0-alpha15"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32"
classpath "org.jlleitschuh.gradle:ktlint-gradle:$ktlint_version"
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5")
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (app level) is like:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-parcelize'
id 'kotlin-kapt'
id 'androidx.navigation.safeargs'
}
android {
compileSdkVersion rootProject.findProperty("android.compileSdkVersion") as Integer
buildToolsVersion "29.0.3"
defaultConfig {
applicationId findProperty("android.applicationId")
targetSdkVersion findProperty("android.targetSdkVersion") as Integer
minSdkVersion findProperty("android.minSdkVersion") as Integer
versionCode findProperty("android.minSdkVersion") as Integer
versionName findProperty("android.versionName")
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'
useIR = true
}
buildFeatures {
dataBinding true
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerVersion '1.4.32'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "androidx.core:core-ktx:$ktx_version"
implementation "androidx.legacy:legacy-support-v4:$legacy_version"
implementation "androidx.constraintlayout:constraintlayout:$constraint_layout_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.recyclerview:recyclerview:$recyclerview_version"
implementation "com.google.android.material:material:$material_version"
// Retrofit
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-moshi:$retrofit_version"
implementation "com.squareup.moshi:moshi-kotlin:$moshi_version"
// Navigation
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
// Compose
implementation "androidx.navigation:navigation-compose:$navigation_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.lifecycle:lifecycle-runtime-ktx:2.3.1'
implementation 'androidx.activity:activity-compose:1.3.0-alpha07'
// Kotlin
implementation "androidx.fragment:fragment-ktx:$fragment_version"
// Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutine_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutine_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutine_version"
// Room
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-runtime:$room_version"
implementation "androidx.room:room-ktx:$room_version"
// Work Manager
implementation "androidx.work:work-runtime-ktx:$work_version"
// Timber
implementation "com.jakewharton.timber:timber:$timber_version"
// Glide
implementation "com.github.bumptech.glide:glide:$glide_version"
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
and Upgrade JDK to 11 using embedded JDK
and at last upgrade gradle to 7.0.0
P.S.
here gradle.properties:
# Common Android settings
android.compileSdkVersion=30
android.applicationId=com.composetest.application
android.targetSdkVersion=30
android.minSdkVersion=28
android.versionCode=1
android.versionName=1.0.0
# gradle.properties
kotlin_version=1.4.32
gradle_version=4.1.1
ktlint_version=9.2.1
safe_args_version=1.0.0
appcompat_version=1.3.0-beta01
ktx_version=1.3.2
legacy_version=1.0.0
constraint_layout_version=2.0.4
lifecycle_version=2.3.1
recyclerview_version=1.2.0
material_version=1.3.0
retrofit_version=2.9.0
moshi_version=1.9.2
navigation_version=2.3.5
navigation_compose_version=1.0.0-alpha10
compose_version=1.0.0-beta06
coroutine_version=1.4.2
room_version=2.3.0
work_version=2.5.0
timber_version=4.7.1
glide_version=4.12.0
fragment_version = 1.3.3

Categories

Resources