Android 任务';的执行失败:应用程序:CompiledBugkotlin';

Android 任务';的执行失败:应用程序:CompiledBugkotlin';,android,Android,我最近更新了我的kotlin和kotlin扩展插件,在构建的过程中,我遇到了以下错误。我尝试了与gradle进行干净构建或同步项目,但没有任何效果 e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath: Error:Execution failed for task ':app:compileDe

我最近更新了我的kotlin和kotlin扩展插件,在构建的过程中,我遇到了以下错误。我尝试了与gradle进行干净构建或同步项目,但没有任何效果

e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
Error:Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details
build.gradle如下所示

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

buildscript {
    ext.kotlin_version = '1.0.0-beta-1038'
    ext.anko_version = '0.7.2'
    ext.android_support_version = '23.0.1'
    ext.android_extensions_version = '1.0.0-beta-1038'

    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
    }
}


android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.xxxxxxxxxx.app"
        minSdkVersion 18
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
        debug.java.srcDirs += 'build/generated/src/main/debug'
        release.java.srcDirs += 'build/generated/src/main/release'
    }
    dexOptions {
        preDexLibraries = false
        javaMaxHeapSize "4g"
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
}

repositories {
    jcenter()
    mavenCentral()
    jcenter { url "https://jitpack.io" }
}

dependencies {
    provided fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'io.realm:realm-android:0.83.0'
    compile 'com.github.PhilJay:MPAndroidChart:v2.1.3'
    compile 'com.braintreepayments.api:braintree:1.+'
    compile('com.mikepenz:materialdrawer:4.4.1@aar') {
        transitive = true
    }
    compile 'com.mikepenz:google-material-typeface:1.2.0.1@aar'
    compile project(':temperature')
    compile project(':heart')
    compile project(':lungs')
    compile "com.android.support:cardview-v7:$android_support_version"
    compile 'com.github.wendykierp:JTransforms:3.1'
    compile 'fuel:fuel:0.57'
    compile "org.jetbrains.anko:anko-sdk15:$anko_version"
    compile "org.jetbrains.anko:anko-support-v4:$anko_version"
    compile 'org.apache.directory.studio:org.apache.commons.io:2.4'
    compile 'com.google.android.gms:play-services:8.1.0'
    compile "com.android.support:recyclerview-v7:$android_support_version"
    compile "com.android.support:appcompat-v7:$android_support_version"
    compile "com.android.support:support-v4:$android_support_version"
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
有人能指出这有什么问题吗


谢谢

我通过在终端中构建项目,然后在intellij(或android studio)中运行应用程序,解决了这个问题


gradle clean build->run app in ide对我来说,解决方案是在Android Studio中打开gradle控制台窗口,并使用StackTrace运行构建

然后,通过阅读,我意识到在Kotlin中做一些事情的新方法需要修改我的代码,但是普通的Gradle构建并没有解决这些问题

视图被强制转换为TextView或其他任何情况,这些都不再相关,必须更改为FindViewById格式。e、 g:

val textView = snackbarView.findViewById(R.id.snackbar_text) as TextView
不得不改成

val textView = snackbarView.findViewById<TextView>(R.id.snackbar_text) 
val textView=snackbarView.findViewById(R.id.snackbar\u text)

在我最近从事的一个项目中,我遇到了同样的错误,这是由于调用一个不再存在的静态方法引起的

MessageService.java

public class MessageService extends FirebaseMessagingService {

    /*
    This method was commented out

    private static String GetReviewTopic(String userId) 
    {
        return "/topics/"+userId+"/review";
    }
    */
}
@Override
public void onCreate() {

    ...

    /* 
    No complication error was caused despite the
    method not being defined. 
    */                        
    MessageService.GetReviewTopic(currentUser);

    ...
}
AppActivity.java

public class MessageService extends FirebaseMessagingService {

    /*
    This method was commented out

    private static String GetReviewTopic(String userId) 
    {
        return "/topics/"+userId+"/review";
    }
    */
}
@Override
public void onCreate() {

    ...

    /* 
    No complication error was caused despite the
    method not being defined. 
    */                        
    MessageService.GetReviewTopic(currentUser);

    ...
}
不幸的是,androidstudio没有报告丢失的静态方法的“语法错误”,也没有任何有意义的复杂错误帮助我跟踪问题


希望这个答案能够为大家节省几个小时的故障排除时间

我在添加Google Play服务时也遇到了同样的问题。我用当前的kotlin版本更新了项目中的所有其他模块,并将依赖项版本更新为最新版本,从而解决了这个问题。在检查并重新检查了所有可能的问题后,我发疯了,这条评论就是正确的答案。我不知道为什么,但我成功了。谢谢在运行单元测试时,执行干净构建需要多少时间?我认为您的问题在于buildToolsVersion/appcompat版本。不是kotlin插件。因为
findViewById
是android O.crgarridos的一部分,尽管这可能是真的,但它帮助我找到了困扰Gradle构建的真正问题。我收到的信息与问题贴出的信息完全相同。