檢視 Android Getting Started SDK8 的原始碼
←
Android Getting Started SDK8
跳至導覽
跳至搜尋
由於下列原因,您沒有權限進行編輯此頁面的動作:
您請求的操作只有這個群組的使用者能使用:
使用者
您可以檢視並複製此頁面的原始碼。
== <b>簡介</b> == :TAmedia SDK提供Android Mobile App開發者簡易迅速的方式整合行動App廣告, 廣告的種類包含<br> :<ul><li>Banner</li></ul> :<ul><li>Interstitial</li></ul> :<ul><li>InRead Anchor</li></ul> :<ul><li>Native</li></ul> <br> == <b>系統需求</b> == :Android 5.0以上 (API Level 21+) <br> == <b>SDK說明文件</b> == [http://wiki.tamedia.com.tw/androidDoc/index.html SDK說明文件] <br> == <b>Android Studio專案整合SDK</b> == 請按照下列方式設置專案<br><br> <big><u>Step 1: 將SDK放入app專案的<b>libs</b>資料夾</u></big><br><br> :請至[[Download MADP Android SDK|下載 Download SDK]]下載SDK,並將壓縮檔內的AAR檔 (adpmobile-lib-r8.0.0.aar) 放至專案的libs資料夾, 若無libs資料夾請自行建立<br> [[檔案:AS SDK8 aar.png | 300px]] <br> <big><u>Step 2-1: 編輯app專案中<b>build.gradle</b></u></big><br> [[檔案:AS SDK8 gradle.png | 300px]] <br> :請加入TAmedia SDK aar與下列相依性函式庫 :<ul><li>kotlin</li></ul> :<ul><li>kotlin-coroutines</li></ul> :<ul><li>retrofit</li></ul> :<ul><li>google play service identifier</li></ul> :<ul><li>gson</li></ul> :<ul><li>lifecycle</li></ul> :<ul><li>viewModel ktx</li></ul> :<ul><li>appset</ul> == <b>Gradle設定</b> == <source> 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' } </source> :compileOptions請加入JAVA 8 <source> android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } </source> <br> <big><u>Step 2-2: 在Project的<b>build.gradle</b>的repositories內加入google()</u></big><br> [[檔案:Import SDK7 Step2-2.PNG]] <br> <source> 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() } } </source> <br><br> <big><u>Step 3: 在<b>AndroidManifest.xml</b>的manifest tag宣告權限</u></big><br> [[檔案:Import SDK7 Step3-1.PNG]] :<ul><li>Required Permission</li></ul> <!-- 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" /> :<ul><li>Optional Permission</li></ul> <!-- 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" /> <br> == <b>Target API 為 31+ (Android 12) 的應用程式</b> == : Target API 為 31+的開發者應用程式,請於AndroidManifest.xml中加入下列使用權限 <source> <uses-permission android:name="com.google.android.gms.permission.AD_ID"/> </source> <br> : Target API 為 31+的開發者應用程式,但是屬於 <b>闔家適用計畫,或將兒童導向應用程式</b> 請於AndroidManifest.xml中加入下列使用權限 <source> <uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/> </source> <br> : Target API 為 30 以下的開發者應用程式,則不須增加此權限 <br> 詳情可參考Google網站說明:<br> [https://support.google.com/googleplay/android-developer/answer/6048248?hl=zh-Hant 2021 年 Google Play 服務更新] <br> [https://support.google.com/googleplay/android-developer/topic/9877766 Google Play Policy - 家庭] <br> == <b>Target API 為 34 (Android 14) 的應用程式 [[檔案:new-xxl.png|30px]] </b> == : Target API 為 34的開發者應用程式,請下載MADP 8.0.5 SDK, 並參考下面Gradle相依性設定, Proguard混淆設定 <br> === <b>Gradle設定</b> === <source> implementation(fileTree(include: ['*.aar'], dir: 'libs')) // =======================================================================// // MADP library dependencies // =======================================================================// // 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:18.0.1' // app set id implementation 'com.google.android.gms:play-services-appset:16.0.2' // gson implementation 'com.google.code.gson:gson:2.10.1' // jetpack security implementation "androidx.security:security-crypto:1.1.0-alpha06" // ActivityResultContracts implementation 'androidx.activity:activity-ktx:1.8.2' </source> <br> === <b>Proguard設定</b> === <source> ##---------------Begin: proguard for MADP ---------- -dontoptimize -optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/* -optimizationpasses 5 -dontusemixedcaseclassnames -keepattributes *Annotation*,InnerClasses,EnclosingMethod,SourceFile,LineNumberTable -dontpreverify -verbose -dontwarn android.support.** -keep public class com.google.vending.licensing.ILicensingService -keep public class com.android.vending.licensing.ILicensingService -keeppackagenames com.taiwanmobile.pt.**, com.iab.omid.library.taiwanmobile.** # keep setters in Views so that animations can still work. # see http://proguard.sourceforge.net/manual/examples.html#beans -keepclassmembers public class * extends android.view.View { void set*(***); *** get*(); } # We want to keep methods in Activity that could be used in the XML attribute onClick -keepclassmembers class * extends android.app.Activity { public void *(android.view.View); } -keep class * extends android.os.Parcelable { public static final android.os.Parcelable$Creator *; } -keepclassmembers class **.R$* { public static <fields>; } -keep public enum com.taiwanmobile.pt.adp.view.TWMAdRequest$** { **[] $VALUES; public <fields>; public <methods>; } -keep class com.taiwanmobile.pt.adp.TWMMobileAds { public protected <fields>; public protected <methods>; } -keepclassmembers class com.taiwanmobile.pt.adp.TWMMobileAds { public static ** Companion; } -keep class com.taiwanmobile.pt.adp.view.*, com.taiwanmobile.pt.adp.view.inread.*, com.taiwanmobile.pt.adp.view.webview.**, com.taiwanmobile.pt.adp.nativead.* { public protected <fields>; public protected <methods>; } -keep class com.iab.omid.library.taiwanmobile.** { public protected <fields>; public protected <methods>; } # Also keep - Enumerations. Keep the special static methods that are required in # enumeration classes. -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } # Keep names - Native method names. Keep all native class/method names. -keepclasseswithmembers,allowshrinking class * { native <methods>; } ##---------------End: proguard for MADP ---------- ##---------------Begin: proguard for Retrofit ---------- # Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and # EnclosingMethod is required to use InnerClasses. -keepattributes Signature, InnerClasses, EnclosingMethod # Retrofit does reflection on method and parameter annotations. -keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations # Keep annotation default values (e.g., retrofit2.http.Field.encoded). -keepattributes AnnotationDefault # Retain service method parameters when optimizing. -keepclassmembers,allowshrinking,allowobfuscation interface * { @retrofit2.http.* <methods>; } # Ignore annotation used for build tooling. -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement # Ignore JSR 305 annotations for embedding nullability information. -dontwarn javax.annotation.** # Guarded by a NoClassDefFoundError try/catch and only used when on the classpath. -dontwarn kotlin.Unit # Top-level functions that can only be used by Kotlin. -dontwarn retrofit2.KotlinExtensions -dontwarn retrofit2.KotlinExtensions$* # With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy # and replaces all potential values with null. Explicitly keeping the interfaces prevents this. -if interface * { @retrofit2.http.* <methods>; } -keep,allowobfuscation interface <1> # Keep generic signature of Call, Response (R8 full mode strips signatures from non-kept items). -keep,allowobfuscation,allowshrinking interface retrofit2.Call -keep,allowobfuscation,allowshrinking class retrofit2.Response # With R8 full mode generic signatures are stripped for classes that are not # kept. Suspend functions are wrapped in continuations where the type argument # is used. -keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation ##---------------End: proguard for Retrofit ---------- ##---------------Begin: proguard for Gson ---------- # Gson uses generic type information stored in a class file when working with fields. Proguard # removes such information by default, so configure it to keep all of it. -keepattributes Signature # For using GSON @Expose annotation -keepattributes *Annotation* # Gson specific classes -dontwarn sun.misc.** #-keep class com.google.gson.stream.** { *; } # Application classes that will be serialized/deserialized over Gson -keep class com.google.gson.examples.android.model.** { <fields>; } # Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory, # JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter) -keep class * extends com.google.gson.TypeAdapter -keep class * implements com.google.gson.TypeAdapterFactory -keep class * implements com.google.gson.JsonSerializer -keep class * implements com.google.gson.JsonDeserializer # Prevent R8 from leaving Data object members always null -keepclassmembers,allowobfuscation class * { @com.google.gson.annotations.SerializedName <fields>; } # Retain generic signatures of TypeToken and its subclasses with R8 version 3.0 and higher. -keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken -keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken ##---------------End: proguard for Gson ---------- ##---------------Begin: proguard for kotlinx.coroutines ---------- # Allow R8 to optimize away the FastServiceLoader. # Together with ServiceLoader optimization in R8 # this results in direct instantiation when loading Dispatchers.Main -assumenosideeffects class kotlinx.coroutines.internal.MainDispatcherLoader { boolean FAST_SERVICE_LOADER_ENABLED return false; } -assumenosideeffects class kotlinx.coroutines.internal.FastServiceLoaderKt { boolean ANDROID_DETECTED return true; } -keep class kotlinx.coroutines.android.AndroidDispatcherFactory {*;} # Disable support for "Missing Main Dispatcher", since we always have Android main dispatcher -assumenosideeffects class kotlinx.coroutines.internal.MainDispatchersKt { boolean SUPPORT_MISSING return false; } # Statically turn off all debugging facilities and assertions -assumenosideeffects class kotlinx.coroutines.DebugKt { boolean getASSERTIONS_ENABLED() return false; boolean getDEBUG() return false; boolean getRECOVER_STACK_TRACES() return false; } ##---------------End: proguard for kotlinx.coroutines ---------- ##---------------Begin: proguard for Google ads ---------- # For Google Play Services -keep public class com.google.android.gms.ads.**{ public *; } # For old ads classes -keep public class com.google.ads.**{ public *; } # For mediation -keepattributes *Annotation* # Other required classes for Google Play Services # Read more at http://developer.android.com/google/play-services/setup.html -keep class * extends java.util.ListResourceBundle { protected Object[][] getContents(); } -keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable { public static final *** NULL; } -keepnames @com.google.android.gms.common.annotation.KeepName class * -keepclassmembernames class * { @com.google.android.gms.common.annotation.KeepName *; } -keepnames class * implements android.os.Parcelable { public static final ** CREATOR; } ##---------------End: proguard for Google ads ---------- ##---------------Begin: proguard for jetpack security ---------- -dontwarn com.google.errorprone.annotations.Immutable ##---------------End: proguard for jetpack security ---------- ##---------------Begin: Gradle 8.2.1 ---------- -dontwarn java.lang.invoke.StringConcatFactory ##---------------End: Gradle 8.2.1 ---------- </source> <br> == <b>資安相關</b> == === CVE-2023-3635 === Square公司知名套件retrofit(處理網路API)其相依性套件okio有DDOS風險 <br> 解決辦法: build.gradle中增加下列設定 <source> // CVE-2023-3635 // implementation 'com.squareup.okio:okio:3.4.0' </source> 參考資訊: https://nvd.nist.gov/vuln/detail/CVE-2023-3635 <br> [[SDK8_Android_SDK_Developer_Guide | 回首頁]]
返回到「
Android Getting Started SDK8
」。
導覽選單
個人工具
登入
命名空間
頁面
討論
變體
已展開
已摺疊
視圖
閱讀
檢視原始碼
檢視歷史
更多
已展開
已摺疊
搜尋
導覽
首頁
近期變更
隨機頁面
有關 MediaWiki 的說明
工具
連結至此的頁面
相關變更
特殊頁面
頁面資訊