需要类型和名称,而不仅仅是“setExtensionCallback”

发布于 2025-01-10 03:05:26 字数 4071 浏览 1 评论 0原文

我正在尝试为我的应用程序生成签名的 apk,但失败并出现错误期望类型和名称,而不是文件“pathtofile\release\consumer-rules.pro”第 326 行中的“(”之前的“setExtensionCallback”,< /代码> 我不确定是什么原因造成的,也没有任何进一步的信息或任何详细报告。这是 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.** { *; }

I am trying to generate signed apk for my application but it fails with error Expecting type and name instead of just 'setExtensionCallback' before '(' in line 326 of file 'pathtofile\release\consumer-rules.pro',
I am not sure what is causing and there is no any further information or any detail report about it. This is line 325 and 326 of consumer-rules.pro-

-if class androidx.window.layout.SidecarCompat {
  public setExtensionCallback(androidx.window.layout.ExtensionInterfaceCompat$ExtensionCallbackInterface);
}

I am using dexguard for this. It was working few days back but stopped suddenly.

Here is dexguard-project.txt file.

# 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.** { *; }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

初见 2025-01-17 03:05:26

此问题现已在最新版本的 dex-guard.9.3.3 中修复

This issue is now fixed in latest version of dex-guard.9.3.3

つ低調成傷 2025-01-17 03:05:26

当我升级到低于依赖项的版本并且启用了 pro-guard 时,我的项目中也遇到了类似的问题。我尝试了很多方法来解决这个问题,但最后看来,当启用 pro-guard 时,这个库的新版本存在任何问题。

因此,我必须降级依赖项 'androidx.preference:preference-ktx:$version'

Version 1.1.1 的版本,因为此依赖项对我有用并解决了问题。

希望它也能解决您的问题!

I have similar issue in my project when I have upgraded below dependency's version and when the pro-guard is enabled. I have tried many approaches to solve this issue, but at-last it seems like there's any issue with this library's new version when pro-guard is enabled.

So, I have to degrade the version of dependency 'androidx.preference:preference-ktx:$version'

Version 1.1.1 for this dependency has worked for me and solved the issue.

Hope it solves your issue too!!

还给你自由 2025-01-17 03:05:26

你能尝试保留所有类的元数据吗

-keep class androidx.window.layout.SidecarCompat {
 *;
 }
-keepkotlinmetadata

can you try to keep all the class with metadata

-keep class androidx.window.layout.SidecarCompat {
 *;
 }
-keepkotlinmetadata
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文