草庐IT

android - 在启用混淆器的情况下以 Release模式编译 Android 应用程序时出现问题

coder 2023-12-15 原文

我正在尝试使用混淆器编译我的 Android 应用程序,但我收到以下错误并且不知道如何修复它们。有人知道吗?在 Debug模式下,一切都可以正常编译...

Note: duplicate definition of library class [org.apache.http.conn.scheme.HostNameResolver]
Note: duplicate definition of library class [org.apache.http.conn.scheme.SocketFactory]
Note: duplicate definition of library class [org.apache.http.conn.ConnectTimeoutException]
Note: duplicate definition of library class [org.apache.http.params.HttpParams]
Note: duplicate definition of library class [android.net.http.SslCertificate$DName]
Note: duplicate definition of library class [android.net.http.SslError]
Note: duplicate definition of library class [android.net.http.SslCertificate]
    Note: android.support.v4.app.NotificationCompatJellybean accesses a declared field 'title' dynamically
          Maybe this is program field 'android.support.v4.app.NotificationCompat$Action { java.lang.CharSequence title; }'
          Maybe this is program field 'android.support.v7.appcompat.R$attr { int title; }'
          Maybe this is program field 'android.support.v7.appcompat.R$id { int title; }'
          Maybe this is program field 'android.support.v7.mediarouter.R$attr { int title; }'
          Maybe this is program field 'android.support.v7.mediarouter.R$id { int title; }'
          Maybe this is program field 'com.facebook.share.internal.VideoUploader$UploadContext { java.lang.String title; }'
          Maybe this is program field 'com.facebook.share.model.GameRequestContent { java.lang.String title; }'
          Maybe this is program field 'com.facebook.share.model.GameRequestContent$Builder { java.lang.String title; }'
          Maybe this is program field 'com.google.android.gms.games.internal.player.PlayerColumnNames { java.lang.String title; }'
          Maybe this is program field 'com.google.android.gms.vision.barcode.Barcode$ContactInfo { java.lang.String title; }'
          Maybe this is program field 'com.google.android.gms.vision.barcode.Barcode$UrlBookmark { java.lang.String title; }'
          Maybe this is program field 'com.google.api.client.util.PemReader$Section { java.lang.String title; }'
          Maybe this is program field 'com.android.app.R$attr { int title; }'
          Maybe this is program field 'com.android.app.R$id { int title; }'
          Maybe this is program field 'com.android.app.adapter.InAppListItem { java.lang.String title; }'
          Maybe this is library field 'android.R$attr { int title; }'
          Maybe this is library field 'android.R$id { int title; }'
          Maybe this is library field 'android.app.Notification$Action { java.lang.CharSequence title; }'
          Maybe this is library field 'android.preference.PreferenceActivity$Header { java.lang.CharSequence title; }'
        Warning:library class com.google.api.client.auth.oauth2.TokenRequest depends on program class com.google.api.client.http.HttpRequestInitializer
        Warning:library class com.google.api.client.auth.oauth2.TokenRequest depends on program class com.google.api.client.http.HttpExecuteInterceptor
        Warning:library class com.google.api.client.auth.oauth2.TokenRequest depends on program class com.google.api.client.http.GenericUrl
        Warning:library class com.google.api.client.auth.oauth2.TokenRequest depends on program class com.google.api.client.http.HttpResponse
        Warning:library class com.google.api.client.auth.oauth2.TokenRequest depends on program class com.google.api.client.util.GenericData
        Warning:library class com.google.api.client.auth.oauth2.TokenResponse depends on program class com.google.api.client.json.GenericJson
        Warning:library class com.google.api.client.auth.oauth2.TokenResponse depends on program class com.google.api.client.util.GenericData
        Warning:library class com.google.api.client.auth.openidconnect.IdToken depends on program class com.google.api.client.json.webtoken.JsonWebSignature$Header
        Warning:library class com.google.api.client.auth.openidconnect.IdToken depends on program class com.google.api.client.json.JsonFactory
        Warning:library class com.google.api.client.auth.openidconnect.IdToken depends on program class com.google.api.client.json.webtoken.JsonWebToken$Payload
        Warning:library class com.google.api.client.auth.openidconnect.IdToken$Payload depends on program class com.google.api.client.json.webtoken.JsonWebToken$Payload
        Warning:library class com.google.api.client.auth.openidconnect.IdToken$Payload depends on program class com.google.api.client.json.GenericJson
        Warning:library class com.google.api.client.auth.openidconnect.IdToken$Payload depends on program class com.google.api.client.util.GenericData
        Warning:library class com.google.api.client.auth.openidconnect.IdTokenVerifier depends on program class com.google.api.client.util.Clock
        Warning:library class com.google.api.client.auth.openidconnect.IdTokenVerifier$Builder depends on program class com.google.api.client.util.Clock
            Note: the configuration explicitly specifies 'org.apache.http.**' to keep library class 'org.apache.http.protocol.HttpRequestExecutor'
            Note: the configuration explicitly specifies 'org.apache.http.**' to keep library class 'org.apache.http.protocol.HttpRequestInterceptorList'
            Note: the configuration explicitly specifies 'org.apache.http.**' to keep library class 'org.apache.http.protocol.HttpResponseInterceptorList'
            Note: the configuration explicitly specifies 'org.apache.http.**' to keep library class 'org.apache.http.protocol.SyncBasicHttpContext'
            Note: the configuration explicitly specifies 'org.apache.http.**' to keep library class 'org.apache.http.util.EntityUtils'
            Note: there were 2 references to unknown classes.
                  You should check your configuration for typos.
                  (http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
            Note: there were 112 library classes explicitly being kept.
                  You don't need to keep library classes; they are already left unchanged.
                  (http://proguard.sourceforge.net/manual/troubleshooting.html#libraryclass)
            Note: there were 16 unresolved dynamic references to classes or interfaces.
                  You should check if you need to specify additional program jars.
                  (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
            Note: there were 4 accesses to class members by means of introspection.
                  You should consider explicitly keeping the mentioned class members
                  (using '-keep' or '-keepclassmembers').
                  (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclassmember)
            Warning:there were 146 instances of library classes depending on program classes.
                     You must avoid such dependencies, since the program classes will
                     be processed, while the library classes will remain unchanged.
                     (http://proguard.sourceforge.net/manual/troubleshooting.html#dependency)
            Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
            :app:transformClassesAndResourcesWithProguardForRelease FAILED
            Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
            > java.io.IOException: Please correct the above warnings first.

我的 Gradle 文件如下所示:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 'Google Inc.:Google APIs:23'
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.test.app"
        minSdkVersion 17
        targetSdkVersion 21
        versionCode 240
        versionName "2.4.0"
        // Enabling multidex support.
        multiDexEnabled true
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFile getDefaultProguardFile('proguard-android.txt')
            proguardFile 'proguard-app.txt'
        }
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.google.http-client:google-http-client-gson:1.20.0'
    compile 'com.google.code.gson:gson:2.4'
    compile "com.android.support:appcompat-v7:23.1.1"
    compile 'com.google.android.gms:play-services:8.3.0'

    compile 'com.facebook.android:facebook-android-sdk:4.7.0'
    compile 'com.android.support:support-v13:23.1.0'
    compile files('libs/google-api-client-1.18.0-rc.jar')
    compile files('libs/google-api-client-android-1.18.0-rc.jar')
    compile files('libs/google-http-client-android-1.18.0-rc.jar')
    compile files('libs/AudienceNetwork.jar')
}

这是我的 proguard 文件 proguard-app.txt:

# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html
-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.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);
}

