小编Abd*_*aki的帖子

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

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

 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)
Run Code Online (Sandbox Code Playgroud)

我认为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"
Run Code Online (Sandbox Code Playgroud)

android android-lifecycle androidx

19
推荐指数
3
解决办法
5209
查看次数

在滚动视图中渲染反应导航屏幕

我正在构建一个反应本机应用程序,我想将滚动视图作为包装器添加到所有 UI 屏幕。我已将其包装Stack.Navigator在 ScrollView 中,但内容被剪切在屏幕底部,屏幕结束后没有可见的内容。请看下面的代码

应用程序.tsx

export default function App() {
  const [loading, setLoading] = useState(true);
  return loading ? (
    <AppSplashScreen onLoadComplete={() => setLoading(false)} />
  ) : (
    <NavigationContainer>
      <AuthProvider>
        <Provider>
          <ScrollView
            contentContainerStyle={{ minHeight: "100%", overflow: "visible" }}
            style={styles.container}
          >
            <Content />
          </ScrollView>
        </Provider>
      </AuthProvider>
    </NavigationContainer>
  );
}

const styles = StyleSheet.create({
  container: {
    marginTop: 32,
    padding: 16,
    minHeight: "100%",
  },
});
Run Code Online (Sandbox Code Playgroud)

内容.tsx

const Content = () => {
  return (
    <Stack.Navigator
      initialRouteName="LandingPage"
      screenOptions={{
        headerShown: false,
      }}
    > …
Run Code Online (Sandbox Code Playgroud)

reactjs react-native react-native-navigation react-navigation

7
推荐指数
1
解决办法
1859
查看次数