【发布时间】:2017-04-10 07:22:58
【问题描述】:
我想隐藏aar 文件中的真实代码。我的库的 Gradle 文件如下所示。
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
}
我在运行此应用程序时遇到以下异常。
Warning:Exception while processing task java.io.FileNotFoundException: E:\MyProjects\TestApp\testLibrary\build\intermediates\proguard-rules\release\aapt_rules.txt (The system cannot find the path specified)
Error:Execution failed for task ':testLibrary:transformClassesAndResourcesWithProguardForRelease'.
> Job failed, see logs for details
如果我将minifyEnabled true 更改为minifyEnabled false,则此应用程序运行正常,但我可以从生成的arr 文件中看到Java 文件。
所以我想隐藏 Java 代码。
【问题讨论】:
-
我认为您实际上希望缩小项目。但是,偶数
aapt_rules.txt存在吗?不需要配置吗? -
@JeremyGrand 是的,我需要配置它。