简体   繁体   English

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

[英]Error trying to import Gradle Project to Android Studio existing project

I am trying to import 3 Gradle Projects I used in all my apps with utilities to a new project. 我正在尝试将我所有带有实用程序的应用程序中使用的3个Gradle项目导入一个新项目。

I create the new project and then File -> Project Structure -> + -> Import Gradle Project 我创建了新项目,然后创建文件->项目结构-> +->导入Gradle项目 选择要导入的项目

Then I click Finish but those 3 projects do not appear in the modules list 然后,我单击完成,但是这3个项目未出现在模块列表中

模块列表,没有应导入的3个项目

No error has appeared yet. 尚未出现错误。 But when I click Ok there I do got 4 IDE fatal errors: 但是,当我单击“确定”时,确实出现了4个IDE致命错误:

1/4 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 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 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 4/4

Error while applying changes

This is my build.gradle before trying to import those modules (it does not change) 这是我的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'
}

And the settings.gradle 和settings.gradle

include ':app'

Of course if I try to just include the implementation project(':callRemoteService') line in the Gradle it fails. 当然,如果我尝试仅将实现项目(':callRemoteService')行包含在Gradle中,它将失败。 But if try to import againg the modules from the Project Structure, it says that it is already on the project 但是,如果尝试再次从“项目结构”中导入模块,则表示该模块已在项目中

在此处输入图片说明

Add to settings.gradle at the root folder: 在根文件夹中添加到settings.gradle:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM