Android gradle modules circular dependency - android

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)

Related

meow bottom navigation bar is not recogonised by android studio even after entering dependencies?

it giving me error <meow.meowbottomnavigation.MeowBottomNavigation
/>
in red, saying missing class even after entering these dependecies.
build.gradel(project)
buildscript {
repositories {
jcenter()
}
}
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
}
build.gradel(app)
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.meowbotm"
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'
}
}
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.etebarian:meow-bottom-navigation:1.2.0'
}
i have also added following lines in gradel properties
android.useAndroidX=true
android.enableJetifier=true
i don't know what problem is, in YT and on websites its shows these dependecies are sufficent and meowbottom bar working.
You have to use this tag in your xml file to implement, then it will work. AS you are using 1.2.0 version.
<com.etebarian.meowbottomnavigation.MeowBottomNavigation
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/btm_nav"
android:layout_gravity="bottom"
app:mbn_backgroundBottomColor="#color/purple_200"
app:mbn_circleColor="#color/white"
app:mbn_selectedIconColor="#color/purple_200"
app:mbn_defaultIconColor="#color/white"/>

how to add This plug in in Build.gradle (app)

apply plugin: 'com.google.gms.google-services' <- where should i add this ?
so I recently installed a new version of android studio and there is a new format for the Gradel plugin so where can I put the apply plugin in the below code?
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.social.login2"
minSdkVersion 19
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
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}```
change the following lines
plugins {
id 'com.android.application'
}
to
plugins {
id 'com.android.application'
id ''com.google.gms.google-services'
}
instead of the apply plugin the way to use is now inside the plugins block give the id name and then the id within quotes.
You can add it at the end of your build.gradle file, as that's how it is recommended.
Or just as the last plugin in the plugins block up top

NoClassDefFoundError: Failed resolution of: Lokhttp3/logging/HttpLoggingInterceptor;

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.

Jetpack Compose compilation error with Firebase

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

How to make Android Jetifier works with databinding?

My Android project has 2 Android library modules: app and boo.
app module has already migrated to AndroidX, boo is still using support library.
In boo module, I want to add a new library that depends on both support library and uses data binding.
I have enable Android Jetifier in my gradle.properties.
I am using Android Gradle build tool v.3.3.2 and Gradle v.5.3.1.
Here is my gradle.properies
org.gradle.jvmargs=-Xmx1536m
kotlin.code.style=official
android.useAndroidX=true
android.enableJetifier=true
My app's build.gradle that use AndroidX.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.example"
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
nit:4.12'
implementation project(':boo')
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.appcompat:appcompat:1.0.2'
}
My boo's build.gradle. The module depends on a library that uses both databinding and support library.
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation <library with support library and data binding>
databinding/LayoutWallBinding.java:13: error: cannot find symbol
public final android.support.constraint.ConstraintLayout orderingLayout;
^
symbol: class ConstraintLayout
location: package android.support.constraint
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':editor:kaptDebugKotlin'.
I expect Android Jetifier to convert all support libraries including to AndroidX, but it seems like it cannot convert the ConstraintLayout generated from data binding to AndroidX.
No,it's not working like that
If you want to use AndroidX then it's mandatory that you use all libraries of AndroidX not Support libs
so Instead of this:
implementation'com.android.support.constraint:constraintlayout:1.1.3'
Use this:
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
Convert your library to androidX using standalone jetifier and see if it helps.
./jetifier-standalone -i libraryToProcess.aar -o result.aar

Categories

Resources