这是我们的R8版本
当前版本是:1.4.94(从 go/r8bot 构建 390954928f0db9c3b888a367f7f128ce3bbfb160 (luci-r8-ci-archive-0-5g74))。
当我从
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Run Code Online (Sandbox Code Playgroud)
到
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
Run Code Online (Sandbox Code Playgroud)
我们收到以下错误。
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
{
"code": 403,
"errors": [
{
"domain": "usageLimits",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"reason": "dailyLimitExceededUnreg",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:378)
at com.google.api.client.http.HttpRequest.a(HttpRequest.java:1067)
at …Run Code Online (Sandbox Code Playgroud) 当我想发布我的应用程序时出现此错误:com.android.tools.r8.internal.jb: Sealed classes are not supported as program classes when generating class files
在 build.gradle 中,由于 android studio min gradle,我无法编辑编译版本。
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
Run Code Online (Sandbox Code Playgroud)
我在模块中使用的密封类是
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
Run Code Online (Sandbox Code Playgroud) 我安装了新版本的 Android Studio 并更新了我的项目(不更改依赖项),但遇到了以下问题:
Missing class com.google.protobuf.java_com_google_android_gmscore_sdk_target_granule__proguard_group_gtm_N1281923064GeneratedExtensionRegistryLite$Loader (referenced from: java.util.List kotlinx.coroutines.internal.FastServiceLoader.load(java.lang.Class, java.lang.ClassLoader))
Missing class org.bouncycastle.jsse.BCSSLParameters (referenced from: void okhttp3.internal.platform.BouncyCastlePlatform.configureTlsExtensions(javax.net.ssl.SSLSocket, java.lang.String, java.util.List) and 1 other context)
Missing class org.bouncycastle.jsse.BCSSLSocket (referenced from: void okhttp3.internal.platform.BouncyCastlePlatform.configureTlsExtensions(javax.net.ssl.SSLSocket, java.lang.String, java.util.List) and 5 other contexts)
Missing class org.bouncycastle.jsse.provider.BouncyCastleJsseProvider (referenced from: void okhttp3.internal.platform.BouncyCastlePlatform.<init>())
Missing class org.conscrypt.Conscrypt$Version (referenced from: boolean okhttp3.internal.platform.ConscryptPlatform$Companion.atLeastVersion(int, int, int))
Missing class org.conscrypt.Conscrypt (referenced from: boolean okhttp3.internal.platform.ConscryptPlatform$Companion.atLeastVersion(int, int, int) and 4 other contexts)
Missing class org.conscrypt.ConscryptHostnameVerifier (referenced from: okhttp3.internal.platform.ConscryptPlatform$DisabledHostnameVerifier)
Missing class org.openjsse.javax.net.ssl.SSLParameters (referenced from: void okhttp3.internal.platform.OpenJSSEPlatform.configureTlsExtensions(javax.net.ssl.SSLSocket, …Run Code Online (Sandbox Code Playgroud) 我正在编写 Android 库,所以我想保留一些构造函数/方法的参数名称。我正在将我的库部署为 AAR 文件。
Gradle 从 3.3.2 升级到 3.4.0 后,构造函数和公共方法中的所有参数都被重命名为类似“var1”的名称,在此之前一切都很好。
据我了解,主要区别在于,现在默认使用 R8 而不是 Proguard 来缩小和混淆我们的代码。所以可能我在配置中遗漏了一些东西。
假设我有课:
public class Foo {
public String bar;
public Foo(String bar) {
this.bar = bar;
}
}
Run Code Online (Sandbox Code Playgroud)
所以在 proguard-rules.pro 中我有:
-keepparameternames
-keepattributes MethodParameters
-keepattributes Signature
-keep class my.class.path.Foo { *; }
Run Code Online (Sandbox Code Playgroud)
我将该配置加载到我的模块 gradle 文件中:
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}}
Run Code Online (Sandbox Code Playgroud)
现在我的 AAR 文件中的类看起来像这样 ->
public class Foo {
public String bar;
public SecureElement(String var1) {
this.bar = var1;
}
} …Run Code Online (Sandbox Code Playgroud) 我创建了两个 aar 库:com.example:test1:1.0.0 和 com.example:test2:1.0.0。我将这些库添加到我的主应用程序中,并且在构建 Android-Studio 后抛出错误:
Duplicate class com.example.utils.a found in modules classes.jar (com.example:test1:1.0.0) and classes.jar (com.example:test2:1.0.0)
我发现发生这个错误是因为两个库在同一个包(com.example.utils)中都有类,并且在混淆后 R8 创建了具有相同全名的类(a.class)(我在 aar 的 classes.jar 中看到了这个)。如果我在我的库的属性中禁用 R8,这个错误就会消失。
'a' 不是库类:混淆后所有库类名称保持不变,并且 a.class 被 R8 添加到包中。我阅读了 R8 文档,但没有发现有关此问题的任何信息。有没有办法解决这个问题,而无需在我的一个库中命名包?
我正在使用 Android-R8 并且存在以下 R8 警告:
R8 warnings
Missing class: javax.xml.stream.XMLStreamReader
Missing class: javax.xml.stream.util.XMLEventAllocator
Missing class: javax.xml.stream.events.Characters
Missing class: javax.xml.stream.events.DTD
Missing class: javax.xml.stream.XMLOutputFactory
Missing class: javax.xml.stream.EventFilter
Missing class: javax.xml.stream.events.Comment
Missing class: javax.xml.stream.events.Attribute
Missing class: javax.xml.stream.events.NotationDeclaration
Missing class: javax.xml.stream.events.ProcessingInstruction
Missing class: javax.xml.stream.events.EndElement
Missing class: javax.xml.stream.events.StartDocument
Missing class: javax.xml.stream.Location
Missing class: javax.xml.stream.util.XMLEventConsumer
Missing class: javax.xml.stream.events.EndDocument
Missing class: javax.xml.stream.events.XMLEvent
Missing class: javax.xml.stream.XMLInputFactory
Missing class: javax.xml.stream.events.EntityDeclaration
Missing class: javax.xml.stream.XMLEventWriter
Missing class: javax.xml.stream.events.Namespace
Missing class: javax.xml.stream.StreamFilter
Missing class: javax.xml.stream.events.EntityReference
Missing class: javax.xml.stream.events.StartElement
Missing class: javax.xml.stream.XMLEventFactory
Missing …Run Code Online (Sandbox Code Playgroud) 我正在使用proguard来混淆我的代码,并且我有一个称为库的模块,在该模块中我有一个资产文件夹,并且我保留了一些在运行时使用的 jar。我想将该资产文件夹保留在混淆器中。
这是它的结构:
我怎样才能保留这些?或者我们如何在ProGuard中传递文件的路径?
我在启用 R8 的情况下构建发布 apk 时遇到以下错误:
Task :app:minifyReleaseWithR8
AGPBI: {"kind":"warning","text":"Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in C:\\Users\\y509118\\AndroidStudioProjects\\SafeBox\\app\\build\\outputs\\mapping\\release\\missing_rules.txt.\n","sources":[{}]}
AGPBI: {"kind":"warning","text":"Missing class com.google.errorprone.annotations.Immutable (referenced from: com.google.crypto.tink.KeyTemplate and 4 other contexts)","sources":[{}],"tool":"R8"}
Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in C:\Users\y509118\AndroidStudioProjects\SafeBox\app\build\outputs\mapping\release\missing_rules.txt.
Missing class com.google.errorprone.annotations.Immutable (referenced from: com.google.crypto.tink.KeyTemplate and 4 other contexts)
Run Code Online (Sandbox Code Playgroud)
上述missing_rules文件的内容:
# Please add these rules to your existing …Run Code Online (Sandbox Code Playgroud) java.lang.RuntimeException: Unable to invoke no-args constructor for class com.arch.example.network.models.NetworkPagingList. Registering an InstanceCreator with Gson for this type may fix this problem.\n at com.google.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:228)\n at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:212)\n at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:40)\n at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:27)\n at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:243)\n at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:153)\n at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)\n at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)\n at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)\n at java.lang.Thread.run(Thread.java:1012)\n Caused by: java.lang.UnsupportedOperationException: Abstract class can't be instantiated! Class name: com.arch.example.network.models.NetworkPagingList\n at com.google.gson.internal.UnsafeAllocator.assertInstantiable(UnsafeAllocator.java:120)\n at com.google.gson.internal.UnsafeAllocator$1.newInstance(UnsafeAllocator.java:49)\n at com.google.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:225)\n at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:212)\xc2\xa0\n at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:40)\xc2\xa0\n at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:27)\xc2\xa0\n at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:243)\xc2\xa0\n at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:153)\xc2\xa0\n at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)\xc2\xa0\n at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)\xc2\xa0\n at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)\xc2\xa0\n at java.lang.Thread.run(Thread.java:1012)\xc2\xa0\nRun Code Online (Sandbox Code Playgroud)\n实体:
\nimport …Run Code Online (Sandbox Code Playgroud) 我最近将 Android 应用程序项目中的 Android Gradle 插件从版本 7.4.2 升级到 8.0.2。但是,当执行 minifyReleaseWithR8 任务时,我现在在发布构建期间遇到错误。
我收到的错误消息如下:
Task :app:minifyReleaseWithR8
AGPBI: {"kind":"error","text":"Library class android.test.AndroidTestRunner extends program class junit.runner.BaseTestRunner","sources":[{}],"tool":"R8"}
Library class android.test.AndroidTestRunner extends program class junit.runner.BaseTestRunner
AGPBI: {"kind":"error","text":"Library class android.test.InstrumentationTestCase extends program class junit.framework.TestCase","sources":[{}],"tool":"R8"}
Library class android.test.InstrumentationTestCase extends program class junit.framework.TestCase
Task :app:minifyReleaseWithR8 FAILED
Run Code Online (Sandbox Code Playgroud)
该错误似乎与缺少服务类以及库类和程序类之间的冲突有关。
这些错误是在我更新 Android Gradle 插件后才开始出现的。我已尝试清理项目并确保所有依赖项都是最新的,但问题仍然存在。
有其他人在升级到 Android Gradle Plugin 8.0.2 时遇到过类似的问题吗?如何解决这些错误并成功缩小 R8 的发布版本?
任何帮助或建议将不胜感激。谢谢你!