2

我的 Android Studio 0.3.0 和我的项目文件夹有问题,其中包含一个普通的旧 java 库项目、两个 Android 库项目和三个 Android 应用程序。这一切都是用 Gradle 构建的。

问题是初始导入到 Android Studio 工作正常(使用 Android Studio 的Import Project...,然后选择我的settings.gradle文件),但是当我按下 Gradle 侧边栏中的刷新按钮时,我收到消息“Gradle 不再支持以下模块。检查要从 ide 项目中删除的那些:”,然后它列出了我所有要删除的模块。从终端一切都很好。

的输出gradle projects是(带有编辑的名称):

------------------------------------------------------------
Root project
------------------------------------------------------------

Root project 'root'
+--- Project ':android-lib1'
+--- Project ':android-app1'
+--- Project ':android-app2'
+--- Project ':android-app3'
+--- Project ':android-lib2'
\--- Project ':java-lib'

在根文件夹中,我有settings.gradle

include ':java-lib'
include ':android-lib1'
include ':android-lib2'
include ':android-app1'
include ':android-app2'
include ':android-app3'

build.gradle在根文件夹中:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}

allprojects {
    repositories {
        mavenCentral()
        ivy {
            name 'repo'
            artifactPattern 'http://repo.example.com:8081/artifactory/libs-release-local/[organisation]/[module]/[revision]/[type]s/[artifact].[ext]'
            credentials {
                username 'example'
                password 'example'
            }
        }
    }
}

task wrapper(type: Wrapper) {
    gradleVersion = '1.8'
}

build.gradle对于 java-lib:

apply plugin: 'java'
apply plugin: 'eclipse'

compileJava.options.encoding = 'UTF-8'

group 'example'
version '0.1.0'
status 'release'

sourceCompatibility = '1.6'
targetCompatibility = '1.6'

dependencies {
    compile 'com.google.protobuf:protobuf-java:2.5.0'
    compile 'com.google.guava:guava:15.0'
    compile 'org.slf4j:slf4j-api:1.7.5'

    testCompile group: 'junit', name: 'junit', version: '4.+'
}

uploadArchives {
    repositories {
        add project.repositories.repo
    }
}

build.gradle对于两个 Android 库(除了依赖项和版本号之外,它们是相同的:

apply plugin: 'android-library'

dependencies {
    compile project(':java-lib')
}

android {
    compileSdkVersion 18
    buildToolsVersion "18.1.1"

    defaultConfig {
        versionCode 1
        versionName '0.1.0'
        minSdkVersion 9
        targetSdkVersion 18
    }
}

最后,build.gradle对于 Android 应用程序(同样,几乎相同):

apply plugin: 'android'

dependencies {
    compile project(':android-lib1')
    compile project(':android-lib2')
}

android {
    compileSdkVersion 18
    buildToolsVersion "18.1.1"

    defaultConfig {
        versionCode 1
        versionName '0.1.0'
    }

    signingConfigs {
        release
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
}

if (project.hasProperty('storeFile')) {
    android.signingConfigs.release.storeFile = file(storeFile)
}
if (project.hasProperty('storePassword')) {
    android.signingConfigs.release.storePassword = storePassword
}
if (project.hasProperty('keyAlias')) {
    android.signingConfigs.release.keyAlias = keyAlias
}
if (project.hasProperty('keyPassword')) {
    android.signingConfigs.release.keyPassword = keyPassword
}

也许这是 Android Studio 0.3.0 中的一个错误?我在早期版本中没有体验过它,但我想确保它不仅仅是我的构建文件中的东西。

非常感谢您的阅读!

4

2 回答 2

1

这是一个现已修复的错误(自 Android Studio 0.3.5 起为我工作):https ://code.google.com/p/android/issues/detail?id=61453

于 2013-11-19T17:20:46.783 回答
0

也得到了这个或非常类似的错误(不知道我是否刷新了)我看到你在 code.google.com 上发布了错误并同意这一定是他们的错误。我的修复工作只是取消“不受 Gradle 支持”消息,然后我从命令行运行 gradle build。然后一切正常。

于 2013-11-08T22:16:38.407 回答