productFlavors应用程序id与android注释

时间:2016-01-12 17:13:51

标签: java android android-studio build android-productflavors

我正在尝试用android studio做一个multiBuild,但是当我添加applicationId“***”时我收到错误

在我的build.gradle中,我添加了productFlavors

     productFlavors {
    music {

    }

    sport {
        applicationId "com.trueorfalse.ouam.truefalse.sport"
        versionName "1.0-free"
        buildConfigField "boolean", "PAID_VERSION", "false"
    }

}

我收到了这个错误:

  Error:(14, 55) error: cannot find symbol class HomeFragment_
  Error:(15, 60) error: cannot find symbol class QuestionFragments_
  Error:(27, 5) error: cannot find symbol class HomeFragment_
  Error:(14, 55) error: cannot find symbol class HomeFragment_
  Error:(15, 60) error: cannot find symbol class QuestionFragments_
  Error:Execution failed for task ':app:compileSportDebugJavaWithJavac'.
  > Compilation failed; see the compiler error output for details.

就像Android注释不起作用的原因?

如果我删除applicationId所有工作

任何帮助将不胜感激

2 个答案:

答案 0 :(得分:0)

我在这里找到了解决方案:Android annotations and flavors in Android Studio 1.0.1

我补充说           apt {            参数{             androidManifestFile variant.outputs [0] .processResources.manifestFile             resourcePackageName android.defaultConfig.applicationId            }

我修改了这样的productFlavors:

   productFlavors {
        music {
            applicationId android.defaultConfig.applicationId + ".music"
        }
        develop {

        }

        sport {
            applicationId android.defaultConfig.applicationId + ".sport"
        }

    }

答案 1 :(得分:0)

我认为您没有以正确的方式配置 Android Annotation 。 注意 apt->参数

中的注释
  

如果您使用不同的产品,则应在此处设置包装名称   申请ID

defaultConfig {
            applicationId "your.package.name"
            ...
}

//Config Android annotations
apt {
        arguments {
            androidManifestFile variant.outputs[0]?.processResources?.manifestFile
            // if you have multiple outputs (when using splits), you may want to have other index than 0

            // you should set your package name here if you are using different application IDs
            // resourcePackageName "your.package.name"
            resourcePackageName android.defaultConfig.applicationId

            // You can set optional annotation processing options here, like these commented options:
            // logLevel 'INFO'
            // logFile '/var/log/aa.log'
    }
}

    productFlavors{
                mj360 {
                    applicationId android.defaultConfig.applicationId + ".mj360"
                    resValue "string", "app_name", "MyDemo"
                }
                ...
}