-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.content.Context {
   public void *(android.view.View);
   public void *(android.view.MenuItem);
}

-keepclassmembers class * implements android.os.Parcelable {
    static ** CREATOR;
}

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

-keepclassmembers class * {
    @android.webkit.JavascriptInterface <methods>;
}

-keepattributes Exceptions,InnerClasses,Signature

-keep class com.google.api.client.**
-keepclassmembers class com.google.api.client.** {
    *;
 }


-keep class com.google.android.gms.**
-keepclassmembers class com.google.android.gms.** {
    *;
 }
-keep class com.google.gson.**
-keepclassmembers class com.google.gson.** {
    *;
 }


-keep class com.google.ads.**
-keepclassmembers class com.google.ads.** {
    *;
 }

-keep class bolts.**
-keepclassmembers class bolts.** {
    *;
 }

-keep class com.google.api.client.** { *; }
-dontwarn com.google.api.client.*
-keep class org.apache.http.** { *; }
-dontwarn org.apache.http.*

-libraryjars libs
#-injars libs/AudienceNetwork.jar
#-injars libs/google-api-client-1.18.0-rc.jar
#-injars libs/google-api-client-android-1.18.0-rc.jar
#-injars libs/google-http-client-android-1.18.0-rc.jar


 # The official support library.
-keep class android.support.v4.** { *; }
-keepclassmembers class android.support.v4.** {
    *;
 }
-keep interface android.support.v4.** { *; }
-keep class android.support.v7.** { *; }
-keepclassmembers class android.support.v7.** {
    *;
 }
-keep interface android.support.v7.** { *; }

# Library JARs.
-keep class com.facebook.** {
   *;
}
-keepclassmembers class com.facebook.** {
    *;
 }

最佳答案

将以下行添加到您的 proguard-rules.pro 文件

