NoSuchMethodError getLifeCycle() - android

I've updated this library from implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1' to implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'.
Since this update, a crash is appears:
No super method getLifecycle()Landroidx/lifecycle/Lifecycle; in class Landroidx/core/app/ComponentActivity; or its super classes (declaration of 'androidx.core.app.ComponentActivity' appears in /data/app/com.xxx-_17DxVaMzNmc19qlXpUTYw==/base.apk)
This call is done in my Activity (extended AppCompatActivity).
Have you got some explanations guys?

I fixed this issue to upgrade this dependancy from implementation 'androidx.appcompat:appcompat:1.0.2' to implementation 'androidx.appcompat:appcompat:1.1.0-beta01'
Strange behavior... anyway it's fixed!
Thank you very much guys for your support too!

Fixed the issue by adding this dependency to my gradle:
implementation 'androidx.arch.core:core-runtime:2.0.1-alpha01'
I have used
App level gradle compileSdkVersion = 28, buildToolsVersion = "28.0.3":
implementation "com.google.android.gms:play-services-auth:16.0.1"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
implementation 'androidx.arch.core:core-runtime:2.0.1-alpha01'
All com.android.support libraries are of version: 28.0.0
Project level gradle:
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.2.0'
Note 1: If you have the below line, try to build without it:
implementation "androidx.legacy:legacy-support-v4:1.0.0"

try it
worked for me
apply plugin: 'com.A.B'
android {
dataBinding {
enabled = true
}
compileSdkVersion 28
defaultConfig {
applicationId "com.A.B"
minSdkVersion 21
targetSdkVersion 28
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'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.android.support:design:28.0.0' //design
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
implementation "android.arch.lifecycle:extensions:1.1.1"
}
and inside build.gradle (project) add :
classpath 'com.android.tools.build:gradle:3.4.1'

Related

Why doesn't Android Studio see 'android.support.design.widget.CoordinatorLayout'?

I'm a beginner developer in Android. I included
'com.android.support:appcompat-v7:28.0.0' and 'com.android.support:design:28.0.0' in build.gradle.
build.gradle:
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.financialapp"
minSdk 27
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 fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
implementation 'androidx.navigation:navigation-fragment:2.4.1'
implementation 'androidx.navigation:navigation-ui:2.4.1'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
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.google.android.flexbox:flexbox:3.0.0'
}
I want to use `'android.support.design.widget.CoordinatorLayout' in the XML file but then there is an error.
error:
error: package android.support.design.widget does not exist
import android.support.design.widget.CoordinatorLayout;
Version 28 (intended for Android Pie and below) is the last version of the legacy support library, so we recommend that you migrate to AndroidX libraries when using Android Q and moving forward. The IDE can help with
this: Refactor > Migrate to AndroidX.
Old:
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
New:
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
Because you do not have dependency for material
inside your build.gradle(:app)
implementation 'com.google.android.material:material:1.4.0'

How to resolve 'com.android.support:appcompat-v7:28.0.0'

the app already had implementation 'com.android.support:appcompat-v7:26.0.0'.so to stay updated i changed it to 28.0.0. and i still get the Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. error.
how can i solve this error permanently.
i've tried a lot of different solutions provided to similar kind of problems but didn't work.
updated
build.gradle down below
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "man.ravi.app"
minSdkVersion 15
targetSdkVersion 26
versionCode 2
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
multiDexEnabled true
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:design:26.1.0'
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'
implementation 'com.adefruandta.spinningwheel:spinningwheel:0.1.0'
implementation 'com.google.firebase:firebase-core:10.0.1'
implementation 'com.google.firebase:firebase-database:10.0.1'
implementation 'org.immutables:gson:2.6.1'
implementation 'com.google.android.gms:play-services:10.0.1'
implementation 'com.google.android.gms:play-services-maps:10.0.1'
implementation 'com.google.android.gms:play-services-ads:10.0.1'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'gun0912.ted:tedpermission:2.1.0'
}
apply plugin: 'com.google.gms.google-services'
btw..you can `ignore the compileSdkVersion on the Top. it used to be implementationSdkVersion which resulted in a bunch of other erros..then i changed it to compileSdkVersion.
In my case i just update Google service in project level gradle.
classpath 'com.google.gms:google-services:3.2.0'

Could not find ButterKnife compiler

