我正试图为我的应用程序生成签名的apk,但它失败了,返回错误Expecting type and name instead of just 'setExtensionCallback' before '(' in line 326 of file 'pathtofilereleaseconsumer-rules.pro',
我不确定是什么原因造成的,也没有任何进一步的信息或任何详细的报告。这是consumer-rules.pro
-的第325和326行
-if class androidx.window.layout.SidecarCompat {
public setExtensionCallback(androidx.window.layout.ExtensionInterfaceCompat$ExtensionCallbackInterface);
}
我正在为此使用dexguard。几天前它还在工作,但突然停止了。
这是dexguard-project.txt
文件。
# Display some more statistics about the processed code.
-verbose
# Encrypt the assets.
-encryptassetfiles assets/**
#enable all rasp checks
-raspchecks *
-raspcontinueon *
-raspcallback class com.appname.name.SplashActivity{
public static void mRaspCallback(com.guardsquare.dexguard.rasp.callback.DetectionReport);
}
#project related
-keep class com.appname.name.constants
-keep class com.shockwave.**
-dontpreverify
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes EnclosingMethod
-keepattributes InnerClasses
-dontwarn org.xmlpull.v1.**
-dontwarn android-support-v4.**
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
-keep public class com.google.** {*;}
-keepattributes Signature
-keepattributes SourceFile,LineNumberTable
# Huawei Map Config
-ignorewarnings
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes Signature
-keepattributes SourceFile,LineNumberTable
-keep class com.hianalytics.android.**{*;}
-keep class com.huawei.updatesdk.**{*;}
-keep class com.huawei.hms.**{*;}
-keep class org.xms.g.maps.ExtensionMapOptions{*;}
-keep class com.huawei.hms.maps.HuaweiMapOptions{*;}
-keep interface org.xms.g.maps.OnMapReadyCallback{*;}
-keep interface com.huawei.hms.maps.OnMapReadyCallback{*;}
-keep class org.xms.g.maps.StreetViewPanoramaOptions{*;}
-keep class com.huawei.hms.maps.OnStreetViewPanoramaReadyCallback{*;}
-keep interface org.xms.g.maps.OnStreetViewPanoramaReadyCallback{*;}
-keep interface com.huawei.hms.maps.OnStreetViewPanoramaReadyCallback{*;}
-keep class com.huawei.hms.dynamicloader.** { *; }
-keep class com.huawei.hms.feature.dynamic.** {*;}
-keep class com.huawei.hms.feature.** { *;}
# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
# EnclosingMethod is required to use InnerClasses.
-keepattributes Signature, InnerClasses, EnclosingMethod
# Retrofit does reflection on method and parameter annotations.
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
# Retain service method parameters when optimizing.
-keepclassmembers,allowshrinking,allowobfuscation interface * {
@retrofit2.http.* <methods>;
}
# Ignore annotation used for build tooling.
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
# Ignore JSR 305 annotations for embedding nullability information.
-dontwarn javax.annotation.**
# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
-dontwarn kotlin.Unit
# Top-level functions that can only be used by Kotlin.
-dontwarn retrofit2.KotlinExtensions
-dontwarn retrofit2.KotlinExtensions$*
# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy
# and replaces all potential values with null. Explicitly keeping the interfaces prevents this.
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>
# Platform calls Class.forName on types which do not exist on Android to determine platform.
-dontnote retrofit2.Platform
# Platform used when running on Java 8 VMs. Will not be used at runtime.
-dontwarn retrofit2.Platform$Java8
# For OkHttp 3.x
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
# crashlytics
-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**
-keep class com.pushwoosh.** { *; }
-dontwarn com.pushwoosh.**
-keep class pushwooshnotification.PushwooshNotificationService {*;}
-keep class kotlin.** { *; }
此问题现已在最新版本的dex-guard.9.3.3
中修复
当我升级到依赖项的版本以下并且启用了pro-guard时,我的项目中也有类似的问题。我尝试了很多方法来解决这个问题,但最终,当启用pro-guard时,这个库的新版本似乎有任何问题。
因此,我必须降低依赖'androidx.preference:preference-ktx:$version'
的版本
1.1.1版本对我来说很有效,解决了这个问题。
希望它也能解决你的问题!!
您是否可以尝试使用元数据保留所有类
-keep class androidx.window.layout.SidecarCompat {
*;
}
-keepkotlinmetadata