-keep class android.support.v4.** { *; }
-dontnote android.support.v4.**

关于android - 在启用混淆器的情况下以 Release模式编译 Android 应用程序时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33857887/

有关android - 在启用混淆器的情况下以 Release模式编译 Android 应用程序时出现问题的更多相关文章

  1. ruby - ECONNRESET (Whois::ConnectionError) - 尝试在 Ruby 中查询 Whois 时出错 - 2

    我正在用Ruby编写一个简单的程序来检查域列表是否被占用。基本上它循环遍历列表,并使用以下函数进行检查。require'rubygems'require'whois'defcheck_domain(domain)c=Whois::Client.newc.query("google.com").available?end程序不断出错(即使我在google.com中进行硬编码),并打印以下消息。鉴于该程序非常简单,我已经没有什么想法了-有什么建议吗?/Library/Ruby/Gems/1.8/gems/whois-2.0.2/lib/whois/server/adapters/base.

  2. ruby - 在 64 位 Snow Leopard 上使用 rvm、postgres 9.0、ruby 1.9.2-p136 安装 pg gem 时出现问题 - 2

    我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po

  3. ruby - 默认情况下使选项为 false - 2

    这是在Ruby中设置默认值的常用方法:classQuietByDefaultdefinitialize(opts={})@verbose=opts[:verbose]endend这是一个容易落入的陷阱:classVerboseNoMatterWhatdefinitialize(opts={})@verbose=opts[:verbose]||trueendend正确的做法是:classVerboseByDefaultdefinitialize(opts={})@verbose=opts.include?(:verbose)?opts[:verbose]:trueendend编写Verb

  4. ruby - 在没有 sass 引擎的情况下使用 sass 颜色函数 - 2

    我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re

  5. 使用 ACL 调用 upload_file 时出现 Ruby S3 "Access Denied"错误 - 2

    我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file

  6. ruby - 在不使用 RVM 的情况下在 Mac 上卸载和升级 Ruby - 2

    我最近决定从我的系统中卸载RVM。在thispage提出的一些论点说服我:实际上,我的决定是,我根本不想担心Ruby的多个版本。我只想使用1.9.2-p290版本而不用担心其他任何事情。但是,当我在我的Mac上运行ruby--version时,它告诉我我的版本是1.8.7。我四处寻找如何简单地从我的Mac上卸载这个Ruby,但奇怪的是我没有找到任何东西。似乎唯一想卸载Ruby的人运行linux,而使用Mac的每个人都推荐RVM。如何从我的Mac上卸载Ruby1.8.7?我想升级到1.9.2-p290版本,并且我希望我的系统上只有一个版本。 最佳答案

  7. ruby-on-rails - 启用 Rack::Deflater 时 ETag 发生变化 - 2

    在启用Rack::Deflater来gzip我的响应主体时偶然发现了一些奇怪的东西。也许我遗漏了一些东西,但启用此功能后,响应被压缩,但是资源的ETag在每个请求上都会发生变化。这会强制应用程序每次都响应,而不是发送304。这在没有启用Rack::Deflater的情况下有效,我已经验证页面源没有改变。我正在运行一个使用thin作为Web服务器的Rails应用程序。Gemfile.lockhttps://gist.github.com/2510816有没有什么方法可以让我从Rack中间件获得更多的输出,这样我就可以看到发生了什么?提前致谢。 最佳答案

  8. ruby - 使用 postgres.app 在 rvm 下要求 pg 时出错 - 2

    我正在使用Postgres.app在OSX(10.8.3)上。我已经修改了我的PATH,以便应用程序的bin文件夹位于所有其他文件夹之前。Rammy:~phrogz$whichpg_config/Applications/Postgres.app/Contents/MacOS/bin/pg_config我已经安装了rvm并且可以毫无错误地安装pggem,但是当我需要它时我得到一个错误:Rammy:~phrogz$gem-v1.8.25Rammy:~phrogz$geminstallpgFetching:pg-0.15.1.gem(100%)Buildingnativeextension

  9. ruby-on-rails - 为什么在安装 Ruby 1.9.3 时出现 404 错误? - 2

    我最近对我的计算机(OS-MacOSX10.6.8)进行了删除,并且我正在重新安装我所有的开发工具。我再次安装了RVM;但是,它不会让我安装Ruby1.9.3。到目前为止我已经尝试过:rvminstall1.9.3rvm安装1.9.3-p194rvm安装1.9.3-p448rvminstall1.9.3--with-gcc=clang所有返回相同的命令行错误:Searchingforbinaryrubies,thismighttakesometime.Nobinaryrubiesavailablefor:osx/10.6/x86_64/ruby-1.9.3-p448.Continuin

  10. 安卓apk修改(Android反编译apk) - 2

    最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路

随机推荐