Android Getting Started SDK8

出自TAMedia
於 2023年9月25日 (一) 03:31 由 BrandonTeng留言 | 貢獻 所做的修訂 →‎Gradle設定
跳至導覽 跳至搜尋

簡介

TAmedia SDK提供Android Mobile App開發者簡易迅速的方式整合行動App廣告, 廣告的種類包含
  • Banner
  • Interstitial
  • InRead Anchor
  • Native


系統需求

Android 5.0以上 (API Level 21+)


SDK說明文件

SDK說明文件

Android Studio專案整合SDK

請按照下列方式設置專案

Step 1: 將SDK放入app專案的libs資料夾

請至下載 Download SDK下載SDK,並將壓縮檔內的AAR檔 (adpmobile-lib-r8.0.0.aar) 放至專案的libs資料夾, 若無libs資料夾請自行建立

AS SDK8 aar.png


Step 2-1: 編輯app專案中build.gradle

AS SDK8 gradle.png


請加入TAmedia SDK aar與下列相依性函式庫
  • kotlin
  • kotlin-coroutines
  • retrofit
  • google play service identifier
  • gson
  • lifecycle
  • viewModel ktx
  • appset

Gradle設定

dependencies {

    // =======================================================================//
    // MADP library
    // =======================================================================//
    implementation files('libs/adpmobile-lib-r8.0.0.aar')

    // =======================================================================//
    // MADP library dependencies
    // =======================================================================//
    // kotlin
    implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.10'
    // kotlin-coroutines
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0"
    // retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
    // google play service identifier
    implementation 'com.google.android.gms:play-services-ads-identifier:17.0.1'
    // gson
    implementation 'com.google.code.gson:gson:2.8.6'
    // lifecycle
    def lifecycle_version = "2.4.0-alpha03"
    def arch_version = "2.1.0"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-service:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-process:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycle_version"
    testImplementation "androidx.arch.core:core-testing:$arch_version"
    // viewModel ktx extension
    implementation 'androidx.activity:activity-ktx:1.3.1'
    // app set id
    implementation 'com.google.android.gms:play-services-appset:16.0.1'
    // Jetpack Security
    implementation "androidx.security:security-crypto:1.1.0-alpha03"
    // CVE-2023-3635
    implementation 'com.squareup.okio:okio:3.4.0'
}


compileOptions請加入JAVA 8
  android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
  }


Step 2-2: 在Project的build.gradle的repositories內加入google()

Import SDK7 Step2-2.PNG


buildscript {
    ext.kotlin_version = "1.5.10"
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
    }
}




Step 3: 在AndroidManifest.xml的manifest tag宣告權限

Import SDK7 Step3-1.PNG

  • Required Permission
 <!-- TAmedia Required Permission -->
 <uses-permission android:name="android.permission.INTERNET" />
 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  • Optional Permission
 <!-- TAmedia Optional Permission -->
 <uses-permission android:name="android.permission.VIBRATE" /> 
 <uses-permission android:name="android.permission.CAMERA" />
 <uses-permission android:name="android.permission.RECORD_AUDIO" />
 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />


Target API 為 31+ (Android 12以上) 的應用程式

Target API 為 31+的開發者應用程式,請於AndroidManifest.xml中加入下列使用權限
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>


Target API 為 31+的開發者應用程式,但是屬於 闔家適用計畫,或將兒童導向應用程式 請於AndroidManifest.xml中加入下列使用權限
<uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>


Target API 為 30 以下的開發者應用程式,則不須增加此權限


詳情可參考Google網站說明:
2021 年 Google Play 服務更新
Google Play Policy - 家庭


回首頁