gpt4 book ai didi

java - 如何使用Android Studio生成ProGuard混淆?

转载 作者:行者123 更新时间:2023-12-01 10:29:43 26 4
gpt4 key购买 nike

我必须通过在 Android studio 中启用 Pro Guard 混淆来保护我的应用程序。我已经搜索了如何应用它的过程,但没有得到任何明确的解决方案。当我尝试时,我总是收到错误。所以任何人都可以给我解决方案。

错误日志:-

Information:Gradle tasks [:app:assembleRelease]
:app:preBuild UP-TO-DATE
:app:preReleaseBuild UP-TO-DATE
:app:checkReleaseManifest
:app:preDebugBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2311Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42311Library UP-TO-DATE
:app:prepareReleaseDependencies
:app:compileReleaseAidl
:app:compileReleaseRenderscript
:app:generateReleaseBuildConfig
:app:generateReleaseAssets UP-TO-DATE
:app:mergeReleaseAssets
:app:generateReleaseResValues UP-TO-DATE
:app:generateReleaseResources
:app:mergeReleaseResources
:app:processReleaseManifest
:app:processReleaseResources
:app:generateReleaseSources
:app:processReleaseJavaRes UP-TO-DATE
:app:compileReleaseJavaWithJavac

Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

:app:compileReleaseNdk UP-TO-DATE
:app:compileReleaseSources
:app:proguardRelease
Exception while processing task
java.io.IOException: Can't read [D:\Android\Package_name\app\bin\classes] (No such file or directory)
at proguard.InputReader.readInput(InputReader.java:188)
at proguard.InputReader.readInput(InputReader.java:158)
at proguard.InputReader.readInput(InputReader.java:136)
at proguard.InputReader.execute(InputReader.java:66)
at proguard.ProGuard.readInput(ProGuard.java:218)
at proguard.ProGuard.execute(ProGuard.java:82)
at proguard.gradle.ProGuardTask.proguard(ProGuardTask.java:1074)
atcom.android.build.gradle.tasks.AndroidProGuardTask.doMinification(AndroidProGuardTask.java:139)
atcom.android.build.gradle.tasks.AndroidProGuardTask$1.run(AndroidProGuardTask.java:115)
at com.android.builder.tasks.Job.runTask(Job.java:48)
at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41)
at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:227)
at java.lang.Thread.run(Thread.java:745)
Error:java.io.IOException: No such file or directory
at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:50)
at proguard.InputReader.readInput(InputReader.java:184)
... 12 more
:app:dexRelease
:app:validateExternalOverrideSigning
:app:packageRelease FAILED
Error:Execution failed for task ':app:packageRelease'.

Unable to compute hash of D:\Android\Package_name\app\build\intermediates\classes-proguard\release\classes.jar Information:BUILD FAILED Information:Total time: 9.667 secs Information:2 errors Information:0 warnings Information:See complete output in console

构建渐变:-

apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'

defaultConfig {
applicationId "package_name"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.1"
}

dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release
{
minifyEnabled true
proguardFile 'D:/Android/Packagename/app/proguard-rules.pro'
}
debug
{
debuggable true
minifyEnabled true
proguardFile 'D:/Android/Packagename/app/proguard-rules.pro'
applicationIdSuffix ".debug"

}
}

packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.1'
}

proguard-rules.pro:-

-injars      bin/classes
-injars libs
-injars com.android.support:appcompat-v7:23.1.0
-injars com.android.support:design:23.1.1
-libraryjars /usr/local/java/android-sdk/platforms/android-22/android.jar

-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider

-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}

-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * implements android.os.Parcelable {
static android.os.Parcelable$Creator CREATOR;
}

-keepclassmembers class **.R$* {
public static <fields>;
}

-dontwarn android.support.**
-dontwarn com.github.**
-dontwarn com.squareup.picasso.**
-dontwarn com.etsy.android.grid.**
-dontwarn java.nio.file.Files
-dontwarn java.nio.file.Path
-dontwarn java.nio.file.OpenOption
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

最佳答案

请尝试更换

proguardFile 'D:/Android/Packagename/app/proguard-rules.pro' 

与:

proguardFile 'proguard-rules.pro'

关于java - 如何使用Android Studio生成ProGuard混淆?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35150026/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com