dependencies by flavor in android studio build.gradle file, is it possible?

北城以北 提交于 2020-01-06 20:23:49

问题


image in my build.gradle file i have the following dependencies:

dependencies { compile 'com.android.support:support-v13:22.1.1' compile 'com.android.support:appcompat-v7:22.1.1' compile 'com.jakewharton:butterknife:6.0.0' }

and imagine i have the following product flavors defined:

productFlavors {
    germanyMock {
        applicationId "org.mymocksite.mock"
    }

    usaMock {
        applicationId "org.myqasite.qa"
    }

}

suppose i want to have a dependency by flavor only, then could i do this:

dependencies {
    compile 'com.android.support:support-v13:22.1.1'
    compile 'com.android.support:appcompat-v7:22.1.1'
    usaMockcompile 'com.jakewharton:butterknife:6.0.0'//this does not work for me
}

so the above does not work for me but i was thinking since there is a testCompile and i think a mockCompile shouldn't there be a flavorCompile ? if not how can i see all the "compiles" that are available to me ?


回答1:


Change to usaMockCompile change from c to C.

dependencies {
    compile 'com.android.support:support-v13:22.1.1'
    compile 'com.android.support:appcompat-v7:22.1.1'
    usaMockCompile 'com.jakewharton:butterknife:6.0.0'
}


来源:https://stackoverflow.com/questions/31569125/dependencies-by-flavor-in-android-studio-build-gradle-file-is-it-possible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!