2011-12-07 21 views
1

私のプロジェクトをAPKにパックし、ProGuardで難読化しようとしています。ここで ProGuard with maven-android-plugin

は私のポンポンです:

<?xml version="1.0" encoding="UTF-8"?> 
    <project xmlns="http://maven.apache.org/POM/4.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 

    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.skayred</groupId> 
    <artifactId>skayred</artifactId> 
    <version>1.26</version> 
    <packaging>apk</packaging> 
    <name>skayred</name> 

<properties> 
    <environment>development</environment> 
</properties> 

<dependencies> 

    <dependency> 
     <groupId>android</groupId> 
     <artifactId>android</artifactId> 
     <version>2.2_r3</version> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>com.google.android.maps</groupId> 
     <artifactId>maps</artifactId> 
     <version>8_r2</version> 
     <scope>provided</scope> 
    </dependency> 

    <dependency> 
     <groupId>com.google.http-client</groupId> 
     <artifactId>google-http-client</artifactId> 
     <version>1.6.0-beta</version> 
     <exclusions> 

      <exclusion> 
       <groupId>xpp3</groupId> 
       <artifactId>xpp3</artifactId> 
      </exclusion> 

      <exclusion> 
       <groupId>com.google.protobuf</groupId> 
       <artifactId>protobuf-java</artifactId> 
      </exclusion> 

      <exclusion> 
       <groupId>org.codehaus.jackson</groupId> 
       <artifactId>jackson-core-asl</artifactId> 
      </exclusion> 

      <exclusion> 
       <groupId>junit</groupId> 
       <artifactId>junit</artifactId> 
      </exclusion> 

      <exclusion> 
       <groupId>commons-codec</groupId> 
       <artifactId>commons-codec</artifactId> 
      </exclusion> 

      <exclusion> 
       <groupId>commons-logging</groupId> 
       <artifactId>commons-logging</artifactId> 
      </exclusion> 

      <exclusion> 
       <groupId>org.apache.httpcomponents</groupId> 
       <artifactId>httpclient</artifactId> 
      </exclusion> 

      <exclusion> 
       <groupId>org.apache.httpcomponents</groupId> 
       <artifactId>httpcore</artifactId> 
      </exclusion> 

      <exclusion> 
       <groupId>com.google.code.findbugs</groupId> 
       <artifactId>jsr305</artifactId> 
      </exclusion> 

     </exclusions> 
    </dependency> 

    <dependency> 
     <groupId>com.google.http-client</groupId> 
     <artifactId>google-http-client-extensions-android2</artifactId> 
     <version>1.6.0-beta</version> 
     <exclusions> 
      <exclusion> 
       <groupId>com.google.android</groupId> 
       <artifactId>android</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 

    <dependency> 
     <groupId>com.google.guava</groupId> 
     <artifactId>guava</artifactId> 
     <version>10.0.1</version> 

     <exclusions> 
      <exclusion> 
       <groupId>com.google.code.findbugs</groupId> 
       <artifactId>jsr305</artifactId> 
      </exclusion> 
     </exclusions> 

    </dependency> 

    <dependency> 
     <groupId>com.skyhookwireless.wps</groupId> 
     <artifactId>skyhookwireless-wps</artifactId> 
     <version>4.2.0.14</version> 
     <scope>compile</scope> 
    </dependency> 

    <dependency> 
     <groupId>com.bugsense.trace</groupId> 
     <artifactId>bugsense-trace</artifactId> 
     <version>1.1.2</version> 
     <scope>compile</scope> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-jarsigner-plugin</artifactId> 
     <version>1.2</version> 

     <exclusions> 
      <exclusion> 
       <groupId>junit</groupId> 
       <artifactId>junit</artifactId> 
      </exclusion> 
     </exclusions> 

    </dependency> 

</dependencies> 

