【问题标题】:Warnings in libraries during signing app签署应用程序期间库中的警告
【发布时间】:2015-07-29 14:11:13
【问题描述】:

 buildscript {
        repositories {
            maven { url 'https://maven.fabric.io/public' }
        }

        dependencies {
            classpath 'io.fabric.tools:gradle:1.+'
        }
    }
    apply plugin: 'com.android.application'
    apply plugin: 'io.fabric'

    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }


    android {
        compileSdkVersion 22
        buildToolsVersion "22.0.1"

        defaultConfig {
            applicationId "com.example.hello"
            minSdkVersion 9
            targetSdkVersion 21
            compileOptions {
                sourceCompatibility JavaVersion.VERSION_1_7
                targetCompatibility JavaVersion.VERSION_1_7
            }
        }

        buildTypes {
            release {
                minifyEnabled true
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        compile 'com.android.support:support-v4:22.2.0'
        compile 'com.google.code.gson:gson:2.2.4'
        compile 'com.android.support:appcompat-v7:22.2.0'
        compile 'com.google.android.gms:play-services:+'
        compile files('libs/bolts-android-1.2.0.jar')
        compile files('libs/facebook.jar')
        compile 'de.hdodenhof:circleimageview:1.2.1'
        compile 'com.android.support:recyclerview-v7:21.0.+'
        compile 'com.squareup.picasso:picasso:2.5.2'
        compile 'com.jakewharton:butterknife:6.1.0'
        compile 'com.android.support:cardview-v7:21.0.+'
        compile 'com.github.bumptech.glide:glide:3.5.2'
        compile 'com.android.support:support-v4:22.0.0'
        compile('com.crashlytics.sdk.android:crashlytics:2.4.0@aar') {
            transitive = true;
        }
        compile 'com.nhaarman.listviewanimations:lib-core:3.1.0@aar'
        compile project(':gcmv')
        compile 'com.android.support:design:22.2.0'
    }

今天,当我使用 proguard 为我的应用程序签名时,它在我的库中显示了太多警告。 所以由于警告,我无法生成我签名的 apk 文件。 那么有什么方法可以在我的 gradle 文件中使用“dontwarn”。

【问题讨论】:

  • 没有警告就很难说!
  • @BastienViatge aaded 错误图片。检查一下

标签: android android-gradle-plugin proguard


【解决方案1】:

您似乎正在使用毕加索库。

尝试在你的 proguard 文件中添加这一行。 (proguard-rules.pro 在您的应用模块中)

-dontwarn com.squareup.okhttp.**

【讨论】:

  • 现在又显示了一个警告。警告:无法写入资源 [.readme](重复的 zip 条目 [classes.jar:.readme])
  • 这个答案解决了 proguard 的毕加索问题,并且这个新警告与毕加索无关,最好在另一个问题中问它并给我们更多细节
【解决方案2】:

根据ProGuard documentation

标准的 Android 构建过程会自动指定输入 给你的罐子。不幸的是,许多预编译的第三方库 引用其他未实际使用的库,因此不 展示。这在调试版本中工作正常,但在发布版本中, ProGuard 需要所有库,因此它可以执行适当的静态 分析。例如,如果 ProGuard 抱怨它找不到 java.awt 类,然后您正在使用的某个库是指 java.awt。这有点阴暗,因为Android没有这个包 完全没有,但是如果您的应用程序仍然可以工作,您可以让 ProGuard 例如,用“-dontwarn java.awt.**”接受它。

如上所述,如果它在调试中运行良好,您可以使用-dontwarn 作为类过滤器:

指定不警告未解析的引用和其他重要的 问题。可选过滤器是一个正则表达式; ProGuard 不打印有关名称匹配的类的警告。忽略 警告可能很危险。例如,如果未解决的类或 确实需要类成员进行处理,处理后的代码 将无法正常运行。

【讨论】:

    猜你喜欢
    • 2012-11-16
    • 1970-01-01
    • 1970-01-01
    • 2014-10-29
    • 1970-01-01
    • 1970-01-01
    • 2020-06-13
    • 1970-01-01
    • 2021-06-30
    相关资源
    最近更新 更多