迁移到androidx后,没有超级方法getLifecycle()

时间:2018-11-09 16:02:46

标签: android android-lifecycle androidx

我一直在尝试迁移我的应用程序以使用androidx,但是我似乎遇到了一个奇怪的错误。从我调用getLifeCycle()时扩展AppCompatActivity的活动中,它引发以下异常

 Caused by: java.lang.NoSuchMethodError: No super method getLifecycle()Landroidx/lifecycle/Lifecycle; in class Landroidx/core/app/ComponentActivity; or its super classes 
    at androidx.fragment.app.FragmentActivity.getLifecycle(FragmentActivity.java:324)

我认为AppCompatActivity应该实现LifecycleOwner,但不是。难道我做错了什么? 这是我的gradle依赖项

implementation files("libs/jsoup-1.8.3.jar")
implementation "com.github.philjay:MPAndroidChart:v3.0.2"
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.1.0-alpha01'
implementation "androidx.constraintlayout:constraintlayout:2.0.0-alpha2"
implementation 'androidx.constraintlayout:constraintlayout-solver:2.0.0-alpha2'
implementation 'androidx.cardview:cardview:1.0.0'
implementation "com.google.firebase:firebase-messaging:17.3.4"
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
implementation "androidx.lifecycle:lifecycle-runtime:2.0.0"

annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.0.0" // use kapt for Kotlin

implementation "de.hdodenhof:circleimageview:2.2.0"
implementation 'androidx.core:core:1.1.0-alpha01'
implementation "com.thoughtbot:expandablerecyclerview:1.0"
implementation "androidx.lifecycle:lifecycle-livedata:2.0.0"
implementation "androidx.lifecycle:lifecycle-viewmodel:2.0.0"
implementation "com.github.franmontiel:FullScreenDialog:1.0.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.github.apl-devs:appintro:v4.2.3"
implementation "com.google.firebase:firebase-crash:16.2.1"
implementation "com.google.firebase:firebase-core:16.0.5"

4 个答案:

答案 0 :(得分:7)

只需在library(tidyverse) df %>% group_by(Replicate) %>% nest() %>% mutate(ttest = map(data, ~t.test(Value ~ Group, .x))) %>% transmute( Replicate, diff = map_dbl(ttest, ~.x$estimate[1] - .x$estimate[2]), pval = map_dbl(ttest, ~.x$p.value), CI = map(ttest, ~data.frame(CI.low = .x$conf.int[1], CI.high = .x$conf.int[2]))) %>% unnest() ## A tibble: 2 x 5 # Replicate diff pval CI.low CI.high # <dbl> <dbl> <dbl> <dbl> <dbl> #1 1 -1. 0.000990 -1.24 -0.760 #2 2 -1.23 0.00599 -1.72 -0.746 的{​​{1}}版中进行尝试,即可使用。

function socketOnData(server, socket, parser, state, d) { assert(!socket._paused); debug('SERVER socketOnData %d', d.length); var ret = parser.execute(d); onParserExecuteCommon(server, socket, parser, state, ret, d); } state.onData = socketOnData.bind(undefined, server, socket, parser, state); socket.on('data', state.onData); 接口现在由const valueOrNull = (col, value) => ({ rawType: true, toPostgres: () => { if(value === null) { return pgp.as.format('$1:name IS NULL', col); } return pgp.as.format('$1:name = $2', [col, value]); } }); 实现,并由db.oneOrNone(`SELECT * FROM blah WHERE $/c/`, { c: valueOrNull('col', 123) }) -> /^\/api\/(?!add\b)(\w+)(?:\/\w+)*\/?$/i 扩展。现在,您应该可以从活动中获取1.1.0-alpha01对象。

答案 1 :(得分:6)

对我来说,恢复到1.0.1版是可行的。

implementation "androidx.core:core:1.0.1"

答案 2 :(得分:2)

您应该将androidx.appcompat:appcompat版本更改为1.1.0-alpha04

答案 3 :(得分:1)

在我的情况下,我的问题是androidx活动的1.0.0-alpha05版本,​​我恢复为1.0.0-alpha03,并且工作正常