[This post is by Dan Galpin, an Android Developer Advocate specializing in games and comics. 게시물을 [이 만화책과 전문 게임에 의해 댄 Galpin 옹호 개발자, 안드로이드. — Tim Bray] - 팀 브레이의]
The Securing Android LVL Applications
blog post makes it clear that an Android developer should use an
obfuscation tool such as Proguard in order to help safeguard their
applications when using License Server.
보안 안드로이드 LVL 응용 프로그램 블로그 게시물은 라이센스 Server를 사용하는 경우 응용 프로그램을 보호하는 데 도움을 순서주기 위해 안드로이드 개발자가 Proguard와 같은 난독화 도구를 사용하여야 함을 분명히 한다.
Of course, this does present another question.
물론, 이것은 다른 질문을 제시 않습니다.
How should one integrate such a tool with the Android build process?
어떻게 해야 하나의 안드로이드 빌드 과정과 같은 도구를 통합해야합니까?
We're specifically going to detail integrating Proguard in this post.
우리는 특별히 이 게시물에 Proguard 사용하여 통합하는 것을 상세화 할것이다.
Before you Begin ( 당신이 시작하기 전에 )
You must be running the latest version of the Android SDK Tools (at least v7).
당신은 안드로이드 SDK를 도구의 최신 버전 (적어도 v7의)을 실행해야합니다.
The
new Ant build rules file included with v7 contains hooks to support
user-created pre and post compile steps in order to make it easier to
integrate tools such as Proguard into an Android build.
새로운 Ant 는 규칙이 v7의 포함 파일이 들어 사용자가 미리 만들어 지원하고 게시 순서 쉽게 안드로이드에 Proguard 같은 도구를 통합 구축하기 위해 단계를 컴파일 후크 구축할 수 있습니다.
It also integrates a single rules file for building against all versions of the Android SDK.
그것은 또한 안드로이드 SDK의 모든 버전에 대한 구축을위한 하나의 규칙 파일을 통합합니다.
Adding an Optimization Step to build.xml ( 최적화 단계 build.xml 추가하기 )
First, you'll have to get Proguard if you don't yet have it.
먼저, 아직 Proguard 가 없는 경우, 당신을 이것을 구해야 합니다.
If you've been using Eclipse to do your development, you'll have to switch to using the command line.
만약 당신이 개발에서 이클립스를 사용하고 있다면, 당신은 명령줄을 사용하여 전환해야합니다.
Android builds are done using Apache Ant.
안드로이드 빌드는 Apache Ant 를 사용하여 완료 됩니다.
A version of Ant ships along with Eclipse, but I recommend installing your own version.
이클립스와 함께 배포된 Ant 버전도 좋지만, 자신의 버전을 설치하는 것을 권장합니다.
(역주 : 이클립스에 이미 Ant가 들어가 있어서 이것을 사용해도 된다는 것입니다. )
The Android SDK can build you a starter build.xml file.
안드로이드 SDK는 build.xml 파일를 생성하는 것으로 시작할 수 있습니다.
Here is how it's done:
여기 다하는 방식입니다 :
android update project --path ./MyAndroidAppProject
If all works well, you'll have a shiny new build.xml file sitting in your path.
모두가 잘 작동하면, 당신은 당신의 경로에 앉아 반짝 이는 새 build.xml 파일을 가지고 있습니다.
Let's try doing a build.
빌드를 시도해 봅시다.
ant release
You should end up with an unsigned release build.
당신은 서명되지 않은 릴리스 빌드를 끝까지해야합니다.
The command-line tools can also sign your build for you.
명령줄 도구는 또한 당신을 위해 사인한 빌드를 할 수 있습니다.
You'll notice that the android tool created a local.properties file in your directory.
당신은 안드로이드 도구는 디렉터리에 local.properties 파일을 만든 것을 알 수 있습니다.
It will contain the sdk.dir property.
그것은 sdk.dir 속성을 포함합니다.
You can have it make you a signed build by adding the location of your keystore and alias to this file.
당신은 당신이 파일에 keystore 및 별칭의 위치를 추가하여 빌드 서명을 만들 수 있습니다.
key.store=/Path/to/my/keystore/MyKeystore.ks key.alias=myalias
So, now you have a signed build from the command line, but still no obfuscated build.
그래서, 이제 사인한 빌드는 하였지만, 아직 빌드 난독화 빌드는 아닙니다.
To make things easy, you're going to want to get two helper files: add-proguard-release.xml and procfg.txt .
쉽게 하기 위해서, 원한다면 add-proguard-release.xml 과 procfg.txt 2개이 헬퍼 파일을 이용하여 진행할 수 있습니다.
Copy these files into your root directory (where the build.xml file sits).
귀하의 루트 디렉토리에 이러한 파일 (build.xml 파일이 어디에 앉고) 복사합니다.
To
add Proguard to your build, you first need to edit your local
properties file to add the location of the directory that Proguard is
installed in:
빌드에 Proguard를 추가하려면, 먼저 해당 지역의 특성 Proguard가에 설치되어있는 디렉토리의 위치를 추가할 파일을 편집해야합니다 :
proguard.dir=/Directory/Proguard/Is/Installed/In
Finally... you need to add our script to your build file and have it override a few targets.
마지막으로 ... 당신이 빌드 파일에 대한 우리의 스크립트를 추가하고 몇 가지 목표를 재정의가 필요합니다.
To do this, we use the XML “entity” construct.
이렇게하려면, 우리는 XML을 "엔티티"를 구성 사용합니다.
At the top of your build.xml file, add an entity that references our script file:
당신의 build.xml 파일의 맨 위에 참조하는 우리의 스크립트 파일 엔티티 추가 :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project [ <!ENTITY add-proguard-release SYSTEM "add-proguard-release.xml"> ]>
You're not done yet.
당신은 아직 안 끝났어.
Somewhere within the project tag add the reference to our entity to include our script.
어딘가 프로젝트 태그 내에 스크립트를 포함하는 우리의 엔티티에 대한 참조를 추가합니다.
<project name="MyProjectName" default="help"> &add-proguard-release;That's it! 바로 그거에요!
In many cases, calling 대부분의 경우, 전화
ant release
Will give you an obfuscated build.
당신에게 obfuscated 빌드 줄 것이다.
Now test and make sure that it hasn't broken anything.
지금 테스트 그리고 그것은 아무것도 깨진되지 않았는지 확인합니다.
But Wait, My App is Crashing Now ( 하지만 잠깐, 내 응용 프로그램은 이제 작동이 중지됩니다 )
Most
crashes happen because Proguard has obfuscated away something that your
application needs, such as a class that is referenced in the
AndroidManifest or within a layout, or perhaps something called from JNI
or reflection.
Proguard는 응용 프로그램이 AndroidManifest 또는 JNI를하거나
반성에서 호출 레이아웃, 또는 아마도 뭔가 내에서 참조된 클래스 등,이 필요하다고 무언가를 멀리 obfuscated 있기 때문에
대부분의 충돌이 일어날.
The
Proguard configuration provided here tries to avoid obfuscating most of
these cases, but it's still possible that in edge cases you'll end up
seeing something like a ClassNotFoundException
.
Proguard 구성이 여기에 제공된 가지 경우 이들의 대부분을 obfuscating 피하려고하는,하지만 뭔가를 같이 보는 가능 아직도 끝날 것 당신이 가지 경우 가장자리에 ClassNotFoundException
.
You can make edits to the procfg.txt file to keep classes that have been obfuscated away.
할 수 있습니다 당신은 떠나 obfuscated되어 수업을 유지하기 위해 procfg.txt 파일을 수정할 수 있습니다.
Adding:
추가 :
-keep public class * [my classname]
should help.
도움이됩니다.
For more information about how to prevent Proguard from obfuscating specific things, see the Proguard manual .
물건을 obfuscating 특정부터 Proguard을 방지하는 방법에 대한 자세한 내용은 더 볼 수 Proguard 매뉴얼을 .
Specifically, the keep section.
특히,이 섹션을 유지.
In the interest of security, try to keep as little of your application unobfuscated as possible.
보안의 관심에서, 가능 한한 unobfuscated 귀하의 신청서 조금을 유지하려고합니다.
The
standard settings provided in procfg.txt will be good for many
applications, and will catch many common cases, but they are by no means
comprehensive.
procfg.txt에서 제공하는 표준 설정이 많은 애플 리케이션을위한 좋은 것입니다 많은 일반적인 사례를 잡을 것입니다,하지만 그들은 포괄적인 방법으로하고 있습니다.
One
of the things that we've done is had Proguard create a bunch of output
files in the obf directory to help you debug these problems.
우리가 저지른 일들 중 하나는 Proguard 이러한 문제를 디버깅하는 당신을 도와 obf 디렉터리에 출력 파일들을 잔뜩 만들어 없었어요.
The mapping.txt file explains how your classes have been obfuscated.
mapping.txt 파일은 클래스가 obfuscated되어 방법을 설명합니다.
You'll
want to make sure to keep this around once you have submitted your
build to Market, as you'll need this to decipher your stack traces.
당신은 스택 추적하여 해독이 필요하므로,이 주위에 일단 시장에 빌드 제출한 유지되도록 할 것입니다.
Conclusion ( 결론 )
Tools such as Proguard make the binary of your application harder to understand, and make your application slightly smaller and more efficient at the same time, at the cost of making it slightly more challenging to debug problems in the field.
Proguard와 같은 도구는 더 응용 프로그램의 바이너리를 이해하고 응용 프로그램이 약간 더 효율적인 동시에 작게 만들 분야에서 디버그 문제가 더 많은 도전에 약간 그것을 만드는 비용. For many applications, the tradeoff is more than worthwhile. 많은 어플 리케이션의 경우, 효율이 줄어 가치 이상입니다.