gpt4 book ai didi

android - 评估指令时出现 Proguard 错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:19:25 24 4
gpt4 key购买 nike

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

但是我在构建的 Proguard 路径中遇到了错误:

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 文件:

-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:

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

应用中的 Build.gradle:

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 后出现错误。

我尝试添加下一个但没有成功:

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

我的错误是什么以及解决方案是什么?

最佳答案

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

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

关于android - 评估指令时出现 Proguard 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38043855/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com