常识:
1.什么是签名?
2.什么是代码混淆?
3.什么是多渠道?
一. 配置:
implementation 'com.umeng.sdk:common:1.5.1'
implementation 'com.umeng.sdk:analytics:7.5.0'
二.清单文件配置
application的子标签
!--value的值填写你在友盟后台申请的应用Appkey-->
<meta-data android:value="5d3572c53fc19544630000d6" android:name="UMENG_APPKEY"/>
<!--value的值填写渠道名称,例如yingyongbao。这里设置动态渠道变量-->
<meta-data android:value="${UMENG_CHANNEL_VALUE}" android:name="UMENG_CHANNEL"/>
三. moudle gradle配置
android {
compileSdkVersion 28
buildToolsVersion "29.0.0"
defaultConfig {
flavorDimensions "default"
manifestPlaceholders = [qqappid: "100424468"]
applicationId "com.example.ument"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
productFlavors {
Alpha {//自己打包测试使用
manifestPlaceholders = [UMENG_CHANNEL_VALUE: Alpha]
}
Tencent {//投放应用宝市场
manifestPlaceholders = [UMENG_CHANNEL_VALUE: Tencent]
}
Baidu {//投放百度市场
manifestPlaceholders = [UMENG_CHANNEL_VALUE: Baidu]
}
Qihoo {//投放360市场
manifestPlaceholders = [UMENG_CHANNEL_VALUE: Qihoo]
}
Alibaba {//投放阿里巴巴
manifestPlaceholders = [UMENG_CHANNEL_VALUE: Alibaba]
}
Vivo {//投放vivo市场
manifestPlaceholders = [UMENG_CHANNEL_VALUE: Vivo]
}
Oppo {//投放oppo市场
manifestPlaceholders = [UMENG_CHANNEL_VALUE: Oppo]
}
Xiaomi {//投放小米市场
manifestPlaceholders = [UMENG_CHANNEL_VALUE: Xiaomi]
}
Huawei {//投放华为应用市场
manifestPlaceholders = [UMENG_CHANNEL_VALUE: Huawei]
}
productFlavors.all { flavor ->
flavor.manifestPlaceholders = [UMENG_CHANNEL_VALUE: name]
}
}
}
四.代码混淆
1.gradle设置允许混淆
2.以下是混淆文件 proguard-rules.pro
-dontshrink
-dontoptimize
-dontwarn com.google.android.maps.**
-dontwarn android.webkit.WebView
-dontwarn com.umeng.**
-dontwarn com.tencent.weibo.sdk.**
-dontwarn com.facebook.**
-keep public class javax.**
-keep public class android.webkit.**
-dontwarn android.support.v4.**
-keep enum com.facebook.**
-keepattributes Exceptions,InnerClasses,Signature
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keep public interface com.facebook.**
-keep public interface com.tencent.**
-keep public interface com.umeng.socialize.**
-keep public interface com.umeng.socialize.sensor.**
-keep public interface com.umeng.scrshot.**
-keep public class com.umeng.socialize.* {*;}
-keep class com.facebook.**
-keep class com.facebook.** { *; }
-keep class com.umeng.scrshot.**
-keep public class com.tencent.** {*;}
-keep class com.umeng.socialize.sensor.**
-keep class com.umeng.socialize.handler.**
-keep class com.umeng.socialize.handler.*
-keep class com.umeng.weixin.handler.**
-keep class com.umeng.weixin.handler.*
-keep class com.umeng.qq.handler.**
-keep class com.umeng.qq.handler.*
-keep class UMMoreHandler{*;}
-keep class com.tencent.mm.sdk.modelmsg.WXMediaMessage {*;}
-keep class com.tencent.mm.sdk.modelmsg.** implements com.tencent.mm.sdk.modelmsg.WXMediaMessage$IMediaObject {*;}
-keep class im.yixin.sdk.api.YXMessage {*;}
-keep class im.yixin.sdk.api.** implements im.yixin.sdk.api.YXMessage$YXMessageData{*;}
-keep class com.tencent.mm.sdk.** {
*;
}
-keep class com.tencent.mm.opensdk.** {
*;
}
-keep class com.tencent.wxop.** {
*;
}
-keep class com.tencent.mm.sdk.** {
*;
}
-keep class com.twitter.** { *; }
-keep class com.tencent.** {*;}
-dontwarn com.tencent.**
-keep class com.kakao.** {*;}
-dontwarn com.kakao.**
-keep public class com.umeng.com.umeng.soexample.R$*{
public static final int *;
}
-keep public class com.linkedin.android.mobilesdk.R$*{
public static final int *;
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class com.tencent.open.TDialog$*
-keep class com.tencent.open.TDialog$* {*;}
-keep class com.tencent.open.PKDialog
-keep class com.tencent.open.PKDialog {*;}
-keep class com.tencent.open.PKDialog$*
-keep class com.tencent.open.PKDialog$* {*;}
-keep class com.umeng.socialize.impl.ImageImpl {*;}
-keep class com.sina.** {*;}
-dontwarn com.sina.**
-keep class com.alipay.share.sdk.** {
*;
}
-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
-keep class com.linkedin.** { *; }
-keep class com.android.dingtalk.share.ddsharemodule.** { *; }
-keepattributes Signature
五. 签名打包
1.build—>generate
2.选择apk—>next
3. 选择要打包的moudle和创建key签名