本文介绍了Android的注释和口味Android Studio中1.0.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要在我的项目中添加两种口味,我已经有Android的注释和它的不好处工作正常,但是当我加入了两个忙量变到质变时,只产生了口味之一MainActivity_类构建变种。
如何您可以加入香精依然任何想法使用注解?

Android的注解版本是3.2

我的gradle在Android的部分看起来像这样

 安卓{
    compileSdkVersion 21
    buildToolsVersion21.1.2    packagingOptions {
        排除META-INF / LICENSE.TXT
        排除META-INF / LICENSE
        排除META-INF /注意事项
        排除META-INF / notice.txt
    }    defaultConfig {
        的applicationID$软件包名
        14的minSdkVersion
        targetSdkVersion 21
        版本code 1
        的versionName1.0
    }
    buildTypes {
        发布 {
            minifyEnabled假
            proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
        }
    }
    productFlavors {
        flavor1 {        }
        flavor2 {        }
    }
}
易{
    参数{
        androidManifestFile variant.outputs [0] .processResources.manifestFile
        resourcePackageName$软件包名
    }
}


解决方案

我为自己使用AndroidAnnotations了一段时间,现在我有需要产品的口味,以及一些项目。到目前为止,我设法使它工作。

我的猜测是,你错误地配置您的 resourcePackageName 的在你的贴切。

下面是我在我的(截)做的的build.gradle 文件:

 转{
APP_NAME =你的应用程序的名字在这里
}defaultConfig {
    的applicationID APP_GROUP
    APP_VERSION的versionName
    版本code 1    12的minSdkVersion
    targetSdkVersion 21
}易{
参数{
    androidManifestFile variant.outputs [0] .processResources.manifestFile
    resourcePackageName android.defaultConfig.applicationId
}
}

您可能还需要为你的使用每个口味定制的applicationID。你可以这样做的:

  productFlavors {
    flavor1 {
        的applicationID android.defaultConfig.applicationId +.flavor1
    }
    flavor2 {
        的applicationID android.defaultConfig.applicationId +.flavor2
    }
}

希望这能解决您的问题;)

i'm trying to add two flavors in my project, I already have android annotations and it's working fine without the favors, but when I'm adding the two favors the MainActivity_ class is generated only for one of the flavors when changeing the build variant.Any ideas on how could you add flavors and still use the annotations?

Android annotations version is '3.2'

My android section in gradle looks like this

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    packagingOptions {
        exclude 'META-INF/license.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/notice.txt'
    }

    defaultConfig {
        applicationId "$PackageName"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
        flavor1 {

        }
        flavor2 {

        }
    }
}
apt {
    arguments {
        androidManifestFile variant.outputs[0].processResources.manifestFile
        resourcePackageName "$PackageName"
    }
}
解决方案

I'm myself using AndroidAnnotations for a while now and I have a few projects that require product flavors as well. So far I managed to make it work.

My guess would be that you misconfigured your resourcePackageName in your apt.

Here is what I do in my (truncated) build.gradle file:

ext {
APP_NAME = "your app name here"
}

defaultConfig {
    applicationId APP_GROUP
    versionName APP_VERSION
    versionCode 1

    minSdkVersion 12
    targetSdkVersion 21
}

apt {
arguments {
    androidManifestFile variant.outputs[0].processResources.manifestFile
    resourcePackageName android.defaultConfig.applicationId
}
}

You might also want to have a custom applicationId for each flavor your using. You can do it that way:

productFlavors {
    flavor1 {
        applicationId android.defaultConfig.applicationId + ".flavor1"
    }
    flavor2 {
        applicationId android.defaultConfig.applicationId + ".flavor2"
    }
}

Hope this solves your issue ;)

这篇关于Android的注释和口味Android Studio中1.0.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 12:06