Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

不会用,新版Android studio的根目录build.gradle就三行代码 #161

Open
huaxuanHan opened this issue Jul 11, 2024 · 4 comments
Open

Comments

@huaxuanHan
Copy link

新版Android studio的根目录build.gradle里面代码如下:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.application) apply false
}
就这个多

1、在根目录build.gradle中引入插件依赖。
buildscript {
repositories {
mavenCentral()
}
dependencies {
...
classpath 'com.github.megatronking.stringfog:gradle-plugin:5.2.0'
// 选用加解密算法库,默认实现了xor算法,也可以使用自己的加解密库。
classpath 'com.github.megatronking.stringfog:xor:5.0.0'
}
} 这些内容加在这里不对吧,可是我在别的文件里也没找到buildscript,这一步就不会用了

@pangli
Copy link

pangli commented Jul 31, 2024

新版Android studio的根目录build.gradle里面代码如下: // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { alias(libs.plugins.android.application) apply false } 就这个多

1、在根目录build.gradle中引入插件依赖。 buildscript { repositories { mavenCentral() } dependencies { ... classpath 'com.github.megatronking.stringfog:gradle-plugin:5.2.0' // 选用加解密算法库,默认实现了xor算法,也可以使用自己的加解密库。 classpath 'com.github.megatronking.stringfog:xor:5.0.0' } } 这些内容加在这里不对吧,可是我在别的文件里也没找到buildscript,这一步就不会用了

问题解决了吗?新版中怎么用?

@huaxuanHan
Copy link
Author

没有呢,不知道新版本咋用

@pangli
Copy link

pangli commented Aug 1, 2024

没有呢,不知道新版本咋用

我是这样用的

  1. libs.versions.toml 配置中添加
[versions]
stringfogPlugin = "5.2.0"
stringfogXor = "5.0.0"

[libraries]
stringfog-plugin = { module = "com.github.megatronking.stringfog:gradle-plugin", version.ref = "stringfogPlugin" }
stringfog-xor = { module = "com.github.megatronking.stringfog:xor", version.ref = "stringfogXor" }

[plugins]

  1. 在项目的build.gradle.kts配置中添加
buildscript {
    dependencies {
        classpath(libs.stringfog.plugin)
        classpath(libs.stringfog.xor)
    }
}
  1. 在模块的build.gradle.kts配置中添加
import com.github.megatronking.stringfog.plugin.StringFogExtension

plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.jetbrains.kotlin.android)
    id("stringfog")
}
apply(plugin = "stringfog")
configure<StringFogExtension> {
    // 加解密库的实现类路径,需和上面配置的加解密算法库一致。
    implementation = "com.github.megatronking.stringfog.xor.StringFogImpl"
    // 加密开关,默认开启。
    enable = true
    // 指定需加密的代码包路径,可配置多个,未指定将默认全部加密。
    fogPackages = arrayOf("com.hhhhh.uuyu")
    kg = com.github.megatronking.stringfog.plugin.kg.RandomKeyGenerator(16)
    // base64或者bytes
    mode = com.github.megatronking.stringfog.plugin.StringFogMode.bytes
}

dependencies {
    //字符串加密
    implementation(libs.stringfog.xor)
}

目前编译通过,反编译后看加解密生效

@huaxuanHan
Copy link
Author

感谢,等一下我试试

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants