在android studio中找不到proguard-project.txt
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23149417/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
proguard-project.txt not found in android studio
提问by MCA Shah
I am new to Android and Android Studio.
我是 Android 和 Android Studio 的新手。
During my learning I came across the Google Play Services for Ads and all.
在我学习期间,我遇到了 Google Play 广告服务和所有服务。
I tried to enable proguard in my project but reading the below link proguard.
我试图在我的项目中启用 proguard,但阅读下面的链接proguard。
The problem is that I am not able to find proguard-project.txtor proguard.cfgin my project structure...
问题是我在我的项目结构中找不到proguard-project.txt或proguard.cfg...
Instead there is a proguard-rules.txtin my project structure...
相反,我的项目结构中有一个proguard-rules.txt......
How can I find these missing files and configure proguard in my project...
我怎样才能找到这些丢失的文件并在我的项目中配置 proguard...
Please help...
请帮助...
采纳答案by Scott Barta
Use the proguard-rules.txtfile instead. Proguard doesn't attach any special significance to the name of its rule input files; it uses whatever's set up in your build files, which for new projects created in recent versions of Android Studio, is:
请改用proguard-rules.txt文件。Proguard 对其规则输入文件的名称没有任何特殊意义;它使用您的构建文件中设置的任何内容,对于在最新版本的 Android Studio 中创建的新项目,它是:
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
The proguard-android.txtfile lives inside your SDK, and contains reasonable Android-wide defaults that all projects should use.
该proguard的-android.txt文件的生活你的SDK中,并包含合理的Android范围的默认值,所有的项目应该使用。
回答by Sami Eltamawy
I had the same problem when I started using Android Studio
我开始使用Android Studio时遇到了同样的问题
You can't see the ProGuard
files because you are previewing you project in a non Project file
mode. Which most probably will be Android
view mode.
您无法看到ProGuard
文件,因为您正在以非Project file
模式预览项目。其中最有可能是Android
查看模式。
You have to change the mode by clicking on the drop down list of the Android selection and select Project Files
to see all the files in the project as the following:
您必须通过单击 Android 选择的下拉列表来更改模式,然后选择Project Files
查看项目中的所有文件,如下所示:
Then you will be able to see the hidden files in the Android
project structure view mode.
然后您将能够在Android
项目结构视图模式中看到隐藏的文件。
And here is a good examplefor the ProGuard
这里是一个很好的例子为ProGuard
回答by star
You can find proguard-project.txtin
你可以在proguard-project.txt中找到
C:\Users\"USER"\AppData\Local\Android\android-studio\sdk\tools\proguard
"USER"
is the name in you will see when you click on c-drive \users \yourname
"USER"
是当您单击 c-drive \users \yourname 时将看到的名称
回答by Hantelmann Victor
the code posted previously must be corrected to the following according to your use:
之前发布的代码必须根据您的使用情况更正为以下内容:
buildTypes {
release {
minifyEnabled true //according to your use
// or
minifyEnabled false //according to your use
// runProguard false ** NOT USED ANYMORE, replaced by minifyEnabled
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
回答by Nagev
I couldn't find this proguard-rules.txt anywhere on my Windows machine with Android Studio. I did however find a LayoutExample\app\proguard-rules.pro file. This is probably because I had imported my project from Eclipse, so Android Studio didn't create one automatically. So what I did was:
我在装有 Android Studio 的 Windows 机器上的任何地方都找不到这个 proguard-rules.txt。然而,我确实找到了一个 LayoutExample\app\proguard-rules.pro 文件。这可能是因为我从 Eclipse 导入了我的项目,所以 Android Studio 没有自动创建一个。所以我所做的是:
1 - Copy the proguard-rules.pro from the example project to the same folder as build.gradle for my project (you can either search for this file on your machine or create an empty project)
1 - 将示例项目中的 proguard-rules.pro 复制到与我的项目的 build.gradle 相同的文件夹中(您可以在您的机器上搜索此文件或创建一个空项目)
2 - Edit the code in build.gradle to use this file instead of proguard-rules.txt, e.g.
2 - 编辑 build.gradle 中的代码以使用此文件而不是 proguard-rules.txt,例如
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
- Sync gradle, then Build > Build APK. Worked fine for me.
- 同步 gradle,然后 Build > Build APK。对我来说效果很好。
回答by zeeawan
proguard-rules.txtcan be found with terminal command on OS X (should be similar on windows as well)
proguard-rules.txt可以在 OS X 上使用终端命令找到(在 Windows 上也应该类似)
$ locate proguard-rules.txt
On my machine the output is:
在我的机器上,输出是:
/Applications/Android Studio.app/Contents/plugins/android/lib/templates/gradle-projects/AndroidWearModule/root/proguard-rules.txt.ftl
/Applications/Android Studio.app/Contents/plugins/android/lib/templates/gradle-projects/NewAndroidModule/root/proguard-rules.txt.ftl
/Applications/Android Studio.app/Contents/plugins/android/lib/templates/gradle-projects/NewAndroidTVModule/root/proguard-rules.txt.ftl
/Applications/Android Studio.app/Contents/plugins/android/lib/templates/gradle-projects/NewGlassModule/root/proguard-rules.txt.ftl
You can place this file by removing the extra extension beyond txt. Here is what it looks like so you can create your own and place in your android project.
您可以通过删除 txt 之外的额外扩展名来放置此文件。这是它的外观,因此您可以创建自己的项目并将其放置在您的 android 项目中。
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdkDir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
回答by monkey from Tanzania
I had the same problem after updating android studio , I couldn't import my project to new version. change in the gradle build file.
更新 android studio 后我遇到了同样的问题,我无法将我的项目导入到新版本。gradle 构建文件中的更改。
buildTypes {
release {
minifyEnabled false *//change to this not runProguard false*
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}