StringFog
StringFog copied to clipboard
使用最新版Android Studio和gradle 8.7在Kotlin DSL如何添加classpath?
buildscript {
repositories {
mavenCentral()
}
dependencies {
...
classpath 'com.github.megatronking.stringfog:gradle-plugin:5.2.0'
// 选用加解密算法库,默认实现了xor算法,也可以使用自己的加解密库。
classpath 'com.github.megatronking.stringfog:xor:5.0.0'
}
}
//classpath 部分如何在 Kotlin DSL 中使用 plugins { } 添加
plugins {
}
buildscript {
repositories {
mavenCentral() // 添加 Maven Central 仓库
}
dependencies {
classpath("com.github.megatronking.stringfog:gradle-plugin:5.2.0") // StringFog 插件依赖
classpath("com.github.megatronking.stringfog:xor:5.0.0") // StringFog 默认的 XOR 加解密算法库依赖
}
}
上面直接粘到project的build.gradle.kts,下面的在app的build.gradle.kts
plugins {
id("stringfog")
}
apply(plugin = "stringfog")
configure<StringFogExtension> {
// 必要:加解密库的实现类路径,需和上面配置的加解密算法库一致。
implementation = "com.github.megatronking.stringfog.xor.StringFogImpl"
// 可选:加密开关,默认开启。
enable = true
// 可选:指定需加密的代码包路径,可配置多个,未指定将默认全部加密。
// fogPackages = arrayOf("com.xxx.xxx")
kg = com.github.megatronking.stringfog.plugin.kg.RandomKeyGenerator()
// base64或者bytes
mode = com.github.megatronking.stringfog.plugin.StringFogMode.bytes
}
////还有这个
implementation("com.github.megatronking.stringfog:xor:5.0.0") // 引入 XOR 加密库
see #161
buildscript { repositories { mavenCentral() // 添加 Maven Central 仓库 } dependencies { classpath("com.github.megatronking.stringfog:gradle-plugin:5.2.0") // StringFog 插件依赖 classpath("com.github.megatronking.stringfog:xor:5.0.0") // StringFog 默认的 XOR 加解密算法库依赖 } }上面直接粘到project的build.gradle.kts,下面的在app的build.gradle.kts
plugins { id("stringfog") } apply(plugin = "stringfog") configure<StringFogExtension> { // 必要:加解密库的实现类路径,需和上面配置的加解密算法库一致。 implementation = "com.github.megatronking.stringfog.xor.StringFogImpl" // 可选:加密开关,默认开启。 enable = true // 可选:指定需加密的代码包路径,可配置多个,未指定将默认全部加密。 // fogPackages = arrayOf("com.xxx.xxx") kg = com.github.megatronking.stringfog.plugin.kg.RandomKeyGenerator() // base64或者bytes mode = com.github.megatronking.stringfog.plugin.StringFogMode.bytes } ////还有这个 implementation("com.github.megatronking.stringfog:xor:5.0.0") // 引入 XOR 加密库
好的
@pangli 加上 id("stringfog") 编译通不过
@pangli 加上 id("stringfog") 编译通不过
你是不是没写对,我这边是正常的
@pangli 加上 id("stringfog") 编译通不过
貌似不需要加,按上面那个说的做,除了这个不加我的就可以了 我的配置如下根目录 build.gradle.kts
plugins {
id("com.android.application") version "8.6.1" apply false
id("org.jetbrains.kotlin.jvm") version "2.1.0" apply false // 使用你需要的 Kotlin 版本
id("com.google.devtools.ksp") version "2.1.21-2.0.1" apply false
}
buildscript {
repositories {
mavenCentral()
google()
gradlePluginPortal()
}
dependencies {
classpath("com.github.megatronking.stringfog:gradle-plugin:5.2.0") // StringFog 插件依赖
classpath("com.github.megatronking.stringfog:xor:5.0.0") // StringFog 默认的 XOR 加解密算法库依赖
}
}
app build.gradle.kts
import com.github.megatronking.stringfog.plugin.StringFogExtension
plugins {
id("com.android.application")
id("com.google.devtools.ksp") //version "2.1.21-2.0.1"
}
//apply<AutoProxyPlugin>()
apply(plugin = "stringfog")
configure<StringFogExtension> {
// 必要:加解密库的实现类路径,需和上面配置的加解密算法库一致。
implementation = "com.github.megatronking.stringfog.xor.StringFogImpl"
// 可选:加密开关,默认开启。
// enable = true
// 可选:指定需加密的代码包路径,可配置多个,未指定将默认全部加密。
// fogPackages = arrayOf("com.xxx.xxx")
kg = com.github.megatronking.stringfog.plugin.kg.RandomKeyGenerator()
// base64或者bytes
mode = com.github.megatronking.stringfog.plugin.StringFogMode.bytes
}
android {
namespace = "com.xxx"
compileSdk = 35
defaultConfig {
applicationId = "com.xxx"
minSdk = 24
targetSdk = 34
versionCode = 39
versionName = "3.9"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
dataBinding {
enable = true
}
signingConfigs {
create("customDebug") {
storeFile = file("D:\\document\\xxx.jks")
keyAlias = "xxx"
keyPassword = "x"xx
storePassword = "x"xx
}
}
sourceSets {
named("main") {
// getByName("main") {
java.srcDirs("build/generated/ksp/main/java")
}
}
buildTypes {
getByName("debug") {
signingConfig = signingConfigs.getByName("customDebug")
}
getByName("release") {
signingConfig = signingConfigs.getByName("customDebug")
}
release {
//启用代码压缩,混淆,优化
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
)
}
debug {
//启用代码压缩,混淆,优化
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
externalNativeBuild {
cmake {
path = file("src/main/cpp/CMakeLists.txt")
version = "3.22.1"
}
}
buildFeatures {
viewBinding = true
// buildConfig = true
}
flavorDimensions += listOf()
}
dependencies {
// 选用加解密算法库,默认实现了xor算法,也可以使用自己的加解密库。
implementation ("com.github.megatronking.stringfog:xor:5.0.0")
}