디버그 모드에서 proguard를 사용할 수 있습니까?
내 안드로이드 앱에서 proguard를 켜고 일부 기능을 테스트하고 싶습니다.
나는 그것을 정말로 "디버그"할 필요가 없지만, 내가 eclipse에서 실행을 눌렀을 때 proguard가 실행되기를 원합니다. 매번 바이너리를 내보내고 (즉, 릴리스 모드에서) apk로 저장하고 테스트 할 장치로 가져오고 싶지 않습니다.
이런 식으로 proguard를 실행하는 방법이 있습니까?
최신 정보:
Eclipse를 사용 하지 않는 경우 가능한 것 같습니다 . 질문 제목에는 Eclipse가 포함되어 있지 않으므로이 질문에 대한 여러 정답이 있습니다.
이전 답변 :
http://developer.android.com/tools/help/proguard.html
ProGuard는 릴리스 모드에서 애플리케이션을 빌드 할 때만 실행되므로 디버그 모드에서 애플리케이션을 빌드 할 때 난독 화 된 코드를 처리 할 필요가 없습니다.
ant 릴리스를 실행하거나 Eclipse에서 내보내기 마법사를 사용하여 릴리스 모드 에서 애플리케이션을 빌드 할 때 빌드 시스템은 proguard.config
특성이 설정 되었는지 자동으로 확인합니다 . 그렇다면 ProGuard는 모든 것을 .apk 파일 로 패키징하기 전에 응용 프로그램의 바이트 코드를 자동으로 처리 합니다. 디버그 모드에서 빌드하면 디버깅이 더 번거롭기 때문에 ProGuard가 호출되지 않습니다.
업데이트 : 13-3-2016
새로운 gradle 빌드 시스템으로 가능합니다. 당신은 설정해야합니다 minifyEnabled
으로 true
당신의 build.gradle의 파일. 일반적으로 릴리스 모드 에서 프로 가드를 실행 합니다. 리소스 축소와 같은 다른 옵션을 사용할 수 있습니다. http://tools.android.com/tech-docs/new-build-system에서 유용한 정보를 찾을 수 있습니다.
또한보세요 @
http://developer.android.com/tools/building/configuring-gradle.html
android {
...
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
전체 빌드 프로세스를 더 쉽게 만들고 싶다면 gradle 및 Android Studio IDE로 전환해야합니다.
그런 다음 build.gradle 파일에 다음을 쉽게 추가하여 ProGuard를 실행할 수 있습니다.
android {
buildTypes {
release {
}
debug {
minifyEnabled true
proguardFile 'proguard-android.txt'
zipAlignEnabled true
}
}
}
그러면 프로젝트의 루트 폴더에 넣어야하는 "proguard-android.txt"파일로 구성된 디버그 빌드에서 ProGuard가 실행됩니다. 또한 APK가 zip으로 정렬되고 있습니다 (그렇게하지 않으려면 "zipAlignEnabled true"를 제거하십시오). 릴리스 빌드에 대해 동일한 작업을 수행하려면 "release"아래에 해당 세 줄을 추가하면됩니다.
약간의 주제에서 벗어남 : 종속성 추가, APK 서명 또는 빌드 프로세스에 다른 사용자 지정 작업 추가와 같은 작업도 gradle을 사용하면 훨씬 복잡하지 않습니다. 또한 Android Studio IDE를 통해 APK를 빌드 할 수있을뿐만 아니라 명령 줄의 간단한 명령 (예 : ./gradlew assembleDebug)을 통해서도 APK를 빌드 할 수 있습니다. 따라서 팀에서 작업하는 경우 새 구성원을위한 설정 프로세스는 "./gradlew assembleDebug"거리에 있습니다. IDE 구성이 전혀 필요하지 않습니다. 모든 종속성을 포함한 프로젝트 가져 오기는 원 클릭 프로세스만큼 간단합니다.
편집 : Gradle Android Build Tools 버전 0.14.0부터 속성 이름이 변경되었습니다 ( http://tools.android.com/tech-docs/new-build-system ).
- BuildType.runProguard-> minifyEnabled
- BuildType.zipAlign-> zipAlignEnabled
I've updated the above code.
Regarding custom Ant builds (and based on Victor's answer), adding the following to my build.xml file works for me:
<target name="-debug-obfuscation-check">
<!-- enable proguard even in debug mode -->
<property name="proguard.enabled" value="true"/>
<!-- Secondary dx input (jar files) is empty since all the jar files will be in the obfuscated jar -->
<path id="out.dex.jar.input.ref" />
</target>
Notice that I had to override (actually pre-set) the out.dex.jar.input.ref; otherwise, the later running of dx will attempt to merge non-disjoint jars and throw the DexException: Multiple dex files define Xxx.
It is possible if you build with Ant. See Android custom build using Ant on how to build your project with ant. Then, simply override in the project's build.xml the target "-debug-obfuscation-check" and set proguard.enabled to true:
<target name="-debug-obfuscation-check">
<!-- proguard is never enabled in debug mode -->
<property name="proguard.enabled" value="true"/>
</target>
With Android Studio you can use -dontobfuscate
option in your Proguard rules file and debugger will work fine. I'm not sure if it works with Eclipe as well.
참고URL : https://stackoverflow.com/questions/16559723/is-it-possible-to-use-proguard-in-debug-mode
'program story' 카테고리의 다른 글
PHPUnit-구성 파일 사용시 '실행 된 테스트 없음' (0) | 2020.10.25 |
---|---|
서명 된 응용 프로그램을 설치할 때 Win8에서 스마트 화면을 전달하는 방법은 무엇입니까? (0) | 2020.10.24 |
node.js를 사용하여 파일 이름 바꾸기 (0) | 2020.10.24 |
nginx : [emerg] "server"지시문은 여기에서 허용되지 않습니다. (0) | 2020.10.24 |
C #의 비트 필드 (0) | 2020.10.24 |