Type mismatch: inferred type is LoginActivity but LifecycleOwner was expected
I am playing with the preview version of AndroidStudio - 3.4 Canary 9
.
I selected the default login activity option from Configure your project
window and provided, selected below options:
No error reported on Gradle sync, however on build compilation it produces following error:
Type mismatch: inferred type is LoginActivity but LifecycleOwner was expected
Here is the code snippet on which it is showing the error:
// Type mismatch at this@LoginActivity, required LifeCycleOwner, found - LoginActivity
loginViewModel.loginFormState.observe(this@LoginActivity, Observer {
val loginState = it ?: return@Observer
// disable login button unless both username / password is valid
login.isEnabled = loginState.isDataValid
if (loginState.usernameError != null) {
username.error = getString(loginState.usernameError)
}
if (loginState.passwordError != null) {
password.error = getString(loginState.passwordError)
}
})
LoginActivity
is derived from AppCompatActivity()
Respective imported library is androidx.appcompat.app.AppCompatActivity
Here is content from app level build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.socialsample"
minSdkVersion 19
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.1.0-alpha03'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.annotation:annotation:1.0.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
Here is content from Project level build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.11'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0-alpha09'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Am I missing anything over here? Please suggest.
kotlin android-architecture-components androidx android-jetpack android-studio-3.4
add a comment |
I am playing with the preview version of AndroidStudio - 3.4 Canary 9
.
I selected the default login activity option from Configure your project
window and provided, selected below options:
No error reported on Gradle sync, however on build compilation it produces following error:
Type mismatch: inferred type is LoginActivity but LifecycleOwner was expected
Here is the code snippet on which it is showing the error:
// Type mismatch at this@LoginActivity, required LifeCycleOwner, found - LoginActivity
loginViewModel.loginFormState.observe(this@LoginActivity, Observer {
val loginState = it ?: return@Observer
// disable login button unless both username / password is valid
login.isEnabled = loginState.isDataValid
if (loginState.usernameError != null) {
username.error = getString(loginState.usernameError)
}
if (loginState.passwordError != null) {
password.error = getString(loginState.passwordError)
}
})
LoginActivity
is derived from AppCompatActivity()
Respective imported library is androidx.appcompat.app.AppCompatActivity
Here is content from app level build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.socialsample"
minSdkVersion 19
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.1.0-alpha03'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.annotation:annotation:1.0.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
Here is content from Project level build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.11'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0-alpha09'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Am I missing anything over here? Please suggest.
kotlin android-architecture-components androidx android-jetpack android-studio-3.4
What class your Activity is inherited from?
– Sergey
Jan 3 at 12:24
LoginActivity is derived from AppCompatActivity(). Respective imported library is androidx.appcompat.app.AppCompatActivity
– Devarshi
Jan 3 at 12:41
add a comment |
I am playing with the preview version of AndroidStudio - 3.4 Canary 9
.
I selected the default login activity option from Configure your project
window and provided, selected below options:
No error reported on Gradle sync, however on build compilation it produces following error:
Type mismatch: inferred type is LoginActivity but LifecycleOwner was expected
Here is the code snippet on which it is showing the error:
// Type mismatch at this@LoginActivity, required LifeCycleOwner, found - LoginActivity
loginViewModel.loginFormState.observe(this@LoginActivity, Observer {
val loginState = it ?: return@Observer
// disable login button unless both username / password is valid
login.isEnabled = loginState.isDataValid
if (loginState.usernameError != null) {
username.error = getString(loginState.usernameError)
}
if (loginState.passwordError != null) {
password.error = getString(loginState.passwordError)
}
})
LoginActivity
is derived from AppCompatActivity()
Respective imported library is androidx.appcompat.app.AppCompatActivity
Here is content from app level build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.socialsample"
minSdkVersion 19
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.1.0-alpha03'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.annotation:annotation:1.0.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
Here is content from Project level build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.11'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0-alpha09'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Am I missing anything over here? Please suggest.
kotlin android-architecture-components androidx android-jetpack android-studio-3.4
I am playing with the preview version of AndroidStudio - 3.4 Canary 9
.
I selected the default login activity option from Configure your project
window and provided, selected below options:
No error reported on Gradle sync, however on build compilation it produces following error:
Type mismatch: inferred type is LoginActivity but LifecycleOwner was expected
Here is the code snippet on which it is showing the error:
// Type mismatch at this@LoginActivity, required LifeCycleOwner, found - LoginActivity
loginViewModel.loginFormState.observe(this@LoginActivity, Observer {
val loginState = it ?: return@Observer
// disable login button unless both username / password is valid
login.isEnabled = loginState.isDataValid
if (loginState.usernameError != null) {
username.error = getString(loginState.usernameError)
}
if (loginState.passwordError != null) {
password.error = getString(loginState.passwordError)
}
})
LoginActivity
is derived from AppCompatActivity()
Respective imported library is androidx.appcompat.app.AppCompatActivity
Here is content from app level build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.socialsample"
minSdkVersion 19
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.1.0-alpha03'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.annotation:annotation:1.0.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
Here is content from Project level build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.11'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0-alpha09'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Am I missing anything over here? Please suggest.
kotlin android-architecture-components androidx android-jetpack android-studio-3.4
kotlin android-architecture-components androidx android-jetpack android-studio-3.4
edited Jan 3 at 12:40
Devarshi
asked Jan 3 at 11:32
DevarshiDevarshi
10.9k850111
10.9k850111
What class your Activity is inherited from?
– Sergey
Jan 3 at 12:24
LoginActivity is derived from AppCompatActivity(). Respective imported library is androidx.appcompat.app.AppCompatActivity
– Devarshi
Jan 3 at 12:41
add a comment |
What class your Activity is inherited from?
– Sergey
Jan 3 at 12:24
LoginActivity is derived from AppCompatActivity(). Respective imported library is androidx.appcompat.app.AppCompatActivity
– Devarshi
Jan 3 at 12:41
What class your Activity is inherited from?
– Sergey
Jan 3 at 12:24
What class your Activity is inherited from?
– Sergey
Jan 3 at 12:24
LoginActivity is derived from AppCompatActivity(). Respective imported library is androidx.appcompat.app.AppCompatActivity
– Devarshi
Jan 3 at 12:41
LoginActivity is derived from AppCompatActivity(). Respective imported library is androidx.appcompat.app.AppCompatActivity
– Devarshi
Jan 3 at 12:41
add a comment |
3 Answers
3
active
oldest
votes
I had the same issue and fix it with updating my support version to
versions.support = "1.1.0-alpha01"
so which means just update the
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
and it should be fixed
The only answer that worked for me. Thank you
– Pedro Massango
Jan 14 at 17:40
This should be as an accepted answer.
– Riser
Feb 4 at 5:16
alpha02 is out now
– amitav13
Feb 25 at 12:48
Did not work for me!
– Elnaz
yesterday
add a comment |
It seems androidx.appcompat.app.AppCompatActivity
doesn't implement LifecycleOwner
interface in the version you are using androidx.appcompat:appcompat:1.0.2.
android.support.v7.app.AppCompatActivity
implicitly implements LifecycleOwner
, so you need to inherit from it instead of androidx.appcompat.app.AppCompatActivity
:
class LoginActivity : android.support.v7.app.AppCompatActivity() { ... }
or use some other Activity
class that implements (explicitly or implicitly) LifecycleOwner
, e.g. android.support.v4.app.FragmentActivity
.
Additionally, any custom application class can implement the LifecycleOwner
interface. More info about LifecycleOwner
is here.
Why the answer has been downvoted?
– Sergey
Jan 4 at 6:20
No idea.. your answer looks reasonable to me, marking it as accepted and upvoted from my end. In case if someone has alternate view points please feel free to add a comment or another answer.
– Devarshi
Jan 4 at 6:59
Great, glad to help, thanks.
– Sergey
Jan 4 at 7:05
I'm having the same issue but I have used androidx previously and it worked fine this is not the right answer.
– Arutha
Jan 10 at 14:05
@Arutha this is one of the possible solutions, if it is not working for you please leave a comment.
– Sergey
Jan 10 at 19:13
add a comment |
If you are using androidx.appcompat:appcompat:1.0.2
It won't work for you as LifeCycleOwner is not implemented.
Your AppCompatActivity extends FragmentActivity which further extends ComponentActivity and ComponentActivity implements LifeCycleOwner which is not in 1.0.2 version so upgrading (1.1.0-alpha02) or downgrading (1.0.0) will work for you.
Happy coding :)
1
Small typo: 1.1.0-alpha2 -> should be 1.1.0-alpha02
– Deishelon
Feb 26 at 10:27
Thanks @Deishelon for commenting,update answer
– Amit Bhati
Feb 26 at 19:43
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54021453%2ftype-mismatch-inferred-type-is-loginactivity-but-lifecycleowner-was-expected%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
I had the same issue and fix it with updating my support version to
versions.support = "1.1.0-alpha01"
so which means just update the
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
and it should be fixed
The only answer that worked for me. Thank you
– Pedro Massango
Jan 14 at 17:40
This should be as an accepted answer.
– Riser
Feb 4 at 5:16
alpha02 is out now
– amitav13
Feb 25 at 12:48
Did not work for me!
– Elnaz
yesterday
add a comment |
I had the same issue and fix it with updating my support version to
versions.support = "1.1.0-alpha01"
so which means just update the
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
and it should be fixed
The only answer that worked for me. Thank you
– Pedro Massango
Jan 14 at 17:40
This should be as an accepted answer.
– Riser
Feb 4 at 5:16
alpha02 is out now
– amitav13
Feb 25 at 12:48
Did not work for me!
– Elnaz
yesterday
add a comment |
I had the same issue and fix it with updating my support version to
versions.support = "1.1.0-alpha01"
so which means just update the
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
and it should be fixed
I had the same issue and fix it with updating my support version to
versions.support = "1.1.0-alpha01"
so which means just update the
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
and it should be fixed
answered Jan 10 at 14:18
AruthaArutha
220213
220213
The only answer that worked for me. Thank you
– Pedro Massango
Jan 14 at 17:40
This should be as an accepted answer.
– Riser
Feb 4 at 5:16
alpha02 is out now
– amitav13
Feb 25 at 12:48
Did not work for me!
– Elnaz
yesterday
add a comment |
The only answer that worked for me. Thank you
– Pedro Massango
Jan 14 at 17:40
This should be as an accepted answer.
– Riser
Feb 4 at 5:16
alpha02 is out now
– amitav13
Feb 25 at 12:48
Did not work for me!
– Elnaz
yesterday
The only answer that worked for me. Thank you
– Pedro Massango
Jan 14 at 17:40
The only answer that worked for me. Thank you
– Pedro Massango
Jan 14 at 17:40
This should be as an accepted answer.
– Riser
Feb 4 at 5:16
This should be as an accepted answer.
– Riser
Feb 4 at 5:16
alpha02 is out now
– amitav13
Feb 25 at 12:48
alpha02 is out now
– amitav13
Feb 25 at 12:48
Did not work for me!
– Elnaz
yesterday
Did not work for me!
– Elnaz
yesterday
add a comment |
It seems androidx.appcompat.app.AppCompatActivity
doesn't implement LifecycleOwner
interface in the version you are using androidx.appcompat:appcompat:1.0.2.
android.support.v7.app.AppCompatActivity
implicitly implements LifecycleOwner
, so you need to inherit from it instead of androidx.appcompat.app.AppCompatActivity
:
class LoginActivity : android.support.v7.app.AppCompatActivity() { ... }
or use some other Activity
class that implements (explicitly or implicitly) LifecycleOwner
, e.g. android.support.v4.app.FragmentActivity
.
Additionally, any custom application class can implement the LifecycleOwner
interface. More info about LifecycleOwner
is here.
Why the answer has been downvoted?
– Sergey
Jan 4 at 6:20
No idea.. your answer looks reasonable to me, marking it as accepted and upvoted from my end. In case if someone has alternate view points please feel free to add a comment or another answer.
– Devarshi
Jan 4 at 6:59
Great, glad to help, thanks.
– Sergey
Jan 4 at 7:05
I'm having the same issue but I have used androidx previously and it worked fine this is not the right answer.
– Arutha
Jan 10 at 14:05
@Arutha this is one of the possible solutions, if it is not working for you please leave a comment.
– Sergey
Jan 10 at 19:13
add a comment |
It seems androidx.appcompat.app.AppCompatActivity
doesn't implement LifecycleOwner
interface in the version you are using androidx.appcompat:appcompat:1.0.2.
android.support.v7.app.AppCompatActivity
implicitly implements LifecycleOwner
, so you need to inherit from it instead of androidx.appcompat.app.AppCompatActivity
:
class LoginActivity : android.support.v7.app.AppCompatActivity() { ... }
or use some other Activity
class that implements (explicitly or implicitly) LifecycleOwner
, e.g. android.support.v4.app.FragmentActivity
.
Additionally, any custom application class can implement the LifecycleOwner
interface. More info about LifecycleOwner
is here.
Why the answer has been downvoted?
– Sergey
Jan 4 at 6:20
No idea.. your answer looks reasonable to me, marking it as accepted and upvoted from my end. In case if someone has alternate view points please feel free to add a comment or another answer.
– Devarshi
Jan 4 at 6:59
Great, glad to help, thanks.
– Sergey
Jan 4 at 7:05
I'm having the same issue but I have used androidx previously and it worked fine this is not the right answer.
– Arutha
Jan 10 at 14:05
@Arutha this is one of the possible solutions, if it is not working for you please leave a comment.
– Sergey
Jan 10 at 19:13
add a comment |
It seems androidx.appcompat.app.AppCompatActivity
doesn't implement LifecycleOwner
interface in the version you are using androidx.appcompat:appcompat:1.0.2.
android.support.v7.app.AppCompatActivity
implicitly implements LifecycleOwner
, so you need to inherit from it instead of androidx.appcompat.app.AppCompatActivity
:
class LoginActivity : android.support.v7.app.AppCompatActivity() { ... }
or use some other Activity
class that implements (explicitly or implicitly) LifecycleOwner
, e.g. android.support.v4.app.FragmentActivity
.
Additionally, any custom application class can implement the LifecycleOwner
interface. More info about LifecycleOwner
is here.
It seems androidx.appcompat.app.AppCompatActivity
doesn't implement LifecycleOwner
interface in the version you are using androidx.appcompat:appcompat:1.0.2.
android.support.v7.app.AppCompatActivity
implicitly implements LifecycleOwner
, so you need to inherit from it instead of androidx.appcompat.app.AppCompatActivity
:
class LoginActivity : android.support.v7.app.AppCompatActivity() { ... }
or use some other Activity
class that implements (explicitly or implicitly) LifecycleOwner
, e.g. android.support.v4.app.FragmentActivity
.
Additionally, any custom application class can implement the LifecycleOwner
interface. More info about LifecycleOwner
is here.
edited Jan 10 at 14:27
answered Jan 3 at 12:42
SergeySergey
4,24421835
4,24421835
Why the answer has been downvoted?
– Sergey
Jan 4 at 6:20
No idea.. your answer looks reasonable to me, marking it as accepted and upvoted from my end. In case if someone has alternate view points please feel free to add a comment or another answer.
– Devarshi
Jan 4 at 6:59
Great, glad to help, thanks.
– Sergey
Jan 4 at 7:05
I'm having the same issue but I have used androidx previously and it worked fine this is not the right answer.
– Arutha
Jan 10 at 14:05
@Arutha this is one of the possible solutions, if it is not working for you please leave a comment.
– Sergey
Jan 10 at 19:13
add a comment |
Why the answer has been downvoted?
– Sergey
Jan 4 at 6:20
No idea.. your answer looks reasonable to me, marking it as accepted and upvoted from my end. In case if someone has alternate view points please feel free to add a comment or another answer.
– Devarshi
Jan 4 at 6:59
Great, glad to help, thanks.
– Sergey
Jan 4 at 7:05
I'm having the same issue but I have used androidx previously and it worked fine this is not the right answer.
– Arutha
Jan 10 at 14:05
@Arutha this is one of the possible solutions, if it is not working for you please leave a comment.
– Sergey
Jan 10 at 19:13
Why the answer has been downvoted?
– Sergey
Jan 4 at 6:20
Why the answer has been downvoted?
– Sergey
Jan 4 at 6:20
No idea.. your answer looks reasonable to me, marking it as accepted and upvoted from my end. In case if someone has alternate view points please feel free to add a comment or another answer.
– Devarshi
Jan 4 at 6:59
No idea.. your answer looks reasonable to me, marking it as accepted and upvoted from my end. In case if someone has alternate view points please feel free to add a comment or another answer.
– Devarshi
Jan 4 at 6:59
Great, glad to help, thanks.
– Sergey
Jan 4 at 7:05
Great, glad to help, thanks.
– Sergey
Jan 4 at 7:05
I'm having the same issue but I have used androidx previously and it worked fine this is not the right answer.
– Arutha
Jan 10 at 14:05
I'm having the same issue but I have used androidx previously and it worked fine this is not the right answer.
– Arutha
Jan 10 at 14:05
@Arutha this is one of the possible solutions, if it is not working for you please leave a comment.
– Sergey
Jan 10 at 19:13
@Arutha this is one of the possible solutions, if it is not working for you please leave a comment.
– Sergey
Jan 10 at 19:13
add a comment |
If you are using androidx.appcompat:appcompat:1.0.2
It won't work for you as LifeCycleOwner is not implemented.
Your AppCompatActivity extends FragmentActivity which further extends ComponentActivity and ComponentActivity implements LifeCycleOwner which is not in 1.0.2 version so upgrading (1.1.0-alpha02) or downgrading (1.0.0) will work for you.
Happy coding :)
1
Small typo: 1.1.0-alpha2 -> should be 1.1.0-alpha02
– Deishelon
Feb 26 at 10:27
Thanks @Deishelon for commenting,update answer
– Amit Bhati
Feb 26 at 19:43
add a comment |
If you are using androidx.appcompat:appcompat:1.0.2
It won't work for you as LifeCycleOwner is not implemented.
Your AppCompatActivity extends FragmentActivity which further extends ComponentActivity and ComponentActivity implements LifeCycleOwner which is not in 1.0.2 version so upgrading (1.1.0-alpha02) or downgrading (1.0.0) will work for you.
Happy coding :)
1
Small typo: 1.1.0-alpha2 -> should be 1.1.0-alpha02
– Deishelon
Feb 26 at 10:27
Thanks @Deishelon for commenting,update answer
– Amit Bhati
Feb 26 at 19:43
add a comment |
If you are using androidx.appcompat:appcompat:1.0.2
It won't work for you as LifeCycleOwner is not implemented.
Your AppCompatActivity extends FragmentActivity which further extends ComponentActivity and ComponentActivity implements LifeCycleOwner which is not in 1.0.2 version so upgrading (1.1.0-alpha02) or downgrading (1.0.0) will work for you.
Happy coding :)
If you are using androidx.appcompat:appcompat:1.0.2
It won't work for you as LifeCycleOwner is not implemented.
Your AppCompatActivity extends FragmentActivity which further extends ComponentActivity and ComponentActivity implements LifeCycleOwner which is not in 1.0.2 version so upgrading (1.1.0-alpha02) or downgrading (1.0.0) will work for you.
Happy coding :)
edited Feb 26 at 19:43
answered Feb 19 at 12:56
Amit BhatiAmit Bhati
838918
838918
1
Small typo: 1.1.0-alpha2 -> should be 1.1.0-alpha02
– Deishelon
Feb 26 at 10:27
Thanks @Deishelon for commenting,update answer
– Amit Bhati
Feb 26 at 19:43
add a comment |
1
Small typo: 1.1.0-alpha2 -> should be 1.1.0-alpha02
– Deishelon
Feb 26 at 10:27
Thanks @Deishelon for commenting,update answer
– Amit Bhati
Feb 26 at 19:43
1
1
Small typo: 1.1.0-alpha2 -> should be 1.1.0-alpha02
– Deishelon
Feb 26 at 10:27
Small typo: 1.1.0-alpha2 -> should be 1.1.0-alpha02
– Deishelon
Feb 26 at 10:27
Thanks @Deishelon for commenting,update answer
– Amit Bhati
Feb 26 at 19:43
Thanks @Deishelon for commenting,update answer
– Amit Bhati
Feb 26 at 19:43
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54021453%2ftype-mismatch-inferred-type-is-loginactivity-but-lifecycleowner-was-expected%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What class your Activity is inherited from?
– Sergey
Jan 3 at 12:24
LoginActivity is derived from AppCompatActivity(). Respective imported library is androidx.appcompat.app.AppCompatActivity
– Devarshi
Jan 3 at 12:41