Error migrating to new jetpack compose version - android-jetpack

I'm trying to update my app to a new compose version but it gave me an error that I don't know how to fix. when I run the error persists in my run. my old project works normally but mine what I want is to change versions follow my error if anyone can help me i would appreciate it a lot
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.quitanda, PID: 10390
java.lang.AbstractMethodError: abstract method "void androidx.lifecycle.DefaultLifecycleObserver.onCreate(androidx.lifecycle.LifecycleOwner)"
at androidx.lifecycle.FullLifecycleObserverAdapter.onStateChanged(FullLifecycleObserverAdapter.java:36)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:354)
at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:196)
at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:808)
at android.view.View.dispatchAttachedToWindow(View.java:18355)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3399)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3406)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3406)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3406)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3406)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1796)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1494)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7288)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
at android.view.Choreographer.doCallbacks(Choreographer.java:761)
at android.view.Choreographer.doFrame(Choreographer.java:696)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6923)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)
build.gradle(Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
task clean(type: Delete) {
delete rootProject.buildDir
}
buildscript {
ext {
compose_version = '1.0.0-rc01'
}
}
build.gradle(Module)
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
apply plugin:'kotlin-parcelize'
android {
compileSdk 30
defaultConfig {
applicationId "com.example.quitanda"
minSdk 21
targetSdk 30
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
}
}
dependencies {
def appcompat_version = "1.3.0"
implementation 'androidx.hilt:hilt-navigation-compose:1.0.0-alpha02'
implementation 'androidx.core:core-ktx:1.6.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.0-rc01'
implementation "androidx.appcompat:appcompat:$appcompat_version"
// For loading and tinting drawables on older versions of the platform
implementation "androidx.appcompat:appcompat-resources:$appcompat_version"
testImplementation 'junit:junit:4.+'
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"
// implementation "com.google.accompanist:accompanist-coil:0.7.1"
implementation "io.coil-kt:coil-compose:1.3.0"
implementation "androidx.navigation:navigation-compose:2.4.0-alpha05"
implementation "com.google.accompanist:accompanist-swiperefresh:0.8.0"
implementation "com.google.accompanist:accompanist-pager:0.8.1"
implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-moshi:2.9.0"
implementation "androidx.paging:paging-compose:1.0.0-alpha08"
}

It is an error with the AGP. Change the minSDKVersion to 24 for now

As described in the documentation:
If you are using Android Studio Bumblebee Canary 4 or AGP 7.1.0-alpha04/7.1.0-alpha05, you may hit the following crash:
java.lang.AbstractMethodError: abstract method "void androidx.lifecycle.DefaultLifecycleObserver.onCreate(androidx.lifecycle.LifecycleOwner)"
To fix, temporarily increase your minSdkVersion to 24+ in your build.gradle file. This issue will be fixed in the next version of Android Studio Bumblebee and AGP 7.1.

Related

Could not parse the Android Application Module's Gradle config ,While connecting to Firebase

I am getting this error ,While connecting the app to firebase from the firebase assistant in Android Studio.
Error message -Could not parse the Android Application Module's Gradle config. Resolve gradle build issues and/or resync.
I tried every posted Solution from Stack overflow and had watched many you tube videos ,
even cleared the gradle caches and also Updated the IDE.
Even There is No error or Warning in my Gradle build files.
>build.gradle(app)
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.project.PlacementInfo"
minSdk 25
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildFeatures {
dataBinding = 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
}
compileSdkVersion 32
buildToolsVersion '32.0.0'
}
dependencies {
implementation 'com.google.android.gms:play-services-location:20.0.0'
implementation 'com.google.firebase:firebase-analytics'
implementation platform('com.google.firebase:firebase-bom:30.2.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 'com.google.firebase:firebase-database:20.0.5'
testImplementation 'junit:junit:'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
>build.gradle(Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
classpath "com.android.tools.build:gradle:4.2.2"
classpath 'com.google.gms:google-services:4.3.13'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Issue is resolved.
Removed this line:
testImplementation 'junit:junit:'
from build.gradle (app) and also downgrade the compile SDK from 32 to 31
and added following line:
android.suppressUnsupportedCompileSdk=32
in the gradle's properties(Project)
well here you have to add classpath in gradle level 1
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.2"
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()
maven {
url "https://github.com/jitsi/jitsi-maven-repository/raw/master/releases"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
then you have to add apply plugin in gradle level 2
below dependencies
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 31
defaultConfig {
applicationId "com.example.chatapp"
minSdkVersion 23
targetSdkVersion 31
versionCode 1
versionName "1.0"
multiDexEnabled true
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.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation platform('com.google.firebase:firebase-bom:29.2.1')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-firestore:24.1.0'
implementation 'com.google.firebase:firebase-storage:20.0.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.firebaseui:firebase-ui-firestore:6.2.1'
implementation 'com.firebaseui:firebase-ui-database:8.0.0'
implementation 'com.google.firebase:firebase-database:20.0.4'
implementation 'com.google.firebase:firebase-messaging:23.0.5'
implementation ('org.jitsi.react:jitsi-meet-sdk:3.10.2') { transitive = true }
implementation 'com.android.volley:volley:1.2.0'
implementation 'com.google.firebase:firebase-appcheck-safetynet:16.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
apply plugin: 'com.google.gms.google-services'
source [here]

android studio is not connecting with firebase

I am trying to setup Firebase in my android project.
Could not parse the Android Application Module's Gradle config. Resolve gradle build issues and/or resync.
Been looking for fixes online, most of them are removing jcenter() in build.gradle file. I don't have jcenter() or any other repository in my build.gradle.
Heres my build gradle project:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.1.1' apply false
id 'com.android.library' version '7.1.1' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Build gradle module (app):
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.pabhelhasan.autowebpagerefresher2022"
minSdk 22
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
}
buildToolsVersion '32.0.0'
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.6.0-alpha01'
implementation 'com.getbase:floatingactionbutton:1.10.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Try to go to tools tab and firebase section, that will open chrome console.firebase.google.com and u connect it automatically with all the modules and imports.
Because gradle has changed and firebase didn't update the instructions, so it will not work they way you tried.

Android Studio - Could not parse the Android Application Module's Gradle config

I wish to develop a chat app using firebase. However, I can't Connect to Firebase in the assistant pannel. Instead, it shows this error message
Could not parse the Android Application Module's Gradle config. Resolve gradle build issues and/or resync.
I tried searching up for fix online people suggest to delete jCenter() from gradle but i don't even have this code in my file. I was able to sync my project everything seems to work fine except i couldn't connect to it.
Project gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.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
}
Module gradle
plugins {
id 'com.android.application'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
}
android {
compileSdk 32
defaultConfig {
applicationId "android.exercise.myExercise"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
manifestPlaceholders = [MAPS_API_KEY: "${properties.getProperty('secret-apiKey')}"]
}
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 'com.google.android.gms:play-services-maps:18.0.1'
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.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.annotation:annotation:1.3.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
implementation 'com.google.android.material:material:1.6.0-alpha01'
implementation 'com.github.VishnuSivadasVS:Advanced-HttpURLConnection:1.2'
implementation 'com.google.android.gms:play-services-maps:18.0.2'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// chat sys
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.firebase:firebase-auth:19.0.0'
implementation 'com.google.firebase:firebase-database:19.1.0'
implementation 'com.google.firebase:firebase-core:17.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
}
It's a little late, but I can still help. I had the same problem. And I solved the problem
File>Project Specture>Modules
or
Ctrl+Alt+Shift+S >Modules
Compile sdk Version: 32 or latest version
Build Tools Version: 32.0.0 or latest version
then click Apply button
then click OK button
and the problem will be solved.
Sorry for my english, i don't know english.
Add MAVEN in Project gradle:
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' } // Add this repository
}

Task :app:processDebugMainManifest FAILED when I add dependency implementation 'com.mesibo.api:mesibo:1.5.2'

I started a new project in Android Studio. Empty project compiles without problem.
As soon as I add implementation 'com.mesibo.api:mesibo:1.5.2' to dependencies, I get the following error:
[com.android.support:animated-vector-drawable:28.0.0] C:\Users\nenad\.gradle\caches\transforms-2\files-2.1\2321a6ddb441101d2687f6656a3ad88a\animated-vector-drawable-28.0.0\AndroidManifest.xml Warning:
Package name 'android.support.graphics.drawable' used in: com.android.support:animated-vector-drawable:28.0.0, com.android.support:support-vector-drawable:28.0.0.
[androidx.versionedparcelable:versionedparcelable:1.1.1] C:\Users\nenad\.gradle\caches\transforms-2\files-2.1\7db5a34e07a8e6159e7e1ab900eaa2f0\versionedparcelable-1.1.1\AndroidManifest.xml Warning:
Package name 'androidx.versionedparcelable' used in: androidx.versionedparcelable:versionedparcelable:1.1.1, com.android.support:versionedparcelable:28.0.0.
D:\AndroidStudioProjects\LiburnijaVoIP\app\src\main\AndroidManifest.xml:24:18-86 Error:
Attribute application#appComponentFactory value=(androidx.core.app.CoreComponentFactory) from [androidx.core:core:1.5.0] AndroidManifest.xml:24:18-86
is also present at [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 value=(android.support.v4.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-22:19 to override.
My build.gradle is as follows:
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "hr.grafiknet.liburnijavoip"
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
}
}
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'
implementation platform('com.google.firebase:firebase-bom:28.2.1')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.mesibo.api:mesibo:1.5.2'
}
Those errors are dure to mixing AndroidX/Support. Enable jetifier to resolve. Add following lines to your gradle.properties:
android.useAndroidX=true
android.enableJetifier=true

error "No such property: applicationVariants for class: java.lang.String" when connecting the plugin "com.google.gms.google-services"

I am using the latest version of Android Studio and all plugins. I am trying to connect android app to firebase console. Successfully downloaded google-services.json file and added to module root directory. Added lines "classpath 'com.google.gms: google-services: 4.3.3" and "apply plugin:' com.google.gms.google-services'" to the build.gradle files.
build.gradle project level:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
build.gradle app level:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "app"
minSdkVersion 16
targetSdkVersion 29
versionCode 42
versionName "16.0.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.navigation:navigation-fragment:2.3.0'
implementation 'androidx.navigation:navigation-ui:2.3.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
// CloudPayments SDK
implementation 'ru.cloudpayments.android:sdk:1.0.5'
// add the Firebase SDK for Google Analytics
implementation 'com.google.firebase:firebase-iid:20.2.4'
implementation 'com.google.firebase:firebase-messaging:20.2.4'
implementation 'com.google.firebase:firebase-analytics:17.5.0'
}
apply plugin: 'com.google.gms.google-services'
When synchronizing the project, I get the error
No such property: applicationVariants for class: java.lang.String
which refers to the line "apply plugin: 'com.google.gms.google-services'" in build.gradle app level.
I ask for advice on how you can fix this error.
I solved this by checking all my gradle files and found out that, the gradle.properties file has some errors in it. I don’t know how they got there. But I replaced the file contents by copying the contents from a fresh android project.
Solved

Resources