The Android griddle plug in creates
a set of configurations for
each build variant.
This allows us to manage dependencies
independently for each of our variants.
So we'll have the usual compile and
run time configurations.
But we'll also have free compile and
free runtime.
And so on.
The free runtime configuration extends
the free compile configuration.
Just as compile extends runtime
when using the Java plugin.
Additionally, free compile configuration
extends the regular compile
configuration.
Which means our free variance will
include all of our default dependencies.
In addition to those added
to the free configurations.
It's probably likely that we would
want to enable ads in the free version
of our app, but not in the paid.
Utilizing Google's Ad Services requires
to depend on the Ad Services Library.
However we don't want to unnecessarily
bloat the paid version of our app
by including a library
that won't be needed.
To solve this problem we can simply
declare this dependency only for
the free version of our app.
As you can see here,
we've added a dependency to
the Google Play ad services.
But we've assigned it to
the free compile configuration.
That's really there is to declaring
variant specific dependencies.
But we've included a demo
in the course repository.
You should check it out.
يقوم ملحق Android griddle بإنشاء
مجموعة من التكوينات
.لكل متغير تم إنشاؤه
وهذا ما يسمح لنا بإدارة التبعيات
.بشكل مستقل عن كل من متغيراتنا
وبالتالي سيكون لدينا المجموعة المعتادة
.وتكوينات وقت التشغيل
ولكن سيكون لدينا أيضًا مجموعة حرة
.وزمن تشغيل حر
.ونحو ذلك
ويمتد تكوين زمن التشغيل الحر إلى ما يزيد عن
.تكوين المجموعة الحرة
تمامًا مثل المجموعة التي تقوم بمد زمن التشغيل
.عند مكون Java الإضافي
وبالإضافة لذلك، يمتد تكوين المجموعة المجانية
إلى ما يزيد عن تكوين المجموعة
.العادية
الأمر الذي يعني أن متغيرنا المجاني سوف يشمل
.كل تبعياتنا الافتراضية
إضافة إلى تلك التي تمت إضافتها
.إلى التكوينات المجانية
ومن المحتمل أننا كنا نريد على الأرجح
تمكين الإعلانات في الإصدار المجاني
.من تطبيقنا ولكن ليس في المدفوع
وتتطلب الاستفادة من Google's Ad Services
.الاعتماد على مكتبة خدمات الإعلانات
ومع ذلك، فنحن لا نرغب دون داع
تضخيم الإصدار المجاني من تطبيقنا
عن طريق إدراج مكتبة
.قد نكون في غنى عنها
ولحل المشكلة يمكننا ببساطة
توضيح أن هذه التبعية تتعلق
.بالإصدار المجاني من تطبيقنا
،وكما ترون هنا
فإننا قد أضفنا تبعية إلى
.خدمات إعلانات Google Play
ولكننا قمنا بتعيينها في
.تكوين المجموعة المجانية
وهذا حقًا من أجل الإعلان عن
.التبعيات الخاصة بالمتغير
بيد أننا قمنا بإدراج نسخة تجريبية في
.مستودع الدورات
.وينبغي عليكم التحقق منه
O plugin de griddle do Android cria
um conjunto de configurações para
cada variante de compilação.
Isso nos permite gerenciar dependências
independentemente para cada uma das variantes.
Teremos as configurações habituais de
compilação e tempo de execução.
Mas também teremos compilação gratuita e
tempo de execução gratuito.
E assim por diante.
A configuração de tempo de execução gratuita estende
a configuração da compilação livre.
Assim como a compilação estende o tempo de execução
ao usar o plugin Java.
Além disso, a configuração de compilação gratuita
estende a configuração de compilação
comum.
O que significa que a variação gratuita
incluirá todas as dependências padrão.
Além das adicionadas
às configurações gratuitas.
É provável que queiramos
habilitar anúncios na versão gratuita
do aplicativo, mas não na versão paga.
O uso dos Serviços de anúncios do Google
requer dependência da Biblioteca de serviços de anúncios.
No entanto, não quero, desnecessariamente,
inchar a versão paga do aplicativo
incluindo uma biblioteca
desnecessária.
Para resolver esse problema, podemos simplesmente
declarar essa dependência apenas para
a versão gratuita do aplicativo.
Como se pode ver aqui,
adicionamos uma dependência aos
serviços de anúncios do Google Play.
Mas nós a atribuímos à
configuração de compilação gratuita.
É tudo o que há para declarar
dependências específicas de variantes.
Mas incluímos uma demonstração
no repositório do curso.
Confira!
Android gradle 插件
可为每个构建
变种创建一组配置。
这允许我们为我们的每个
变种独立地管理依赖性。
因此我们将有通常的编译和运行时间配置。
但是我们还将有免费的编译和免费的运行时间,
等等。
免费的运行时间配置可扩展免费的编译配置,
正如当使用 Java 插件时,编译
可扩展运行时间一样。
另外,免费的编译配置可扩展常规的编译
配置。
这意味着我们的免费变化将
包括我们所有的默认依赖性。
除添加到免费配置的广告外,
我们很可能想启用我们
应用程序免费版中而非
付费版中的广告。
使用 Google 的广告服务,需要
依赖广告服务库。
然而,我们不想通过将不会需要的库
包括进来而不必要地膨胀我们应用
程序的付费版。
为解决这一问题,我们只要声明
本依赖性仅针对我们应用程序的
免费版。
正如你所看到的,
我们已经向 Google Play 广告
服务添加了一个依赖性。
但是我们已将其分配到免费编译配置。
这的确是要声明具体依赖性变种。
但是我们已经在课程资源库
中包括了一个演示。
你应查看一下。