I follow google guidlines to setup compose in my project, this is my app-level build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-kapt'
apply plugin: 'dagger.hilt.android.plugin'
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
applicationId "com.super.note"
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode rootProject.versionCode
versionName rootProject.versionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
useIR = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion Versions.compose
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation Kotlin.stdlib
implementation AndroidX.coreKtx
implementation AndroidX.appcompat
implementation AndroidX.constraintLayout
implementation AndroidX.recyclerView
implementation Lifecycle.extensions
implementation Lifecycle.livedata
implementation Material.core
implementation AndroidX.legacySupport
androidTestImplementation "androidx.test.ext:junit:$junit_android_version"
//fragment androidx
implementation AndroidX.fragment
implementation AndroidX.fragmentKtx
//navigation
implementation Navigation.fragment
implementation Navigation.uiKtx
//Debugging
implementation Debug.timber
//lottie
implementation Animation.lottie
//Hilt DI
implementation Di.hiltAndroid
kapt Di.hiltCompiler
implementation Di.hiltViewModel
kapt Di.hiltAndroidX
//compose
implementation Compose.core
implementation Compose.material
implementation Compose.tooling
implementation project(":domain")
implementation project(":data")
}
I get this error when I try build it:
e: java.lang.NoSuchMethodError: org.jetbrains.kotlin.codegen.state.GenerationState$Builder.isIrBackend(Z)Lorg/jetbrains/kotlin/codegen/state/GenerationState$Builder;
I use Firebase, hilt and corutine and build project with Android Studio 4.2 Canary.
Does anyone have idea to fix this or I can’t use firebase and google play corutine with compose at the moment? Thanks
Related
I am trying to implement firebase crash analytics for my android app I added the dependencies as as shown in firebase site,I also added the googleservices.json. Now after making changes I installed my map and it crashes.
I have attached screenshot of logcat. Please help me.
build.gradle of app
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 30
buildToolsVersion "30.0.1"
defaultConfig {
applicationId "com.android.quotesapp"
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'
}
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'com.android.support:design:28.0.0'
implementation("androidx.recyclerview:recyclerview:1.2.1")
// For control over item selection of both touch and mouse driven selection
implementation("androidx.recyclerview:recyclerview-selection:1.1.0")
implementation 'com.squareup.picasso:picasso:2.71828'
implementation("com.android.volley:volley:1.2.0")
implementation "androidx.cardview:cardview:1.0.0"
implementation platform('com.google.firebase:firebase-bom:28.3.1')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.firebase:firebase-core:19.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Add the following in your gradle file:
apply plugin: 'com.google.firebase.crashlytics'
After
buildFeatures {
}
add
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Also add
implementation 'com.google.firebase:firebase-crashlytics:17.0.0'
Also in your project build.gradle if you have not added
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0'
in dependencies then do so
My Android Studio Build fails with this error message, after updating several dependencies. I also switched from using "dataBinding{
enabled = true
}"
to "viewBinding true" I can't find a resolution for this anywhere. I already tried cleaning, rebuilding, invalidating caches and restarting the computer multiple times. Previous suggestions to similar questions didn't resolve this either. Do i have to start a new android studio project and copy over my code?
C:\Users\seric\AndroidStudioProjects\Futlytics\app\build\generated\data_binding_base_class_source_out\debug\out\com\futlytics\databinding\ToggleStyleBinding.java:7: error: cannot find symbol
import android.widget.selector;
I dont even use anything called ToggleStyleBinding.
My gradle files look like this:
Module
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
//apply plugin: 'kotlin-android-extensions'
apply plugin: "androidx.navigation.safeargs.kotlin"
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 30
buildToolsVersion "30.0.0"
defaultConfig {
applicationId "com.futlytics"
minSdkVersion 22
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'
}
/*dataBinding{
enabled = true
}*/
buildFeatures {
mlModelBinding true
viewBinding true
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
//implementation 'androidx.navigation:navigation-fragment:2.3.4'
//implementation 'androidx.navigation:navigation-ui:2.3.4'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.4'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.4'
implementation 'org.tensorflow:tensorflow-lite-support:0.1.0-rc1'
implementation 'org.tensorflow:tensorflow-lite-metadata:0.1.0-rc1'
implementation 'org.tensorflow:tensorflow-lite-gpu:2.2.0'
implementation 'com.google.firebase:firebase-auth:20.0.3'
implementation 'com.google.android.gms:play-services-auth:19.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
implementation 'com.google.android.gms:play-services-vision:20.1.3'
implementation 'com.google.android.gms:play-services-mlkit-text-recognition:16.1.3'
implementation 'androidx.preference:preference-ktx:1.1.1'
// CameraX
implementation "androidx.camera:camera-camera2:1.1.0-alpha03"
implementation "androidx.camera:camera-lifecycle:1.1.0-alpha03"
implementation "androidx.camera:camera-view:1.0.0-alpha23"
//Firebase
implementation platform('com.google.firebase:firebase-bom:26.7.0')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-firestore-ktx'
implementation 'com.google.firebase:firebase-auth-ktx:20.0.3'
}
Projectapply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
//apply plugin: 'kotlin-android-extensions'
apply plugin: "androidx.navigation.safeargs.kotlin"
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 30
buildToolsVersion "30.0.0"
defaultConfig {
applicationId "com.futlytics"
minSdkVersion 22
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'
}
/*dataBinding{
enabled = true
}*/
buildFeatures {
mlModelBinding true
viewBinding true
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
//implementation 'androidx.navigation:navigation-fragment:2.3.4'
//implementation 'androidx.navigation:navigation-ui:2.3.4'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.4'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.4'
implementation 'org.tensorflow:tensorflow-lite-support:0.1.0-rc1'
implementation 'org.tensorflow:tensorflow-lite-metadata:0.1.0-rc1'
implementation 'org.tensorflow:tensorflow-lite-gpu:2.2.0'
implementation 'com.google.firebase:firebase-auth:20.0.3'
implementation 'com.google.android.gms:play-services-auth:19.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
implementation 'com.google.android.gms:play-services-vision:20.1.3'
implementation 'com.google.android.gms:play-services-mlkit-text-recognition:16.1.3'
implementation 'androidx.preference:preference-ktx:1.1.1'
// CameraX
implementation "androidx.camera:camera-camera2:1.1.0-alpha03"
implementation "androidx.camera:camera-lifecycle:1.1.0-alpha03"
implementation "androidx.camera:camera-view:1.0.0-alpha23"
//Firebase
implementation platform('com.google.firebase:firebase-bom:26.7.0')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-firestore-ktx'
implementation 'com.google.firebase:firebase-auth-ktx:20.0.3'
}
Project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.4.31"
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.4"
classpath 'com.google.gms:google-services:4.3.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I had this issue when accidentally placed xml with <selector> to "layout" folder (instead of "drawable"). Android Studio then tries to make a Binding for it as for layout.
build.gradle(:app) -> just change TRUE to FALSE. (idk what viewBiding does, but my quite advanced app works (again) without error)
buildFeatures {
viewBinding false
}
Connecting module application and get following error:
Circular dependency between the following tasks:
:app:processDebugResources
\--- :app:processDebugResources (*)
Module structure
/app
|--base
|--authfire
Error appears after adding to authfire gradle this line
api project(path: ':app')
What I actually need is simply use MainActivity class from root app inside authfire for starting MainActivity. Woud be appreciate for any help.
:app gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-kapt'
apply from: '../dependencies.gradle'
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.alazar.tracker"
minSdkVersion 22
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 1.8
targetCompatibility 1.8
}
buildFeatures {
viewBinding = true
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation project(path: ':app:base')
implementation project(path: ':app:authfire')
implementation libs.kotlin
implementation libs.core
implementation libs.appcompat
implementation libs.lifecycle
implementation libs.constraint
implementation libs.material
testImplementation libs.testJunit
androidTestImplementation libs.androidTestJunit
androidTestImplementation libs.androidTestEspresso
// dagger
implementation libs.dagger
kapt libs.daggerKapt
}
:app:authfire gradle
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'com.google.gms.google-services'
id 'kotlin-kapt'
}
apply from: '../../dependencies.gradle'
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
minSdkVersion 22
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 {
//noinspection GradleDependency
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.72" // because of Firebase compatibility
}
dependencies {
api project(path: ':app')
api project(path: ':app:base')
implementation libs.core
implementation libs.appcompat
implementation libs.material
implementation libs.constraint
implementation libs.lifecycle
testImplementation libs.testJunit
androidTestImplementation libs.androidTestJunit
androidTestImplementation libs.androidTestEspresso
// Firebase
implementation platform('com.google.firebase:firebase-bom:26.0.0')
implementation 'com.google.firebase:firebase-auth-ktx:20.0.0'
implementation 'com.google.firebase:firebase-firestore-ktx:22.0.0'
// RX
implementation libs.rxKotlin
// dagger
implementation libs.dagger
kapt libs.daggerKapt
}
Thanks!
Move the common/shared code used by the two modules to another module, say common:
we have,
common module
module 1 depends on common
module 2 depends on common
and so on..
this way you won't have a circular dependency issue
App is depending on authfire
authfire is depending on App
That for sure make a loop.
it seems that in project: authfire you need to use some parameters from project: App. Solution whould be like this:
App is depending on authfire (that is ok)
App is passing parameters to Project:authfire (that would be ok) (example of passing parameters is using broadcast)
I have an aar library project, I am using it in a sample project. I added the relevant library to Maven Local Repository. When I check the Pom file, I can see it as Okhttp3 / logging / HttpLoggingInterceptor dependency. But i am facing with below screen shoot error. Any suggestions?
my parent app gradle file looks like above code
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.example.deneme"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
dataBinding {
enabled = 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.6'
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.3'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.1'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.mylibrary:feature:1.0.15#aar'
implementation 'com.android.support:multidex:1.0.3'
}
My problem is that when the pom file is generated it generates incorrectly, I am actually having a problem on the wrong sub-mobule. After I fixed my pom settings my problem was resolved.
Hey everyone how do we enable databinding in android_plugin_version = '3.4.0' ? as my android studio I install the latest version and I receive another error when downgrading the android_plugin_version = '3.4.0' to 3.2.xx.
Project gradle
buildscript {
ext {
kotlin_version = '1.3.31'
android_plugin_version = '3.4.0'
}
repositories {
google()
jcenter()
maven { url 'https://maven.google.com' }
}
dependencies {
classpath "com.android.tools.build:gradle:$android_plugin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
Module
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
applicationId "xxx.xxx.com"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
kapt {
generateStubs = true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
kapt "com.android.databinding:compiler:$android_plugin_version"
}
Syncing has no problem but when running it, I received this error
Could not find com.android.databinding:compiler:3.4.0.
Searched in the following locations:
-
https://dl.google.com/dl/android/maven2/com/android/databinding/compiler/3.4.0/compiler-3.4.0.pom
- https://dl.google.com/dl/android/maven2/com/android/databinding/compiler/3.4.0/compiler-3.4.0.jar
- https://jcenter.bintray.com/com/android/databinding/compiler/3.4.0/compiler-3.4.0.pom
- https://jcenter.bintray.com/com/android/databinding/compiler/3.4.0/compiler-3.4.0.jar
- https://repo.maven.apache.org/maven2/com/android/databinding/compiler/3.4.0/compiler-3.4.0.pom
- https://repo.maven.apache.org/maven2/com/android/databinding/compiler/3.4.0/compiler-3.4.0.jar
You are using wrong version of the Databinding Compiler. For latest version, you can check sites like mvnrepository. For now latest version is 3.4.0.
Here, you are passing wrong version:
kapt "com.android.databinding:compiler:$android_plugin_version"
Instead, use this:
kapt "com.android.databinding:compiler:3.4.0"
UPDATE
In Android studio 3.3 and above you do not need to add annotation processor kapt "com.android.databinding:compiler:$android_plugin_version". Just set dataBinding.enabled = true in your module gradle file or like this:
android {
...
dataBinding {
enabled = true
}
}
I simply remove the kapt "com.android.databinding:compiler$android_plugin_version" and it works the ActivityMainBinding appear in my MainActivity
Gradle App
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
applicationId "xxx.xx.com"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.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
}
dataBinding {
enabled = true
}
}
kapt {
correctErrorTypes = true
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
go to file>>setting>>Gradle>>android studio and check embedded maven
update gradle plugin.
It worked for me