项目作者: SupasinTatiyanupanwong

项目描述 :
Encapsulates Android's Ads APIs. Supports Google Ads and Huawei Ads.
高级语言: Java
项目地址: git://github.com/SupasinTatiyanupanwong/ads-kit-android.git
创建时间: 2020-06-12T15:52:17Z
项目社区:https://github.com/SupasinTatiyanupanwong/ads-kit-android

开源协议:Apache License 2.0

下载


Ads Kit

javadoc
license

Ads Kit is an abstraction wrapper that encapsulates Android’s Ads APIs from Google and Huawei.

Architecture

The library consists of 3 artifacts; ads-core, ads-google, and ads-huawei.

  • ads-core artifact provides an abstraction layer to interact with the Android’s Ads APIs.
  • ads-google artifact provides an integration with the Google Mobile Ads SDK.
  • ads-huawei artifact provides an integration with the Huawei Ads SDK.

Usage

Limitations

Only Advertising ID is currently supported.

Migrating from the existing Ads APIs

Existing Name Ads Kit Name
AdvertisingIdClient.getAdvertisingIdInfo(Context) AdsKit.getAdvertisingIdClient(Context).getAdvertisingIdInfo()

Additional documentation

Declaring dependencies

Add the dependencies for the artifacts you need in the build.gradle file for your app or module:

  1. dependencies {
  2. // To use the Google Mobile Ads SDK via Ads Kit
  3. implementation 'dev.supasintatiyanupanwong.libraries.android.kits.ads:ads-google:0.1.0'
  4. // To use the Huawei Ads SDK via Ads Kit
  5. implementation 'dev.supasintatiyanupanwong.libraries.android.kits.ads:ads-huawei:0.1.0'
  6. }

If both of integration artifacts are included in your final build, the implementation will be selected based on API availability upon application startup.

However, it is recommended to separate builds between them as next:

  1. android {
  2. // ...
  3. flavorDimensions 'vendor'
  4. productFlavors {
  5. google
  6. huawei { applicationIdSuffix '.huawei' }
  7. }
  8. }
  9. configurations {
  10. google
  11. huawei
  12. googleImplementation.extendsFrom(google)
  13. googleCompileOnly.extendsFrom(huawei)
  14. huaweiImplementation.extendsFrom(huawei)
  15. huaweiCompileOnly.extendsFrom(google)
  16. }
  17. dependencies {
  18. google 'dev.supasintatiyanupanwong.libraries.android.kits.ads:ads-google:0.1.0'
  19. huawei 'dev.supasintatiyanupanwong.libraries.android.kits.ads:ads-huawei:0.1.0'
  20. }

Although make sure to have at least one of the integration artifacts included in your final build, otherwise an exception will be thrown at runtime.

For more information about dependencies, see Add build dependencies.

License

  1. Copyright 2020 Supasin Tatiyanupanwong
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.