在android库模块中找不到程序包

在android库模块中找不到程序包,android,android-gradle-plugin,Android,Android Gradle Plugin,我在现有项目中创建了两个不同的Android库模块 现在,当我尝试运行该应用程序时,它会给我一个错误,说该程序包在项目中不存在。这真的让我很困惑,因为这两个模块都在那里,而之前只有一个库模块,它正在工作 此外,在gradle构建时,它不会给出任何错误 这是应用程序的gradle文件: apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0

我在现有项目中创建了两个不同的Android库模块

现在,当我尝试运行该应用程序时,它会给我一个错误,说该程序包在项目中不存在。这真的让我很困惑,因为这两个模块都在那里,而之前只有一个库模块,它正在工作

此外,在gradle构建时,它不会给出任何错误

这是应用程序的gradle文件:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.cl.lo"
        minSdkVersion 17
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile project(":ge")
    compile project(":in")
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'

}
这一个在gradle文件中

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.google.android.gms:play-services-maps:9.4.0'
    compile 'com.google.android.gms:play-services-location:9.4.0'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
}
最后一个是ge gradle文件:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'com.google.android.gms:play-services-maps:9.4.0'
}

更新
删除ge build.gradle中的此行

minifyEnabled true
apply plugin: 'com.google.gms.google-services'
Minify删除库中未使用的代码,因此应用程序无法找到它们

注意:ProGuard设置应该放在app build.gradle中,而不是放在库中


旧答案

如果是与谷歌服务相关的问题,
在应用程序的build.gradle底部添加此行

minifyEnabled true
apply plugin: 'com.google.gms.google-services'

引言
2为已启用的服务所需的基本库添加依赖项。此步骤要求应用插件:“com.google.gms.google服务”行位于app/build.gradle文件的底部,这样就不会引入依赖冲突。您可以通过运行./gradlew:app:dependencies查看此步骤的结果


更新
删除ge build.gradle中的此行

minifyEnabled true
apply plugin: 'com.google.gms.google-services'
Minify删除库中未使用的代码,因此应用程序无法找到它们

注意:ProGuard设置应该放在app build.gradle中,而不是放在库中


旧答案

如果是与谷歌服务相关的问题,
在应用程序的build.gradle底部添加此行

minifyEnabled true
apply plugin: 'com.google.gms.google-services'

引言
2为已启用的服务所需的基本库添加依赖项。此步骤要求应用插件:“com.google.gms.google服务”行位于app/build.gradle文件的底部,这样就不会引入依赖冲突。您可以通过运行./gradlew:app:dependencies查看此步骤的结果


你是对的,删除
minifyEnabled
就成功了。另一方面,我打算分发图书馆的aar文件。那么在这种情况下,我应该在哪里运行
minifyEnabled
?@floftking998否。不要为aar运行minify。它删除了库本身未使用的所有类/方法。另外,请保留class和method names.NB:使用consumerProguardFiles在库中使用ProGuard配置文件。看到了答案,但是如果他们打算将SDK分发给包含一些关键/业务逻辑组件的开发人员,应该怎么做?在这种情况下,我如何混淆代码?让我们来看看。你是对的,删除
minifyEnabled
成功了。另一方面,我打算分发图书馆的aar文件。那么在这种情况下,我应该在哪里运行
minifyEnabled
?@floftking998否。不要为aar运行minify。它删除了库本身未使用的所有类/方法。另外,请保留class和method names.NB:使用consumerProguardFiles在库中使用ProGuard配置文件。看到了答案,但是如果他们打算将SDK分发给包含一些关键/业务逻辑组件的开发人员,应该怎么做?在这种情况下,我如何混淆代码?让我们来看看。