Skip to content

Commit

Permalink
feat: 友盟统计集成,打包混淆
Browse files Browse the repository at this point in the history
  • Loading branch information
wkl007 committed Jun 20, 2021
1 parent 2349545 commit 71cb1a1
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 3 deletions.
9 changes: 7 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ android {
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
ndk {
abiFilters "armeabi-v7a", "arm64-v8a", "x86_64", "x86"
// abiFilters "armeabi-v7a", "arm64-v8a", "x86_64", "x86"
// TODO 只打包flutter所支持的架构,flutter没有armeabi架构的so,加x86的原因是为了能够兼容模拟器
// abiFilters "armeabi-v7a" // release 时只打"armeabi-v7包
abiFilters "armeabi-v7a" // release 时只打"armeabi-v7包
}
}

Expand All @@ -64,6 +64,11 @@ android {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
// 开启混淆
minifyEnabled true // 启用代码混淆、压缩APK
shrinkResources true // 删除无用资源
useProguard true // 代码压缩设置
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' // 混淆文件
signingConfig signingConfigs.release
}
}
Expand Down
20 changes: 20 additions & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#Flutter Wrapper
-dontwarn io.flutter.**
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
#友盟
-keep class com.umeng.** {*;}
-keepclassmembers class * {
public <init> (org.json.JSONObject);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep public class [com.wkl.flutter_trip].R$*{
public static final int *;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
package com.wkl.flutter_bilibili

import android.os.Bundle

import io.flutter.embedding.android.FlutterActivity
import com.umeng.analytics.MobclickAgent
import com.umeng.commonsdk.UMConfigure

class MainActivity : FlutterActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
UMConfigure.init(this, "60cf1e5626a57f10182e89ba", "Flutter BiliBili", UMConfigure.DEVICE_TYPE_PHONE, null)
}

override fun onPause() {
super.onPause()
MobclickAgent.onPause(this)
}

class MainActivity: FlutterActivity() {
override fun onResume() {
super.onResume()
MobclickAgent.onResume(this)
}
}
7 changes: 7 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.0"
umeng_common_sdk:
dependency: "direct main"
description:
name: umeng_common_sdk
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.3"
underline_indicator:
dependency: "direct main"
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dependencies:
web_socket_channel: ^2.1.0
flutter_overlay: ^1.0.0
provider: ^5.0.0
umeng_common_sdk: ^1.1.3

dev_dependencies:
build_runner: ^2.0.4
Expand Down

0 comments on commit 71cb1a1

Please sign in to comment.