<build> 
    <finalName>${project.artifactId}</finalName> 

    <resources> 
     <!-- a pair definition for resource filtering of xml files only (not binary files since they get mangled --> 
     <resource> 
      <directory>${project.basedir}/res</directory> 
      <filtering>true</filtering> 
      <targetPath>${project.build.directory}/filtered-res</targetPath> 
      <includes> 
       <include>**/*.xml</include> 
      </includes> 
     </resource> 
     <resource> 
      <directory>${project.basedir}/res</directory> 
      <filtering>false</filtering> 
      <targetPath>${project.build.directory}/filtered-res</targetPath> 
      <excludes> 
       <exclude>**/*.xml</exclude> 
      </excludes> 
     </resource> 
    </resources> 

    <plugins> 
     <plugin> 
      <artifactId>maven-resources-plugin</artifactId> 
      <executions> 
       <execution> 
        <phase>initialize</phase> 
        <goals> 
         <goal>resources</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
     <plugin> 
      <groupId>com.jayway.maven.plugins.android.generation2</groupId> 
      <artifactId>android-maven-plugin</artifactId> 
      <version>3.0.0</version> 
      <extensions>true</extensions> 
      <configuration> 
       <resourceDirectory>${project.build.directory}/filtered-res</resourceDirectory> 
       <manifest> 
        <debuggable>true</debuggable> 
       </manifest> 
       <dex> 
        <jvmArguments> 
         <jvmArgument>-Xms256m</jvmArgument> 
         <jvmArgument>-Xmx512m</jvmArgument> 
        </jvmArguments> 
       </dex> 
       <sdk> 
        <platform>8</platform> 
       </sdk> 
      </configuration> 
      <executions> 
       <execution> 
        <id>manifestUpdate</id> 
        <phase>process-resources</phase> 
        <goals> 
         <goal>manifest-update</goal> 
        </goals> 
       </execution> 
       <execution> 
        <id>alignApk</id> 
        <phase>package</phase> 
        <goals> 
         <goal>zipalign</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 

</build> 

<profiles> 
    <profile> 
     <id>development</id> 
     <!-- using this since activeByDefault does not work well with multiple profiles --> 
     <activation> 
      <property> 
       <name>environment</name> 
       <value>!production</value> 
      </property> 
     </activation> 
     <properties> 
      <deployment.host>http://192.168.192.15:5000</deployment.host> 
     </properties> 
    </profile> 
    <profile> 
     <id>production</id> 

     <properties> 
      <deployment.host>https://somehost.com</deployment.host> 
     </properties> 
    </profile> 
    <profile> 
     <id>release</id> 
     <properties> 
      <deployment.host>https://somehost.com</deployment.host> 
     </properties> 
     <!-- via this activation the profile is automatically used when the release is done with the maven release 
     plugin --> 
     <activation> 
      <property> 
       <name>performRelease</name> 
       <value>true</value> 
      </property> 
     </activation> 
     <build> 
      <plugins> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-jarsigner-plugin</artifactId> 
        <executions> 
         <execution> 
          <id>signing</id> 
          <goals> 
           <goal>sign</goal> 
           <goal>verify</goal> 
          </goals> 
          <phase>package</phase> 
          <inherited>true</inherited> 
          <configuration> 
           <removeExistingSignatures>true</removeExistingSignatures> 
           <archiveDirectory/> 
           <includes> 
            <include>${project.build.directory}/${project.artifactId}.apk</include> 
           </includes> 
           <keystore>${sign.keystore}</keystore> 
           <alias>${sign.alias}</alias> 
           <storepass>${sign.storepass}</storepass> 
           <keypass>${sign.keypass}</keypass> 
           <verbose>true</verbose> 
          </configuration> 
         </execution> 
        </executions> 
       </plugin> 
       <!-- the signed apk then needs to be zipaligned and we activate proguard and we run the manifest 
       update --> 
       <plugin> 
        <groupId>com.jayway.maven.plugins.android.generation2</groupId> 
        <artifactId>android-maven-plugin</artifactId> 
        <inherited>true</inherited> 
        <configuration> 
         <sign> 
          <debug>false</debug> 
         </sign> 
         <zipalign> 
          <verbose>true</verbose> 
          <inputApk>${project.build.directory}/${project.artifactId}.apk</inputApk> 
          <outputApk>${project.build.directory}/${project.artifactId}-signed-aligned.apk 
          </outputApk> 
         </zipalign> 
         <manifest> 
          <debuggable>false</debuggable> 
          <versionCodeAutoIncrement>true</versionCodeAutoIncrement> 
         </manifest> 
         <proguard> 
          <skip>false</skip> 
         </proguard> 
        </configuration> 
        <executions> 
         <execution> 
          <id>manifestUpdate</id> 
          <phase>process-resources</phase> 
          <goals> 
           <goal>manifest-update</goal> 
          </goals> 
         </execution> 
         <execution> 
          <id>alignApk</id> 
          <phase>package</phase> 
          <goals> 
           <goal>zipalign</goal> 
          </goals> 
         </execution> 
        </executions> 
       </plugin> 
       <plugin> 
        <groupId>org.codehaus.mojo</groupId> 
        <artifactId>build-helper-maven-plugin</artifactId> 
        <configuration> 
         <artifacts> 
          <artifact> 
           <file>${project.build.directory}/${project.artifactId}-signed-aligned.apk</file> 
           <type>apk</type> 
           <classifier>signed-aligned</classifier> 
          </artifact> 
          <artifact> 
           <file>${project.build.directory}/proguard/mapping.txt</file> 
           <type>map</type> 
           <classifier>release</classifier> 
          </artifact> 
         </artifacts> 
        </configuration> 
        <executions> 
         <execution> 
          <id>attach-signed-aligned</id> 
          <phase>package</phase> 
          <goals> 
           <goal>attach-artifact</goal> 
          </goals> 
         </execution> 
        </executions> 
       </plugin> 
      </plugins> 
     </build> 
    </profile> 
</profiles> 

proguard.cfg:

-optimizationpasses 5 
-dontusemixedcaseclassnames 
-dontskipnonpubliclibraryclasses 
-dontpreverify 
-verbose 
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 

-keep public class * extends android.app.Activity 
-keep public class * extends android.app.Application 
-keep public class * extends android.app.Service 
-keep public class * extends android.content.BroadcastReceiver 
-keep public class * extends android.content.ContentProvider 
-keep public class * extends android.app.backup.BackupAgentHelper 
-keep public class * extends android.preference.Preference 
-keep public class com.android.vending.licensing.ILicensingService 

-keepclasseswithmembernames class * { 
    native <methods>; 
} 

-keepclasseswithmembers class * { 
    public <init>(android.content.Context, android.util.AttributeSet); 
} 

-keepclasseswithmembers class * { 
    public <init>(android.content.Context, android.util.AttributeSet, int); 
} 

-keepclassmembers class * extends android.app.Activity { 
    public void *(android.view.View); 
} 

-keepclassmembers enum * { 
    public static **[] values(); 
    public static ** valueOf(java.lang.String); 
} 

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

-renamesourcefileattribute SourceFile 
-keepattributes SourceFile,LineNumberTable 

しかし、私はmvn3 clean install -Prelease -Xを実行しようとしているとき、私はエラーとloooongコマンドを取得しました。私はそのコマンドを実行しようとしているとき、私は持っています:

Warning: com.google.common.collect.AbstractBiMap: can't find referenced class javax.annotation.Nullable 
Warning: com.google.common.collect.AbstractBiMap: can't find referenced class javax.annotation.Nullable 
Note: the configuration refers to the unknown class 'com.android.vending.licensing.ILicensingService' 
Note: there were 1 references to unknown classes. 
    You should check your configuration for typos. 
Warning: there were 1277 unresolved references to classes or interfaces. 
    You may need to specify additional library jars (using '-libraryjars'), 
    or perhaps the '-dontskipnonpubliclibraryclasses' option. 
Warning: there were 6 unresolved references to program class members. 
    Your input classes appear to be inconsistent. 
    You may need to recompile them and try again. 
    Alternatively, you may have to specify the options 
    '-dontskipnonpubliclibraryclasses' and/or 
    '-dontskipnonpubliclibraryclassmembers'. 
java.io.IOException: Please correct the above warnings first. 
at proguard.Initializer.execute(Initializer.java:308) 
at proguard.ProGuard.initialize(ProGuard.java:210) 
at proguard.ProGuard.execute(ProGuard.java:85) 
at proguard.ProGuard.main(ProGuard.java:499) 

そして、以前は参照に関する警告がたくさんありました。私は間違っているの?

+0

どのようにGoogle LVLをプロジェクトに組み込みますか?ライブラリプロジェクトやソースコードをコピーするにはどうすればよいですか? – yorkw

+0

LVLとは何ですか? oO – skayred

+0

[ライセンス検証ライブラリ](http://developer.android.com/guide/publishing/licensing.html) – yorkw

答えて

3

の警告は、あなたが処理している多くのクラスは、入力されたjarファイルやライブラリのjarファイルに存在しないクラスを参照してくださいと言う:

これは、Androidで共通の問題ですそこでは、他の欠けているライブラリに依存するサードパーティのライブラリを処理しています(実際には実際には使用しません)。一部のAndroid固有の質問と回答:

(無害)のノートがあなたのproguard.cfgがcom.android.vending.licensing.ILicensingServiceを参照することを言いますが、それクラスがコード内に存在しません。設定から回線を削除できます。

+0

LicensingServiceについては注意してください。ただし、例外と警告はそのまま残ります。 – skayred

+0

私はすべての-dontwarnを適用しており、resolvinについての警告も消えています – skayred