1、删除打包x86架构的配置

2、声网SO不做动态加载
3、美颜so动态加载
This commit is contained in:
老皮 2024-09-24 18:20:38 +08:00
parent 13a373c73b
commit b300541ce9
11 changed files with 109 additions and 55 deletions

View File

@ -33,7 +33,8 @@ android {
versionName rootProject.ext.android.versionName
manifestPlaceholders = rootProject.ext.manifestPlaceholders
ndk {
abiFilters "armeabi-v7a", "arm64-v8a","x86","x86_64"
abiFilters "armeabi-v7a", "arm64-v8a"
// abiFilters "armeabi-v7a", "arm64-v8a","x86","x86_64"
}
}
aaptOptions {

View File

@ -68,18 +68,67 @@ android {
exclude 'lib/armeabi-v7a/libMNN_CL.so'
exclude 'lib/armeabi-v7a/libMNN_Express.so'
// SO
if (rootProject.ext.manifestPlaceholders.isGooglePlay == 0) {
// SO
exclude 'lib/armeabi-v7a/libCNamaSDK.so'
exclude 'lib/arm64-v8a/libCNamaSDK.so'
exclude 'lib/x86_64/libCNamaSDK.so'
exclude 'lib/x86/libCNamaSDK.so'
exclude 'lib/armeabi-v7a/libfuai.so'
exclude 'lib/arm64-v8a/libCNamaSDK.so'
exclude 'lib/arm64-v8a/libfuai.so'
exclude 'lib/x86_64/libfuai.so'
exclude 'lib/x86/libfuai.so'
/* // X86架构的so
exclude 'lib/x86/libagora-core.so'
exclude 'lib/x86/libagora-ffmpeg.so'
exclude 'lib/x86/libagora-fdkaac.so'
exclude 'lib/x86/libagora-soundtouch.so'
exclude 'lib/x86/libagora-rtc-sdk.so'
*//* exclude 'lib/x86/libagora_ai_echo_cancellation_extension.so'
exclude 'lib/x86/libagora_ai_noise_suppression_extension.so'
exclude 'lib/x86/libagora_audio_beauty_extension.so'
exclude 'lib/x86/libagora_clear_vision_extension.so'
exclude 'lib/x86/libagora_content_inspect_extension.so'
exclude 'lib/x86/libagora_face_detection_extension.so'
exclude 'lib/x86/libagora_face_capture_extension.so'
exclude 'lib/x86/libagora_lip_sync_extension.so'
exclude 'lib/x86/libagora_screen_capture_extension.so'
exclude 'lib/x86/libagora_segmentation_extension.so'
exclude 'lib/x86/libagora_spatial_audio_extension.so'
exclude 'lib/x86/libagora_video_av1_decoder_extension.so'
exclude 'lib/x86/libagora_video_decoder_extension.so'
exclude 'lib/x86/libagora_video_encoder_extension.so'
exclude 'lib/x86/libagora_video_quality_analyzer_extension.so'
exclude 'lib/x86/libagora_video_dec.so'
exclude 'lib/x86/libagora_video_enc.so'*//*
exclude 'lib/x86_64/libagora-core.so'
exclude 'lib/x86_64/libagora-ffmpeg.so'
exclude 'lib/x86_64/libagora-fdkaac.so'
exclude 'lib/x86_64/libagora-soundtouch.so'
exclude 'lib/x86_64/libagora-rtc-sdk.so'
*//* exclude 'lib/x86_64/libagora_clear_vision_extension.so'
exclude 'lib/x86_64/libagora_segmentation_extension.so'
exclude 'lib/x86_64/libagora_screen_capture_extension.so'
exclude 'lib/x86_64/libagora_audio_beauty_extension.so'
exclude 'lib/x86_64/libagora_spatial_audio_extension.so'
exclude 'lib/x86_64/libagora_video_decoder_extension.so'
exclude 'lib/x86_64/libagora_video_encoder_extension.so'
exclude 'lib/x86_64/libagora_video_av1_decoder_extension.so'
exclude 'lib/x86_64/libagora_content_inspect_extension.so'
exclude 'lib/x86_64/libagora_video_quality_analyzer_extension.so'
exclude 'lib/x86_64/libagora_face_detection_extension.so'
exclude 'lib/x86_64/libagora_face_capture_extension.so'
exclude 'lib/x86_64/libagora_ai_noise_suppression_extension.so'
exclude 'lib/x86_64/libagora_ai_echo_cancellation_extension.so'
exclude 'lib/x86_64/libagora_lip_sync_extension.so'
exclude 'lib/x86_64/libagora_video_dec.so'
exclude 'lib/x86_64/libagora_video_enc.so'*/
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_18
targetCompatibility JavaVersion.VERSION_18
@ -258,8 +307,8 @@ android {
println("处理ndk 版本 = " + tskReqStr)
def isLink = tskReqStr.contains("Link")
if (isLink) {//32so库可以有效降低包体大小
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
// abiFilters "arm64-v8a", "x86_64"
// abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
abiFilters "armeabi-v7a", "arm64-v8a"
println("打包ndk 链接")
} else {
abiFilters "armeabi-v7a", "arm64-v8a"

View File

@ -159,22 +159,22 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
e.printStackTrace();
}
SpUtil.getInstance().setBooleanValue("NOTIFICATION", NotificationManagerCompat.from(this).areNotificationsEnabled());
Log.i("downLoad","架构: " + Build.CPU_ABI);
if(CommonAppConfig.IS_GOOGLE_PLAY != 0){
//渠道包
mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000);
}else {
if(CommonAppConfig.IS_GOOGLE_PLAY == 0){
//链接包 下载so库
checkFaceUnitySOFile();
checkAgoraSOFile();
// checkAgoraSOFile();
}else {
//渠道包
mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000);
}
}
private void checkFaceUnitySOFile() {
File outputDir = new File(mContext.getDir("lib", Context.MODE_PRIVATE).getAbsoluteFile(), Constants.DOWNLOAD_FaceUnity_SO);
String cpuAbi = "";
cpuAbi = Build.CPU_ABI;
String cpuAbi = Build.CPU_ABI;
if (!outputDir.exists()) {
outputDir.mkdirs();
}
@ -190,30 +190,29 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
Log.i("download", soUrl);
if (!fileSo.exists()) {
downloadSo(outputDir.getAbsolutePath(), soUrl,Constants.FaceUnity_SO_Name,false);
downloadSo(outputDir.getAbsolutePath(), soUrl,Constants.FaceUnity_SO_Name,true);
}else if (fileSo.exists() && getFileCount(outputDir.getAbsolutePath()) < 3) {
fileSo.delete();
downloadSo(outputDir.getAbsolutePath(), soUrl,Constants.FaceUnity_SO_Name,false);
downloadSo(outputDir.getAbsolutePath(), soUrl,Constants.FaceUnity_SO_Name,true);
}
}
private void checkAgoraSOFile() {
//存储路径 //检查是否下载过
File outputDir = new File(mContext.getDir("lib", Context.MODE_PRIVATE).getAbsoluteFile(), Constants.DOWNLOAD_Agora_SO);
Log.i("downLoad", "outputDir.getAbsolutePath() = " + outputDir.getAbsolutePath());
Log.i("downLoad", "outputDir.getAbsolutePath() 1 = " + outputDir.getAbsolutePath());
String cpuAbi = "";
cpuAbi = Build.CPU_ABI;
String cpuAbi = Build.CPU_ABI;
if (!outputDir.exists()) {
Log.e("downLoad", "outputDir:>>>" + outputDir.exists());
outputDir.mkdirs();
}
File fileSo = new File(outputDir, Constants.Agora_SO_Name);
Log.i("downLoad", "fileSo.getAbsolutePath() = " + fileSo.getAbsolutePath());
Log.i("downLoad", "fileSo.getAbsolutePath() 2 = " + fileSo.getAbsolutePath());
File fileSoList = new File(outputDir, cpuAbi);
Log.i("downLoad", "fileSoList.getAbsolutePath() = " + fileSoList.getAbsolutePath());
Log.i("downLoad", "fileSoList.getAbsolutePath() 3 = " + fileSoList.getAbsolutePath());
//解压后的文件数量必须要有22个
//如果文件存在解压后 文件数量一致直接进入下一步

View File

@ -35,13 +35,7 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
/*if (new File("$AGORA_RTC_SDK").exists()) {
api fileTree(dir: "${AGORA_RTC_SDK}", include: ['*.jar', '*.aar'])
} else {
api "$AGORA_RTC_SDK"
}*/
if (rootProject.ext.manifestPlaceholders.isGooglePlay != 0) {
/* if (rootProject.ext.manifestPlaceholders.isGooglePlay != 0) {
println("isGooglePlayyes " + rootProject.manifestPlaceholders.isGooglePlay)
println('应用市场安装包使用远程依赖声网SDK')
api "$AGORA_RTC_SDK"
@ -49,7 +43,8 @@ dependencies {
println("isGooglePlay 链接包:>>> " + rootProject.ext.manifestPlaceholders.isGooglePlay)
println('链接包使用本地声网Jar + 下载SO')
api files('../libs/agora-rtc-sdk.jar')
}
}*/
api "$AGORA_RTC_SDK"
api project(path: ':FaceUnity')
api project(path: ':common')
}

View File

@ -93,19 +93,12 @@ public class SWAuManager extends BaseCacheManager {
config.mAppId = CommonAppConfig.getSwAppId();
config.mEventHandler = mRtcEventHandler;
if(CommonAppConfig.IS_GOOGLE_PLAY == 0){
/*if(CommonAppConfig.IS_GOOGLE_PLAY == 0){
//链接包声网加载下载的 So文件
String cpuAbi = "";
cpuAbi = Build.CPU_ABI;
File file = new File(mContext.getDir("lib", Context.MODE_PRIVATE).getAbsoluteFile(), com.yunbao.common.Constants.DOWNLOAD_Agora_SO + File.separator + cpuAbi);
File file = new File(mContext.getDir("lib", Context.MODE_PRIVATE).getAbsoluteFile(), com.yunbao.common.Constants.DOWNLOAD_Agora_SO + File.separator + Build.CPU_ABI);
config.mNativeLibPath = file.getAbsolutePath();
Log.i("downLoad", "声网 SO Path = " + config.mNativeLibPath);
// 美颜SO设置
File file_FaceUnity = new File(mContext.getDir("lib", Context.MODE_PRIVATE).getAbsoluteFile(), com.yunbao.common.Constants.DOWNLOAD_FaceUnity_SO + File.separator + cpuAbi);
faceunity.LoadConfig.loadLibrary(file_FaceUnity.getAbsolutePath());
Log.i("downLoad", "美颜SO Path = " + file_FaceUnity.getAbsolutePath());
}
Log.i("downLoad", "声网 SO Path 1 = " + config.mNativeLibPath);
}*/
// 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
@ -129,14 +122,12 @@ public class SWAuManager extends BaseCacheManager {
config.mContext = mContext;
config.mAppId = CommonAppConfig.getSwAppId();
config.mEventHandler = mEventHandler;
if(CommonAppConfig.IS_GOOGLE_PLAY == 0){
/* if(CommonAppConfig.IS_GOOGLE_PLAY == 0){
//链接包声网加载下载的 So文件
String cpuAbi = "";
cpuAbi = Build.CPU_ABI;
File file = new File(mContext.getDir("lib", Context.MODE_PRIVATE).getAbsoluteFile(), com.yunbao.common.Constants.DOWNLOAD_Agora_SO + File.separator + cpuAbi);
File file = new File(mContext.getDir("lib", Context.MODE_PRIVATE).getAbsoluteFile(), com.yunbao.common.Constants.DOWNLOAD_Agora_SO + File.separator + Build.CPU_ABI);
config.mNativeLibPath = file.getAbsolutePath();
Log.i("downLoad", "config.mNativeLibPath 2 = " + config.mNativeLibPath);
}
Log.i("downLoad", "声网 SO Path 2 = " + config.mNativeLibPath);
}*/
// 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
}

View File

@ -1,6 +1,7 @@
package io.agora.beautyapi.faceunity.agora;
import android.app.Activity;
import android.app.LauncherActivity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
@ -131,14 +132,13 @@ public class SWManager extends BaseCacheManager {
config.mContext = mContext;
config.mAppId = CommonAppConfig.getSwAppId();
config.mEventHandler = mRtcEventHandler;
if(CommonAppConfig.IS_GOOGLE_PLAY == 0){
/*if(CommonAppConfig.IS_GOOGLE_PLAY == 0){
//链接包声网加载下载的 So文件
String cpuAbi = "";
cpuAbi = Build.CPU_ABI;
File file = new File(mContext.getDir("lib", Context.MODE_PRIVATE).getAbsoluteFile(), com.yunbao.common.Constants.DOWNLOAD_Agora_SO + File.separator + cpuAbi);
File file = new File(mContext.getDir("lib", Context.MODE_PRIVATE).getAbsoluteFile(), com.yunbao.common.Constants.DOWNLOAD_Agora_SO + File.separator + Build.CPU_ABI);
config.mNativeLibPath = file.getAbsolutePath();
Log.i("downLoad", "config.mNativeLibPath 2 = " + config.mNativeLibPath);
}
Log.i("downLoad", "声网 SO Path 3 = " + config.mNativeLibPath);
}*/
// 创建并初始化 RtcEngine
mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);

View File

@ -13,6 +13,7 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
@ -33,6 +34,7 @@ import com.blankj.utilcode.util.GsonUtils;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import com.faceunity.wrapper.faceunity;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BasePopupView;
import com.lxj.xpopup.interfaces.XPopupCallback;
@ -216,6 +218,13 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl
super.main();
Bus.getOn(this);
Intent intent = getIntent();
if(CommonAppConfig.IS_GOOGLE_PLAY == 0){
// 美颜SO设置
File file_FaceUnity = new File(mContext.getDir("lib", Context.MODE_PRIVATE).getAbsoluteFile(), com.yunbao.common.Constants.DOWNLOAD_FaceUnity_SO + File.separator + Build.CPU_ABI);
faceunity.LoadConfig.loadLibrary(file_FaceUnity.getAbsolutePath());
Log.i("downLoad", "美颜SO Path = " + file_FaceUnity.getAbsolutePath());
}
initFaceManager();
leave_img = findViewById(R.id.leave_img);
mLiveSDK = intent.getIntExtra(Constants.LIVE_SDK, Constants.LIVE_SDK_KSY);

View File

@ -33,7 +33,8 @@ android {
ndk {
// abiFilters "armeabi-v7a", "arm64-v8a","x86","x86_64"
if (rootProject.ext.manifestPlaceholders.isGooglePlay == 0) {
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
// abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
abiFilters "armeabi-v7a", "arm64-v8a"
} else {
abiFilters "armeabi-v7a", "arm64-v8a"
}

View File

@ -210,6 +210,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
private View floatWarOrder;//战令浮窗
private List<AnchorStartLiveBean> startListNotifyList = new ArrayList<>();
private String[] libNameList = new String[]{"agora-core", "agora-ffmpeg", "agora-fdkaac", "agora-soundtouch","agora-rtc-sdk"};
@Override
@ -239,6 +240,14 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
);
ToastUtil.showDebug("打包时间:"+CommonAppConfig.BUILD_TIME+"\n系统语言:"+IMLoginManager.get(CommonAppContext.sInstance).getLocaleLanguage());
/* File file = new File(getDir("lib", Context.MODE_PRIVATE).getAbsoluteFile(), com.yunbao.common.Constants.DOWNLOAD_Agora_SO + File.separator + Build.CPU_ABI);
String path = file.getAbsolutePath();
for (String s : libNameList) {
Log.i("downLoad", "System.load 加载so path = " + path + File.separator + "lib" + s + ".so");
System.load(path + File.separator + "lib" + s + ".so");
}*/
//初始化声网
SWAuManager.get().initRtcEngine(this);
ActivityCompat.postponeEnterTransition(this);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB