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
Related
When I updated to Electric Eel 2022.1.1, every time I create a new Kotlin file, it gives me the notification warning Configure Kotlin Configure 'Name.app' module in 'Name' project asKotlin (Android with Gradle) module.
I have only been working with Kotlin, not Java. I only started getting this warning after the update.
After I click the link to configure as Kotlin (Android with Gradle) module and select All modules containing Kotlin files: Name.app and set the Kotlin compiler to 1.8.0, it still gives me another warning when I make a new file.
Do I need to worry about this warning or can I just ignore it?
Here is my build.gradle (:app)
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
android {
namespace 'com.example.name'
compileSdk 33
defaultConfig {
applicationId "com.example.name"
minSdk 23
targetSdk 33
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.9.0'
implementation 'androidx.appcompat:appcompat:1.7.0-alpha01'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.core:core-ktx:1.9.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
and here is the top-level build.gradle:
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.8.0' apply 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.
I created a completely fresh jetpack compose project (from the project template) with Android Studio 4.0 Canary 6 and I attempted to add room dependencies.
Here is my app-level build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.composewithroom"
minSdkVersion 29
targetSdkVersion 29
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 {
compose true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.ui:ui-framework:0.1.0-dev03'
implementation 'androidx.ui:ui-layout:0.1.0-dev03'
implementation 'androidx.ui:ui-material:0.1.0-dev03'
implementation 'androidx.ui:ui-tooling:0.1.0-dev03'
implementation "androidx.room:room-runtime:2.2.2"
implementation "androidx.room:room-ktx:2.2.2"
kapt "androidx.room:room-compiler:2.2.2" // e: java.lang.NoSuchMethodError: org.jetbrains.kotlin.codegen.state.GenerationState$Builder.isIrBackend(Z)Lorg/jetbrains/kotlin/codegen/state/GenerationState$Builder;
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
I get this error when I try to build it:
e: java.lang.NoSuchMethodError: org.jetbrains.kotlin.codegen.state.GenerationState$Builder.isIrBackend(Z)Lorg/jetbrains/kotlin/codegen/state/GenerationState$Builder;
This can be either "fixed" by removing kapt "androidx.room:room-compiler:2.2.2" or disabling compose compose true
Does anyone have any idea how to fix this or is the room database just unusable with Compose at the moment?
Should be fixed in 1.3.61... but Jetpack Compose compiler plugin is not updated.
You can find more information in the following YouTrack issue: IR (Jetpack Compose), KAPT, Room: "AssertionError: IR backend shouldn't call KotlinTypeMapper.mapType: MainActivity". Last comment states that:
The problem here is that JetPack Compose hasn't updated its internal Kotlin compiler to 1.3.61 yet. We'll see what we can do about it.
Also, the following issue in Google Issue Tracker: Annotation processors fail when compose is enabled
I have updated my apps build tools to 28.0.0. The application fails to install to device due to the following error:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithDexBuilderForDebug'
If I remove Lombok dependecies then everything runs without any issues.
I can't seem to figure what is the problem and am not able to find info about this online. Any thoughts?
My app gradle config:'
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "my.package.budgeter"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '28.0.2'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
compileOnly 'org.projectlombok:lombok:1.18.2'
annotationProcessor 'org.projectlombok:lombok:1.18.2'
}
Found out that there is an issue with 1.18.2 version.
Rolled back to version 1.16.20. This fixed the issue.