相关疑难解决方法(0)

Android studio - 具有库项目的应用程序无法构建

我在尝试构建我的应用程序项目时遇到了大麻烦.我有主app模块和库项目模块,如下所示:

项目结构

这是每个模块的gradle.build:

主要应用:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}
apply plugin: 'android'
repositories {
    mavenCentral()
}
android {
    compileSdkVersion 19
    buildToolsVersion '19.0.0'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
    }
    buildTypes {
        release {
            runProguard true
            proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
        }
    }
    productFlavors {
        defaultFlavor {
            proguardFile 'proguard-rules.txt'
        }
    }
}
dependencies {
    compile 'com.android.support:support-v13:19.0.+'
    compile 'com.google.android.gms:play-services:4.0.+'
    compile project(':libraries:datetimepicker')
}
Run Code Online (Sandbox Code Playgroud)

这个是图书馆项目:

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

repositories …
Run Code Online (Sandbox Code Playgroud)

android gradle android-studio android-gradle-plugin

29
推荐指数
1
解决办法
3万
查看次数

对于未明确编写脚本的buildType,minifyEnabled的默认值是什么?

我将几个eclipse项目导入Android Studio(v1.1).

在最初的Eclipse环境中,他们使用Proguard进行发布模式.

在Android Studio环境中,这被翻译为build.gradle脚本中的以下内容(通过导入,而不是我):

buildTypes {
    release {
        minifyEnabled true
        proguardFiles 'proguard.cfg'
    }
}
Run Code Online (Sandbox Code Playgroud)

我知道这意味着"在release构建中,使用proguard.cfg启用Proguard的缩小".

然而,问题是minify似乎也发生在非发布版本(即调试)中!

这怎么可能?

调试版本的minifyEnabled的默认值是什么?


更新1:感谢下面的答案,我现在知道默认是false.这意味着其他东西正在构建调试版本中缩小的各种模块.

我发布了整个 build.gradle,用于在调试版本中缩小的模块之一:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 8
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 8
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles 'proguard.cfg'
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

整个build.gradle项目本身(即顶层)是:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories { …
Run Code Online (Sandbox Code Playgroud)

proguard minify gradle android-studio android-gradle-plugin

11
推荐指数
2
解决办法
3万
查看次数