2016-08-23 10 views
4

私はxamarinアプリケーションを開発中です。私はアンドロイドのプロパティで "ProGuardのを" 有効にすると、アプリケーションを構築しながら、私は次のエラーを取得しています:Xamarin Android ProGuardを有効にする

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

開発環境:

"java.exe" exited with code1. 

enter image description here ProGuardののcfgファイルには、以下があります
Visual Studio 2015
Xamarin 4.0.4.4

+0

エラー?ランタイム?コンパイル時間?あなたのproguardファイルも追加してください。 – AndroidRuntimeException

+2

診断ビルドの完全な出力を質問に追加できますか?エラーには、それにつながるトレースが必要です。 –

+2

私が見た最も一般的な問題は、JDKのバージョン(診断に設定すると出力に表示される)とヒープサイズが不十分であることです。 bugtrackerにはこれに関するいくつかの未解決のバグがまだあります:https://bugzilla.xamarin.com/show_bug.cgi?id=35255 – silencedmessage

答えて

12

ProGuardを有効にしたときに同じ問題が発生しました。 this linkのアドバイスに従うことで、私はプロガードを手動でアップデートすることで問題を解決しました。これらのステップはかなり簡単に実行でき、問題を解決しました。これがあなたを助けることを願ってください。

  1. から入手可能なProGuard zipファイルをダウンロードしてください。執筆時点でProGuardの最新バージョンは5.3でした。
  2. ProGuardにはセットアッププログラムがないため、ファイルを解凍してproguardフォルダ構造を次の手順で指定された場所にコピーする必要があります。
  3. SDKマネージャを起動し、メニューオプションの左上にあるパスをメモします。私の場合、これはC:\ Users \ Sahar \ AppData \ Local \ Android \ android-sdkでした。 proguardフォルダは、このパスのtoolsフォルダにあります(私の場合、C:\ Users \ Sahar \ AppData \ Local \ Android \ android-sdk \ tools \ proguardです)。
  4. SDKにアクセスしている開発環境をすべて閉じ、proguardフォルダの名前をproguard.oldに変更します。
  5. 新しいバージョンのproguardフォルダをtoolsフォルダにコピーし、必要に応じてproguardに名前を変更します(私の場合、コピーしたフォルダはproguard5.3から名前が変更されました)。
  6. 最後に、設定ファイルをproguard.oldフォルダから新しいフォルダにコピーします。私の場合、これらは: proguard-android.txt、proguard-android-optimize.txtおよびproguard-project.txtでした。
  7. ProGuardを有効にしてプロジェクトをきれいにして再構築します。
+0

最もよいことは関連する詳細を投稿することです**と**はページへのリンクを含みます。そうでなければ、リンクが死んでしまうと、残念なことにあなたの答えの有効性も失われます。 – gravity

+1

@重力アドバイスをいただきありがとうございます。私はできることを手助けし始めました。私は私の答えを更新します。 –

+0

優れた編集。今、素晴らしい詳細があり、結果としてより良い答えが得られます。 – gravity

1

ProguardがアプリからGoogle Playサービスライブラリを削除していたときに問題が発生しました。

私は、このフォルダに proguard-android.txtファイルにテキストの次の行を追加する必要がありました

:あなたが持っている場合は

/(Path to your Android SDK Folder)/tools/proguard

-keep public class com.google.android.gms.* { public *; } 
-dontwarn com.google.android.gms.** 

完全ProGuardの-android.txtファイル

-keep public class com.google.android.gms.* { public *; } 
-dontwarn com.google.android.gms.** 

# This is a configuration file for ProGuard. 
# http://proguard.sourceforge.net/index.html#manual/usage.html 

-dontusemixedcaseclassnames 
-dontskipnonpubliclibraryclasses 
-verbose 

# Optimization is turned off by default. Dex does not like code run 
# through the ProGuard optimize and preverify steps (and performs some 
# of these optimizations on its own). 
-dontoptimize 
-dontpreverify 
# Note that if you want to enable optimization, you cannot just 
# include optimization flags in your own project configuration file; 
# instead you will need to point to the 
# "proguard-android-optimize.txt" file instead of this one from your 
# project.properties file. 

-keepattributes *Annotation* 
-keep public class com.google.vending.licensing.ILicensingService 
-keep public class com.android.vending.licensing.ILicensingService 

# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native 
-keepclasseswithmembernames class * { 
    native <methods>; 
} 

# keep setters in Views so that animations can still work. 
# see http://proguard.sourceforge.net/manual/examples.html#beans 
-keepclassmembers public class * extends android.view.View { 
    void set*(***); 
    *** get*(); 
} 

# We want to keep methods in Activity that could be used in the XML attribute onClick 
-keepclassmembers class * extends android.app.Activity { 
    public void *(android.view.View); 
} 

# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations 
-keepclassmembers enum * { 
    public static **[] values(); 
    public static ** valueOf(java.lang.String); 
} 

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

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

# The support library contains references to newer platform versions. 
# Don't warn about those in case this app is linking against an older 
# platform version. We know about them, and they are safe. 
-dontwarn android.support.** 

# Understand the @Keep support annotation. 
-keep class android.support.annotation.Keep 

-keep @android.support.annotation.Keep class * {*;} 

-keepclasseswithmembers class * { 
    @android.support.annotation.Keep <methods>; 
} 

-keepclasseswithmembers class * { 
    @android.support.annotation.Keep <fields>; 
} 

-keepclasseswithmembers class * { 
    @android.support.annotation.Keep <init>(...); 
} 
関連する問題