Android - 制作签名apk时出现滑行jar问题

时间:2017-04-29 11:59:05

标签: android eclipse android-glide

我在签名apk时遇到以下错误, 请帮我解决这个问题。 我在应用程序中使用了Glide jar。

[2017-04-29 17:22:42 - myApp]警告:com.bumptech.glide.manager.SupportRequestManagerFragment:找不到引用的方法'android.support.v4.app.Fragment getParentFragment()'in class com.bumptech.glide.manager.SupportRequestManagerFragment

[2017-04-29 17:22:42 - myApp]警告:com.bumptech.glide.manager.SupportRequestManagerFragment:找不到引用的方法'android.support.v4.app.FragmentActivity getActivity()'in class com.bumptech.glide.manager.SupportRequestManagerFragment

[2017-04-29 17:22:42 - myApp]警告:程序类成员有2个未解析的引用。

[2017-04-29 17:22:42 - myApp]您的输入类似乎不一致。

[2017-04-29 17:22:42 - myApp]您可能需要重新编译它们并重试。

[2017-04-29 17:22:42 - myApp]或者,您可能需要指定选项

[2017-04-29 17:22:42 - myApp]'-dontskipnonpubliclibraryclassmembers'。

[2017-04-29 17:22:42 - myApp] java.io.IOException:请先纠正上述警告。

[2017-04-29 17:22:42 - myApp]在proguard.Initializer.execute(Initializer.java:321)

[2017-04-29 17:22:42 - myApp]在proguard.ProGuard.initialize(ProGuard.java:211)

[2017-04-29 17:22:42 - myApp]在proguard.ProGuard.execute(ProGuard.java:86)

[2017-04-29 17:22:42 - myApp]在proguard.ProGuard.main(ProGuard.java:492)

2 个答案:

答案 0 :(得分:0)

您有此错误,因为您在重新安装apk

中使用proGuard

您可能需要在proguard.cfg / proguard.pro

中加入以下行
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public enum 
com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}

# for DexGuard only
-keepresourcexmlelements manifest/application/meta-data@value=GlideModule

答案 1 :(得分:0)

如果project.properties中的'proguard.cfg'路径错误,则会发生此错误。 确保声明正确的路径,示例如下

    proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard.cfg

如果错误仍然存​​在,请对proguard.cfg文件中抛出错误/警告的所有软件包执行以下操作

    -dontwarn com.google.code.**
    -dontwarn oauth.signpost.**
    -dontwarn twitter4j.**

使用proguard.cfg文件示例:

    -optimizationpasses 5
    -dontusemixedcaseclassnames
    -dontskipnonpubliclibraryclasses
    -dontskipnonpubliclibraryclassmembers
    -dontpreverify
    -dontshrink
    -verbose

    -injars bin/classes
    -injars libs
    -outjars bin/classes-processed.jar

    -libraryjars C:/glassfish3/jdk7/jre/lib/rt.jar 
    -libraryjars C:/glassfish3/jdk7/lib/tools.jar

    -dontwarn org.apache.**
    -dontwarn org.slf4j.**
    -dontwarn org.json.*
    -dontwarn org.mortbay.**
    -dontwarn org.apache.log4j.**
    -dontwarn org.apache.commons.logging.**
    -dontwarn org.apache.commons.logging.**
    -dontwarn org.apache.commons.codec.binary.**
    -dontwarn javax.xml.**
    -dontwarn javax.management.**
    -dontwarn java.lang.management.**
    -dontwarn android.support.**
    -dontwarn com.google.code.**
    -dontwarn oauth.signpost.**
    -dontwarn twitter4j.**

    -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
    -keep public class com.google.code.linkedinapi.**

    -keep class javax.**  { *; }
    -keep class org.**  { *; }
    -keep class twitter4j.**  { *; }
    -keep class java.lang.management.**  { *; }
    -keep class com.google.code.**  { *; }
    -keep class oauth.signpost.**  { *; }

    -keepclassmembers public class         com.google.code.linkedinapi.client.impl.LinkedInApiXppClient {
 public <init>(java.lang.String, java.lang.String);
    }

    -keepclasseswithmembernames class * {
native <methods>;
    }

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

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

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

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

}