尝试将Gradle Project导入Android Studio现有项目时出错

时间:2018-05-04 08:47:47

标签: android android-studio gradle

我正在尝试将我在所有应用程序中使用的3个Gradle项目导入到新项目中。

我创建新项目,然后创建文件 - >项目结构 - > + - >导入Gradle项目Projects selected to be imported

然后我单击Finish但这3个项目没有出现在模块列表中

Modules list, without the 3 projects that should have been imported

尚未出现任何错误。但是当我点击Ok时,我确实遇到了4个IDE致命错误:

1/4

Element: class org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl because: different providers: SingleRootFileViewProvider{myVirtualFile=file://F:/development/workspaces/Orchestram/settings.gradle, content=VirtualFileContent{size=16}}(2177d6ca); SingleRootFileViewProvider{myVirtualFile=file://F:/development/workspaces/Orchestram/settings.gradle, content=VirtualFileContent{size=16}}(16a77aa0)

2/4

Element: class com.intellij.psi.impl.compiled.ClsFileImpl because: file://F:/development/workspaces/Orchestram/app/callRemoteService/build/intermediates/classes/debug/com/qbitera/CallRemoteService/R.class is invalid

3/4

Element: class org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl because: different providers: SingleRootFileViewProvider{myVirtualFile=file://F:/development/workspaces/Orchestram/settings.gradle, content=VirtualFileContent{size=16}}(344f03e4); SingleRootFileViewProvider{myVirtualFile=file://F:/development/workspaces/Orchestram/settings.gradle, content=VirtualFileContent{size=16}}(4940c49e)

4/4

Error while applying changes

在尝试导入这些模块之前,这是我的build.gradle(它没有改变)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.qbitera.cerqana.orchestram"
        minSdkVersion 14
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    buildToolsVersion '27.0.3'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

还有settings.gradle

include ':app'

当然,如果我尝试在Gradle中包含实现项目(':callRemoteService')行,则会失败。但是,如果尝试从项目结构中导入againg模块,它表示它已经在项目中

enter image description here

1 个答案:

答案 0 :(得分:1)

添加到根文件夹中的settings.gradle:

include ':app'
include ':your_module'
include ':your_second_module'
include ':you_got_the_point'