Using build types in Gradle to run same app that uses ContentProvider on one device

后端 未结 14 1050
小蘑菇
小蘑菇 2020-11-28 00:22

I have set up Gradle to add package name suffix to my debug app so I could have release version that I\'m using and debug version on one phone. I was referencing this: http:

14条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 00:57

    I don't know if anybody mention it. Actually after android gradle plugin 0.10+, the manifest merger will provide the official support for this function: http://tools.android.com/tech-docs/new-build-system/user-guide/manifest-merger

    In AndroidManifest.xml, you can use ${packageName} like this:

    
    

    And in your build.gradle you can have:

    productFlavors {
        free {
            packageName "org.pkg1"
        }
        pro {
            packageName "org.pkg2"
        }
    }
    

    See full example here: https://code.google.com/p/anymemo/source/browse/AndroidManifest.xml#152

    and here: https://code.google.com/p/anymemo/source/browse/build.gradle#41

提交回复
热议问题