当前位置: 首页 > news >正文

aab转apk

一、 android34升级:
1、升级到安卓34(蓝牙、图片)

再蓝牙广播的地方加入Context.RECEIVER_EXPORTED

2、废弃了 BluetoothAdapter#enable() 和 BluetoothAdapter#disable(),需要修改

// 以前的蓝牙操作BluetoothManager bluetoothManager = (BluetoothManager) this.getSystemService(Context.BLUETOOTH_SERVICE);BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();Log.i(TAG, "BluetoothAdapter isEnabled: " + bluetoothAdapter.isEnabled());if (!bluetoothAdapter.isEnabled()) {boolean enable = bluetoothAdapter.enable();Log.i(TAG, "BluetoothAdapter enable result: " + enable);
}
// 现在需要这样BluetoothManager bluetoothManager = (BluetoothManager) this.getSystemService(Context.BLUETOOTH_SERVICE);BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter();Log.i(TAG, "BluetoothAdapter isEnabled: " + bluetoothAdapter.isEnabled());if (!bluetoothAdapter.isEnabled()) {ActivityResultLauncher<Intent> register = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),new ActivityResultCallback<ActivityResult>() {@Overridepublic void onActivityResult(ActivityResult result) {if (result == null) {Log.i(TAG, "开启蓝牙失败:result 为 null");return;}int resultCode = result.getResultCode();if (resultCode != Activity.RESULT_OK) {Log.i(TAG, "开启蓝牙失败:resultCode 为 " + resultCode);return;}Log.i(TAG, "开启蓝牙成功:resultCode 为 " + resultCode);}});Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);register.launch(intent);
}

图片-头像-拍照:
androidmainfest 增加权限:      Manifest.permission.READ_MEDIA_IMAGES,
                        Manifest.permission.READ_MEDIA_VIDEO,
                        Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED,
                        

代码中动态请求:
                        Manifest.permission.READ_MEDIA_IMAGES,
                        Manifest.permission.READ_MEDIA_VIDEO,
                        Manifest.permission.READ_MEDIA_VISUAL_USER_SELECTED,

 

请求权限参考代码

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU&& (ContextCompat.checkSelfPermission(this, READ_MEDIA_IMAGES) == PERMISSION_GRANTED|| ContextCompat.checkSelfPermission(this, READ_MEDIA_VIDEO) == PERMISSION_GRANTED)) {// Android 13及以上完整照片和视频访问权限} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE &&ContextCompat.checkSelfPermission(this, READ_MEDIA_VISUAL_USER_SELECTED) == PERMISSION_GRANTED) {// Android 14及以上部分照片和视频访问权限} else if (ContextCompat.checkSelfPermission(this, READ_EXTERNAL_STORAGE) == PERMISSION_GRANTED) {// Android 12及以下完整本地读写访问权限} else {// 无本地读写访问权限}

                        


======================================================================================
打aab包:
1、将项目中的\app\src\main\assets中的bin文件夹全部移动到base_assets文件夹
2、打包aab:build->Android App Bundle->选择签名,得到aab的包

===============================================
直接AS运行到手机上测试的:
1、需要将base_assets中的\base_assets\src\main\assets的bin文件,拷贝到\app\src\main\assets
2、移除base_assets文件夹

================================================

将aab转换为apks
1、将aab的包拷贝到AAB_TO_APK文件夹(名称默认为app-release.aab),
2、点击click.bat,出来小黑屏,等待apks的生成 (如果无响应的,重新下载bundletool-all-1.18.1的版本、检查jdk的版本)

下载链接:https://github.com/google/bundletool/releases


3、得到出来aa.apks,解压获得apk的文件包
4、安装到手机测试功能

相关文章:

  • 【Linux系统】进程间信号(捕捉信号)
  • 6.11.各顶点间的最短路径问题-Floyd算法
  • Redis基本使用
  • Git 基本操作(二)
  • AimRT从入门到精通 - 01实现一个helloworld
  • FHQ Treap
  • AI作画提示词:Prompts工程技巧与最佳实践
  • MYSQL-设计表
  • 消息队列的作用
  • [Verilog]跨时钟域数据传输解决方案
  • 2025五一数学建模竞赛A题完整分析论文(共45页)(含模型、可运行代码、数据)
  • spring中的@PostConstruct注解详解
  • 支持向量机(SVM)详解
  • 报文三次握手对么٩(๑^o^๑)۶
  • 网络原理 - 13(HTTP/HTTPS - 4 - HTTPS)
  • 从数据到故事:用可视化工具讲好商业“话本“
  • 鼎讯信通 智能通信干扰设备:多频段多模态信号压制解决方案
  • PS插件生态深度解析与精品合集推荐
  • 姜老师MBTI人格分析课程2:ENFP
  • ppt设计美化公司_杰青_长江学者_优青_青年长江学者_万人计划青年拔尖人才答辩ppt模板
  • 品牌网站建设解决方案/seo短视频
  • 福田做网站/北京做网站公司哪家好
  • 专做民宿预定的网站/信息流广告素材网站
  • ui设计网站模板/如何进行关键词优化工作
  • 集团网站设计/推广代理登录页面
  • 网页游戏名字排行榜/seo关键词优化排名