AssertionError:必须初始化Root包

时间:2015-08-10 13:10:29

标签: android gradle kotlin

我在Android Studio中的另一台计算机上打开我的Kotlin项目,并在事件日志中遇到错误:

  

AssertionError:必须初始化Root包

Root package must be initialized
java.lang.AssertionError: Root package must be initialized
at org.jetbrains.kotlin.resolve.lazy.ResolveSession.getAllPackages(ResolveSession.java:329)
at org.jetbrains.kotlin.resolve.lazy.ResolveSession.forceResolveAll(ResolveSession.java:350)
at org.jetbrains.kotlin.idea.references.BuiltInsReferenceResolver$2.run(BuiltInsReferenceResolver.java:121)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:872)
at org.jetbrains.kotlin.idea.references.BuiltInsReferenceResolver$3.run(BuiltInsReferenceResolver.java:141)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:400)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:56)

项目主体结构:

enter image description here

的build.gradle

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

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "taskmoney"
    minSdkVersion 15
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),     'proguard-rules.pro'
    }
}
sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
    local.java.srcDirs += 'src/local/kotlin'
    }
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//dependencies list
}

buildscript {
ext.kotlin_version = '0.12.1230'
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.2.3'
    classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

因此,无法打开任何.kt文件。

猜猜我想念一些简单的事......谢谢

1 个答案:

答案 0 :(得分:0)

我认为这是因为Android Studio IDE的版本。我在使用1.2时遇到了同样的问题,在我升级到1.5后,问题解决了。