I integrated ButterKnife into my project, since then it has been impossible for me to build it
I've tried different versions of the library but nothing seems to work
Here is the error during the build:
Could not find com.jakewharton:butterknife-compiler:7.0.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/jakewharton/butterknife-compiler/7.0.1/butterknife-compiler-7.0.1.pom
- https://dl.google.com/dl/android/maven2/com/jakewharton/butterknife-compiler/7.0.1/butterknife-compiler-7.0.1.jar
- https://jcenter.bintray.com/com/jakewharton/butterknife-compiler/7.0.1/butterknife-compiler-7.0.1.pom
- https://jcenter.bintray.com/com/jakewharton/butterknife-compiler/7.0.1/butterknife-compiler-7.0.1.jar
- https://jitpack.io/com/jakewharton/butterknife-compiler/7.0.1/butterknife-compiler-7.0.1.pom
- https://jitpack.io/com/jakewharton/butterknife-compiler/7.0.1/butterknife-compiler-7.0.1.jar
Required by:
project :app
And this is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.toto"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//Retrofit Dependencies
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
// Butter Knife
implementation 'com.jakewharton:butterknife:7.0.1'
implementation 'com.android.support:support-annotations:28.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:7.0.1'
// ZXing
implementation 'com.github.tobrun:QR-Vision-Fragment:master-SNAPSHOT'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation 'com.android.support:design:28.0.0'
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'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
}
I have already added the jitpack repositories in the project build.gradle:
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
try this
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
If you are building an old android project and do not want to upgrade your butterknife dependency then add this to your gradle(app level) file. It wokred for me. Happy Coding :)
android {
...
defaultConfig {
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath = true
}
}
}
}
Use This:
compile 'com.jakewharton:butterknife:8.7.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'
from this butterknife-compiler version 7.0.1 not listed(founded) in mvn repository
so use the latest lib version
implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'

Can´t implement firebase-ui-auth

The library com.google.android.gms:play-services-basement is being
requested by various other libraries at [[15.0.1,15.0.1]], but
resolves to 16.0.1. Disable the plugin and check your dependencies
tree using ./gradlew :app:dependencies
I´ve got this error and can´t solve it. I tried everything I found, but nothing worked. Do you have an idea.
I wanted to implement implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.alexa.oneline"
minSdkVersion 15
targetSdkVersion 27
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
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'
//LifeData
implementation 'android.arch.lifecycle:extensions:1.1.1'
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
//room db
implementation "android.arch.persistence.room:runtime:1.1.1"
annotationProcessor "android.arch.persistence.room:compiler:1.1.1"
//Firebase
implementation 'com.google.firebase:firebase-core:17.3.2'
implementation 'com.google.firebase:firebase-firestore:17.1.1'
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
}
apply plugin: 'com.google.gms.google-services'
firebase-core latest version is: 16.0.4 but the Firestore version seems to be all good.
So, change your dependencies to:
//Firebase
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-firestore:17.1.1'
implementation 'com.firebaseui:firebase-ui-auth:4.2.0'
Then add;
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
Right after:
apply plugin: 'com.google.gms.google-services'
In your build.gradle.

build.gradle dependencies have same version specification but still shows mixed versions error

I have read the thread at All com.android.support libraries must use the exact same version specification and many other such threads but none of the answers have solved my problem.
Errors:-
1.) For implementation 'com.android.support:appcompat-v7:26.1.0'
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.1, 26.1.0. Examples include com.android.support:animated-vector-drawable:27.1.1 and com.android.support:cardview-v7:26.1.0 less... (Ctrl+F1)
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).
2.) on building the project
Error: Program type already present:
android.support.design.widget.CoordinatorLayout$Behavior
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "freview1.com.freview"
minSdkVersion 21
targetSdkVersion 26
versionCode 2
versionName '2.2.1'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
//vectorDrawables.useSupportLibrary = true
versionNameSuffix '-alpha'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
/*
ext {
supportLibVersion = '26.1.0' // variable that can be referenced to keep support libs consistent
}
*/
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:percent:26.1.0'
implementation 'com.android.support:support-vector-drawable:26.1.0' // VectorDrawableCompat
implementation 'com.android.support:animated-vector-drawable:26.1.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
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'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
implementation 'com.squareup.picasso:picasso:2.5.2'
}
apply plugin: 'com.google.gms.google-services'
if you want add an library to your project , best way is :
in android studio : (from toolbar) file \ Project Structure ... \ (from left window , under modules ) app \ Dependencies \ [use green plus]
for example if you want use compileSdkVersion 27 , your import code should be like this :
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "your project"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-vector-drawable:27.1.0'
implementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.0'
implementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
It's work for me , and if you want use compileSdkVersion 28 , your import code should be like this :
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "your project"
minSdkVersion 14
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.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'junit:junit:4.12'
implementation 'com.android.support:support-v13:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:mediarouter-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha2'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:support-annotations:28.0.0'
}
It's work for me too .
Many of these problems will disappear with the help of a new library and you will have more efficient classes.
I hope it's work for you .
This version can help you , I test it , it's working :
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
implementation 'com.android.support:support-v4:26.0.0-beta1'
implementation 'com.android.support:design:26.0.0-beta1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
implementation 'com.android.support:gridlayout-v7:26.0.0-beta1'
implementation 'com.android.support:recyclerview-v7:26.0.0-beta1'
implementation 'com.android.support:cardview-v7:26.0.0-beta1'
}
Ok , I finally find your solution , Just add this Lines :
repositories {
mavenCentral()
maven { url "https://maven.google.com" }
}
for example :
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "your app id"
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
implementation 'com.android.support:gridlayout-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
}
repositories {
mavenCentral()
maven { url "https://maven.google.com" }
}
It's mostly happens when you use Libraries that uses old version of AppCompat. It happens to me all the time when I use switchButton library. for last 6 month it didn't impact anything, it's just a false alarm.

Categories

Resources