Unresolved class name proguard-rules Android Studio 4.0
Asked Answered
H

6

68

When I update to Android Studio 4.0 proguard-rules it shows warning Unresolved class name. Below is example but I sure it still waring the exist class in my project.

-keep class com.squareup.haha.** { *; }
-keep class com.squareup.leakcanary.** { *; }

If I change from ** to * this warning is gone.

-keep class com.squareup.haha.* { *; }
-keep class com.squareup.leakcanary.* { *; }

Does anyone get this? Should I ignore this warning or it's bug of Android Studio 4.0?

Update

I find it's bug, it already assigned but not resolved https://issuetracker.google.com/issues/153616200

Update July

Google team already analysis and increase priory of this bug, it may be related to a newer version of R8.

Update August

Fixed in AS 4.2 Canary 9

Hamil answered 29/5, 2020 at 6:45 Comment(1)
add it as an answer and mark it as acceptedBuettner
S
17

Check this issue: https://issuetracker.google.com/issues/147802433

`If you right-click on error, there is option "suppress for statement", after that AS adds a comment such as:

noinspection ShrinkerUnresolvedReference

-keep class not.existing

And with this comment there is no error for "not.existing".`

enter image description here

Speedboat answered 29/5, 2020 at 7:34 Comment(1)
Actually we only need noinspection when the library change and the class doesn't exits but some class and model is exits but android studio 4.0 still said it's unresolved. I think it should be bug instead of fix by "suppress for statement"Krein
K
11

Replace .** with ** as workaround. No compile error and classes are kept.

-keep class com.squareup.haha** { *; }
-keep class com.squareup.leakcanary** { *; }

enter image description here

Kettledrum answered 24/1, 2021 at 9:13 Comment(0)
R
3

This issue is fixed in Android Studio 4.2 Canary 8. Please find the release notes here https://androidstudio.googleblog.com/2020/08/android-studio-42-canary-8-available.html and check for this issue id #153616200

Retrieval answered 26/10, 2020 at 13:26 Comment(0)
T
1

A folder and its subfile. I have tested this:

com.xx.xx.* { *; }   

I guess that it may contain multiply folders and subfile. I've not tested this:

com.xx.xx.**.* {*;}   
Throw answered 10/8, 2020 at 14:10 Comment(0)
M
1

All of these answers are mere non-sense because:

LeakCanary is being added as debugImplementation.

  • it makes no sense to have rules for classes which do not exist in release builds.
  • it makes even less sense to obfuscate debug builds.

In case you may require any of these rules, you've added it to the wrong build-type.

Mcvey answered 24/1, 2021 at 9:26 Comment(0)
H
0

replace

.**

with

.*.*

result

-keep class com.squareup.haha.*.* { *; }
-keep class com.squareup.leakcanary.*.* { *; }
Hessite answered 18/6, 2020 at 13:59 Comment(4)
This is not solution dear, you can also use by remove single star ** replace with *, but this is not a solution this bugMalachi
this works. unresolved class name errors now disappear.Fischer
.** means the directory and all subdirectories, recursive. .*.* means the directory and its immediate subdirectories only. They are not equivalentOfficial
It's not a solution. If a traffic light is stuck on red, you can fix it by making it hang on orange or green instead. Nobody will complain (for a while), but it isn't fixed. On some junctions it might work, on others you'll cause crashes.Hewitt

© 2022 - 2024 — McMap. All rights reserved.