2014-09-10 2 views
1

이클립스와 ACRA의 사용 및 ProGuard에서 대한 가이드가 : 나는 안드로이드 스튜디오 사용 내 경우 https://github.com/ACRA/acra/wiki/ProGuard안드로이드 ACRA 및 ACRA 웹 사이트에 ProGuard에서

와 나는 그러나 나는 ACRA를 추가해야합니다, 자바에 대한 전문가가 아니에요 내 애플 리케이션에 대한 지원. 방금 프로젝트를 편집했지만 안드로이드 스튜디오에서 ProGuard를 ACRA로 설정하는 방법을 모르겠습니다. 내 릴리스 앱인 ACRA가 작동하지 않습니다.

Eclipse 단계를 Android Studio 단계로 "변환"할 수 있습니까?

답변

3

기존 Eclipse 프로젝트가 있고 Android Studio에서 가져 오시겠습니까?

귀하의 build.gradle 같은 것을 보일 것 파일 (하나는 "응용 프로그램"폴더에있는) :

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 20 
    buildToolsVersion '20.0.0' 

    defaultConfig { 
     applicationId "com.yourapp" 
     minSdkVersion 14 
     targetSdkVersion 20 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      runProguard true//make this true 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile project(':library') 
    compile 'ch.acra:acra:4.5.0'//add this line here 
} 

하고 proguard-rules.pro을

하지 여기 경우는 솔루션입니다 :

# Add project specific ProGuard rules here. 
# By default, the flags in this file are appended to flags specified 
# in C:\Android\AndroidSDKBundle2014-03-21x64\sdk/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 *; 
} 


#ACRA specifics 
# Restore some Source file names and restore approximate line numbers in the stack traces, 
# otherwise the stack traces are pretty useless 
-keepattributes SourceFile,LineNumberTable 

# ACRA needs "annotations" so add this... 
# Note: This may already be defined in the default "proguard-android-optimize.txt" 
# file in the SDK. If it is, then you don't need to duplicate it. See your 
# "project.properties" file to get the path to the default "proguard-android-optimize.txt". 
-keepattributes *Annotation* 

# keep this class so that logging will show 'ACRA' and not a obfuscated name like 'a'. 
# Note: if you are removing log messages elsewhere in this file then this isn't necessary 
-keep class org.acra.ACRA { 
    *; 
} 

# keep this around for some enums that ACRA needs 
-keep class org.acra.ReportingInteractionMode { 
    *; 
} 

-keepnames class org.acra.sender.HttpSender$** { 
    *; 
} 

-keepnames class org.acra.ReportField { 
    *; 
} 

# keep this otherwise it is removed by ProGuard 
-keep public class org.acra.ErrorReporter { 
    public void addCustomData(java.lang.String,java.lang.String); 
    public void putCustomData(java.lang.String,java.lang.String); 
    public void removeCustomData(java.lang.String); 
} 

# keep this otherwise it is removed by ProGuard 
-keep public class org.acra.ErrorReporter { 
    public void handleSilentException(java.lang.Throwable); 
} 

나머지는 일식과 같습니다.

0

Android Studio 프로젝트에 proguard-rules.txt 파일이 있어야합니다. 이 파일에 몇 가지 지시문을 추가하여 ProGuard에 보존 할 내용을 알리고 ACRA 지침에서 ProGuard 지시문을 그립니다.

대부분 ACRA의 proguard-project.txt 내용을 프로젝트의 proguard-rules.txt 파일로 복사합니다.

당신은 ACRA 지침이 파일은 안드로이드 Studio의 파일과 다른 이클립스의 ProGuard에서의 구성 기본 파일 proguard-android-optimize.txt 될 것으로 예상 몇 가지 지침을 추가해야 할 수도 있습니다 android-studio\sdk\tools\proguard\proguard-android-optimize.txt

proguard-android-optimize.txt에서 예 지시자 :

-keepclasseswithmembernames class * { 
    native <methods>; 
} 

이것은 ProGuard에 원시 메소드가있는 모든 클래스를 유지하도록 지시합니다.

관련 문제