评估指令时Proguard错误 [英] Proguard error while evaluating instruction

查看:183
本文介绍了评估指令时Proguard错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将android项目升级到24 SDK版本.

I upgrade my android project to 24 SDK version.

但是在Proguard的构建路径中出现错误:

But I got error in Proguard path of build:

Unexpected error while evaluating instruction:
  Class       = [com/google/android/gms/iid/zzd]
  Method      = [zzeC(Ljava/lang/String;)V]
  Instruction = [11] invokevirtual #50
  Exception   = [java.lang.ArrayIndexOutOfBoundsException] (1)
Unexpected error while performing partial evaluation:
  Class       = [com/google/android/gms/iid/zzd]
  Method      = [zzeC(Ljava/lang/String;)V]
  Exception   = [java.lang.ArrayIndexOutOfBoundsException] (1)
Warning: Exception while processing task java.io.IOException: java.lang.ArrayIndexOutOfBoundsException: 1
:PC:transformClassesAndResourcesWithProguardForDebug FAILED

FAILURE: Build failed with an exception.

我的proguard.cfg文件:

My proguard.cfg file:

-printmapping /build/proguard-mapping.txt
-printusage /build/proguard-usage.txt
-printseeds /build/proguard-seeds.txt
-printconfiguration /build/proguard-configuration.txt

-optimizationpasses 5
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
#-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-optimizations !class/unboxing/enum
-allowaccessmodification
-repackageclasses ''
-keepattributes Signature
-keepattributes SetJavaScriptEnabled
-keepattributes JavascriptInterface
-keepattributes InlinedApi
-keepattributes SourceFile, LineNumberTable
-keepattributes *Annotation*

-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.preference.Preference

-libraryjars /libs

-dontwarn android.**
-dontwarn com.android.**
-dontwarn com.google.**
-dontwarn okio.**

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

-keep class com.android.** {*;}
-keepclassmembers class com.android.** { *; }

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

项目中的Build.gradle:

Build.gradle in project:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

在应用程序中构建.gradle:

Build.gradle in app:

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

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
    }
}

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"

    defaultConfig {
        minSdkVersion 11
        targetSdkVersion 24
        signingConfig signingConfigs.release
    }

    buildTypes {
        debug {
            debuggable true
            minifyEnabled true
            signingConfig signingConfigs.release
            proguardFile 'proguard.cfg'
        }
        release {
            debuggable true
            minifyEnabled true
            signingConfig signingConfigs.release
            proguardFile 'proguard.cfg'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.google.android.gms:play-services-gcm:9.0.0'
    compile 'com.android.support:support-v4:24.0.0'
    compile 'com.android.support:appcompat-v7:24.0.0'
}

此配置可在22个android SDK上正常工作,但更新到24个后出现错误.

This configs work fine on 22 android SDK, but after update to 24 got error.

我尝试添加下一个,但不成功:

I try add next but not success:

-keep class com.google.android.gms.analytics.**
-keep class com.google.analytics.tracking.**
-dontwarn com.google.android.gms.analytics.**
-dontwarn com.google.analytics.tracking.**

我的错误是什么,如何解决?

What is my error and what is a solution?

推荐答案

我最终得到了以下proguard选项:

I ended up with the following proguard options:

# WORKAROUND for building project with GMS (google play services) 
-keep class com.google.android.gms.iid.zzd { *; }
-keep class android.support.v4.content.ContextCompat { *; }

这篇关于评估指令时Proguard错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