Android 代码混淆语法讲解及常用模板,flutter二维码识别

本文详细介绍了Android代码混淆的配置文件`proguard-rules.pro`的设置,包括各种混淆规则的解释和示例。同时,提到了在混淆过程中如何保留特定类和方法,以及如何处理第三方库的混淆问题。此外,还提及了Flutter的二维码识别功能,暗示了Android开发者可能需要关注的跨平台开发知识。
摘要由CSDN通过智能技术生成

至于它是

《Android学习笔记总结+最新移动架构视频+大厂安卓面试真题+项目实战源码讲义》

【docs.qq.com/doc/DSkNLaERkbnFoS0ZF】 完整内容开源分享

怎样指定 proguard-rules.pro 文件来配置代码混淆的,我们可以在看一下 build.gradle 是怎样配置的

// 对正式版的进行混淆配置

buildTypes {

release {

minifyEnabled false

proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’

}

}

了解了在哪里配置混淆代码之后,下面我们一起来看一下怎样混淆代码

首先,我们先来看一下 Android 默认的代码混淆配置,在 {SDKHOME}\tools\proguard 目录下,有 proguard-android.txt 文件,该文件就是默认的代码混淆配置

This is a configuration file for ProGuard.

http://proguard.sourceforge.net/index.html#manual/usage.html

-dontusemixedcaseclassnames

-dontskipnonpubliclibraryclasses

-verbose

Optimization is turned off by default. Dex does not like code run

through the ProGuard optimize and preverify steps (and performs some

of these optimizations on its own).

-dontoptimize

-dontpreverify

Note that if you want to enable optimization, you cannot just

include optimization flags in your own project configuration file;

instead you will need to point to the

“proguard-android-optimize.txt” file instead of this one from your

project.properties file.

-keepattributes Annotation

-keep public class com.google.vending.licensing.ILicensingService

-keep public class com.android.vending.licensing.ILicensingService

For native methods, see http://proguard.sourceforge.net/manual/examples.html#native

-keepclasseswithmembernames class * {

native ;

}

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);

}

For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations

-keepclassmembers enum * {

public static **[] values();

public static ** valueOf(java.lang.String);

}

-keepclassmembers class * implements android.os.Parcelable {

public static final android.os.Parcelable$Creator CREATOR;

}

-keepclassmembers class *.R$ {

public static ;

}

The support library contains references to newer platform versions.

Don’t warn about those in case this app is linking against an older

platform version. We know about them, and they are safe.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在 Flutter 应用程序中实现二维码扫描,可以使用 `qr_code_scanner` 或 `barcode_scan` 插件。 `qr_code_scanner` 插件提供了一个 `QRView` widget,可以轻松地将二维码扫描器集成到应用程序中。以下是一个简单的示例: 1. 添加 `qr_code_scanner` 插件到 `pubspec.yaml` 文件中: ``` dependencies: qr_code_scanner: ^0.4.3 ``` 2. 导入 `qr_code_scanner` 包: ``` import 'package:qr_code_scanner/qr_code_scanner.dart'; ``` 3. 创建一个 `QRViewController` 和一个 `QRView`: ``` QRViewController controller; final GlobalKey qrKey = GlobalKey(debugLabel: 'QR'); @override Widget build(BuildContext context) { return QRView( key: qrKey, onQRViewCreated: _onQRViewCreated, ); } void _onQRViewCreated(QRViewController controller) { this.controller = controller; controller.scannedDataStream.listen((scanData) { // 处理扫描到的二维码 }); } ``` 当用户扫描二维码时,`QRViewController` 会不断发送扫描数据到 `scannedDataStream`,可以在监听函数中处理这些数据。 如果想要更多的控制权,可以使用 `barcode_scan` 插件。这个插件提供了一个 `scan()` 方法,可以启动一个新的扫描器界面,并且可以自定义扫描器的外观和行为。以下是一个简单的示例: 1. 添加 `barcode_scan` 插件到 `pubspec.yaml` 文件中: ``` dependencies: barcode_scan: ^2.0.0 ``` 2. 导入 `barcode_scan` 包: ``` import 'package:barcode_scan/barcode_scan.dart'; ``` 3. 调用 `scan()` 方法并处理返回的数据: ``` Future<void> scan() async { String barcode = await BarcodeScanner.scan(); // 处理扫描到的二维码 } ``` 在调用 `scan()` 方法时,会启动一个新的扫描器界面,并等待用户扫描二维码。当用户扫描二维码后,会返回扫描到的数据。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值