相关疑难解决方法(0)

android studio error:默认接口方法仅支持从Android N开始(--min-api 24)

我升级到Android工作室3.1,我得到以下错误:

    Default interface methods are only supported starting with Android N (--min-api 24): void android.arch.lifecycle.DefaultLifecycleObserver.onCreate(android.arch.lifecycle.LifecycleOwner)
Message{kind=ERROR, text=Default interface methods are only supported starting with Android N (--min-api 24): void android.arch.lifecycle.DefaultLifecycleObserver.onCreate(android.arch.lifecycle.LifecycleOwner), sources=[Unknown source file], tool name=Optional.of(D8)}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

这是我的gradle配置:

      compileSdkVersion 27
//buildToolsVersion '27.0.3'
defaultConfig {
    minSdkVersion 16
    targetSdkVersion 27
     multiDexEnabled true
     //...
   }
Run Code Online (Sandbox Code Playgroud)

正如你所看到的那样,我的目标27已经领先于它抱怨的24个?我该怎么做才能解决这个问题?如果我改为1.8 java不会让我失去很多客户?为什么我在升级android studio之前没有收到此错误.

我不知道这是关于我最近投入的LifecycleObserver类,它是在kotlin中,现在我将其更改为java但在清理项目后仍然得到相同的错误:

public class LifeCycleAwareObserver implements LifecycleObserver {

@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
public void  onAppBackgrounded() {
    AnalyticsUtils.trackStartSession(true);
}

@OnLifecycleEvent(Lifecycle.Event.ON_START)
public void onAppForegrounded() {
    AnalyticsUtils.trackStartSession(false);
}
Run Code Online (Sandbox Code Playgroud)

}

如何追踪错误的来源,以便我可以修复它?

这是我的版本依赖项:

project.ext {


        firebase_version …
Run Code Online (Sandbox Code Playgroud)

android java-8 kotlin

193
推荐指数
7
解决办法
6万
查看次数

房间"不确定如何将光标转换为此方法的返回类型":哪种方法?

Error:Not sure how to convert a Cursor to this method's return type
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
Run Code Online (Sandbox Code Playgroud)

使用Room我收到此错误,我想找出导致它的方法.

我有多个DAOs,总共有大约60个方法,并且在添加方法之后弹出了这个错误(从另一个完美工作的复制和粘贴,只是将字段更改为设置).

我可以发布整个类的DAOs,但我想知道哪种方法失败了.我试着用Run with --stacktrace,Run with --info--debug option,但这些都不显示出任何有价值的信息.

我添加的方法是一个@Query UPDATEInt返回类型,如在建议的文档

UPDATE或DELETE查询可以返回void或int.如果是int,则该值是受此查询影响的行数.

编辑:我想补充一点,我尝试删除该方法,使DAO回到工作状态,但它仍然给我这个错误.

EDIT2:添加gradle控制台输出,因为在评论中不可读:

error: Not sure how to convert a Cursor to this method's return type
error: Not sure how to convert a Cursor to …
Run Code Online (Sandbox Code Playgroud)

android dao kapt android-room android-architecture-components

30
推荐指数
8
解决办法
2万
查看次数

为什么butterknife 9.0.0-SNAPSHOT无法解决?

我想使用AndroidX库,下面是Butterknife的Gradle设置

app:模块依赖

implementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT'
 annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT'
Run Code Online (Sandbox Code Playgroud)

插入

apply plugin: 'com.jakewharton.butterknife'

项目依赖

dependencies {
      classpath 'com.android.tools.build:gradle:3.3.0-alpha09'
      classpath 'com.google.gms:google-services:4.0.1'
      classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-SNAPSHOT'
      // NOTE: Do not place your application dependencies here; they belong
      // in the individual module build.gradle files
    }
Run Code Online (Sandbox Code Playgroud)

项目存储库

repositories {
        google()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
        jcenter()
    }
Run Code Online (Sandbox Code Playgroud)

android butterknife androidx

10
推荐指数
3
解决办法
9283
查看次数