【问题标题】:After Updating Android Studio 3.1, I am getting these warnings after each build更新 Android Studio 3.1 后,每次构建后我都会收到这些警告
【发布时间】:2018-09-11 16:28:33
【问题描述】:

Android 问题警告

  1. 从 1 个方法中删除了无效的本地信息。

从 1 个方法中删除了无效的本地信息。 Message{kind=WARNING, text=Stripped invalid locals information from 1 method., sources=[Unknown source file], tool name=Optional.of(D8)}

  1. InnerClass 注释缺少相应的 EnclosureMember 注释。此类 InnerClass 注释将被忽略。

InnerClass 注释缺少相应的 EnclosureMember 注释。此类 InnerClass 注释将被忽略。 Message{kind=WARNING, text=InnerClass 注释缺少相应的 EnclosureMember 注释。这样的InnerClass注解会被忽略,sources=[Unknown source file], tool name=Optional.of(D8)}

  1. 未找到类型org.w3c.dom.bootstrap.DOMImplementationRegistry,它是void com.fasterxml.jackson.databind.ext.DOMSerializer.<init>() 的默认或静态接口方法脱糖所必需的

找不到类型org.w3c.dom.bootstrap.DOMImplementationRegistry,它是void com.fasterxml.jackson.databind.ext.DOMSerializer.<init>()的默认或静态接口方法所必需的 Message{kind=WARNING, text=Type org.w3c.dom.bootstrap.DOMImplementationRegistry is not found, 它是默认或静态接口方法所必需的/transforms/androidGradleClassShrinker/beta/debug/4/com/fasterxml/jackson/databind/ext/DOMSerializer.class],工具名=Optional.of(D8)}

Java 编译器警告

  1. 规则 `-keep public class *extends java.lang.annotation.Annotation {

警告:规则 `-keep public class *extends java.lang.annotation.Annotation {

对于 java 编译器警告,我尝试修复我的 proguard 文件。这是我的proguard文件。如果我做错了什么,请告诉我。

#Start Dto#
-keep public class co.openapp.app.data.model.* {
  *;
}
#End Dto#

#OkHttp3, Okio, Retrofit
-dontwarn okhttp3.**
-dontwarn okio.**
-dontwarn javax.annotation.**

#Start Okhttp#
-dontwarn java.nio.file.**
-dontwarn java.lang.invoke.**
-dontwarn java.lang.reflect.Method
#End Okhttp#

#Start Retrofit#
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes Exceptions
#End Retrofit#

#Start Jackson
-keepattributes *Annotation*,EnclosingMethod,Signature
-keepnames class com.fasterxml.jackson.** { *; }
-dontwarn com.fasterxml.jackson.databind.**
-keep class org.codehaus.** { *; }
-keepclassmembers public final enum 
org.codehaus.jackson.annotate.JsonAutoDetect$Visibility {
    public static final 
org.codehaus.jackson.annotate.JsonAutoDetect$Visibility *; }
#End Jackson

#Start Crashlytics#
-keepattributes SourceFile,LineNumberTable
#End Crashlytics#

#dagger
-dontwarn com.google.errorprone.annotations.**

##---------------Begin: proguard configuration common for all Android apps ----------
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-dontpreverify
-verbose
-dump class_files.txt
-printseeds seeds.txt
-printusage unused.txt
-printmapping mapping.txt
-optimizations 
!code/simplification/arithmetic,

-allowaccessmodification
-keepattributes *Annotation*
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-repackageclasses ''

-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
-dontnote com.android.vending.licensing.ILicensingService

# Explicitly preserve all serialization members. The Serializable interface
# is only a marker interface, so it wouldn't save them.
-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

# Preserve all native method names and the names of their classes.
-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);
}

# Preserve static fields of inner classes of R classes that might be accessed
# through introspection.
-keepclassmembers class **.R$* {
  public static <fields>;
}

# Preserve the special static methods that are required in all enumeration classes.
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep public class * {
    public protected *;
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}
##---------------End: proguard configuration common for all Android apps ----------

#---------------Begin: proguard configuration for support library  ----------
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }

# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
-dontwarn android.support.**
-dontwarn com.google.ads.**
##---------------End: proguard configuration for Gson  ----------

##---------------Begin: proguard configuration for Gson  ----------
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-keep class sun.misc.Unsafe { *; }
#-keep class com.google.gson.stream.** { *; }

# Application classes that will be serialized/deserialized over Gson
-keep class com.example.model.** { *; }

##---------------End: proguard configuration for Gson  ----------

【问题讨论】:

  • 升级到 android studio 3.1 后出现同样的问题,我收到多个警告,例如“...找不到引用的类 com.google.devtools.build.android.desugar.runtime。 ThrowableExtension" 都与脱糖包相关

标签: android android-studio compiler-warnings android-proguard android-studio-3.1


【解决方案1】:

仅供参考,看起来这在 AGP 3.2 Canary 12 中已修复: https://issuetracker.google.com/issues/72080964

遇到同样的问题...

【讨论】:

    【解决方案2】:

    将此添加到您的构建 gradle (module:app)

    implementation 'com.stripe:stripe-android:6.1.2'
    

    会解决的

    【讨论】:

    • 这听起来不像是一个适当的解决方案。为什么要这样做?
    • 不要认为它会修复 D8
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-03
    • 2020-05-19
    • 1970-01-01
    • 2010-11-16
    • 1970-01-01
    • 2013-04-07
    • 1970-01-01
    相关资源
    最近更新 更多