Fixed
Status Update
Comments
do...@traveloka.com <do...@traveloka.com> #2
There are similar issue with this:
adding
```#-keep class android.support.v4.** { *; }
#-keep interface android.support.v4.** { *; }```
on consumer proguard that not using androidx, enable jetifier on your project, the proguard.txt from that library will adding new rules:
```-keep class androidx.** { *; }
-keep interface androidx.** { *; }```
adding
```#-keep class android.support.v4.** { *; }
#-keep interface android.support.v4.** { *; }```
on consumer proguard that not using androidx, enable jetifier on your project, the proguard.txt from that library will adding new rules:
```-keep class androidx.** { *; }
-keep interface androidx.** { *; }```
pa...@gmail.com <pa...@gmail.com> #3
It doesn't even have to be a ProGuard rule, simply following comments on separate lines are parsed as part of the rule and interpreted as regex.
We have this coming from a consumer proguard file in an AAR:
```proguard
# OkHttp platform used only on JVM and when Conscrypt dependency is available.
# OkHttp's ProGuard rules only suppress the main ConscryptPlatform class, let's also suppress its inner classes
-dontwarn okhttp3.internal.platform.ConscryptPlatform$*
# R8 Shrinker
# AGPBI: {"kind":"warning","text":"Missing class: org.conscrypt.ConscryptHostnameVerifier","sources":[{}],"tool":"D8"}
-dontwarn org.conscrypt.ConscryptHostnameVerifier
```
The exception is:
```
Caused by: java.util.regex.PatternSyntaxException: Illegal repetition near index 72
okhttp3/internal/platform/ConscryptPlatform$[^/]*
# R8 Shrinker
# AGPBI: {"kind":"warning"
^
```
If we account for newlines as characters and use a fixed width font, the ^ pointer is pointing at {"kind" where " is not a number as expected by the {N} repetition operator.
I hacked the AAR file in Gradle caches:
Tried adding an empty line between the rule and the comment, but didn't help, but
```diff
-# AGPBI: {"kind":"warning","text":"Missing class: ...
+# AGPBI: \{"kind":"warning","text":"Missing class: ...
```
works.
Since we can't change the Gradle caches on all machines this is a blocker for using Jetifier.
We have this coming from a consumer proguard file in an AAR:
```proguard
# OkHttp platform used only on JVM and when Conscrypt dependency is available.
# OkHttp's ProGuard rules only suppress the main ConscryptPlatform class, let's also suppress its inner classes
-dontwarn okhttp3.internal.platform.ConscryptPlatform$*
# R8 Shrinker
# AGPBI: {"kind":"warning","text":"Missing class: org.conscrypt.ConscryptHostnameVerifier","sources":[{}],"tool":"D8"}
-dontwarn org.conscrypt.ConscryptHostnameVerifier
```
The exception is:
```
Caused by: java.util.regex.PatternSyntaxException: Illegal repetition near index 72
okhttp3/internal/platform/ConscryptPlatform$[^/]*
# R8 Shrinker
# AGPBI: {"kind":"warning"
^
```
If we account for newlines as characters and use a fixed width font, the ^ pointer is pointing at {"kind" where " is not a number as expected by the {N} repetition operator.
I hacked the AAR file in Gradle caches:
Tried adding an empty line between the rule and the comment, but didn't help, but
```diff
-# AGPBI: {"kind":"warning","text":"Missing class: ...
+# AGPBI: \{"kind":"warning","text":"Missing class: ...
```
works.
Since we can't change the Gradle caches on all machines this is a blocker for using Jetifier.
pa...@gmail.com <pa...@gmail.com> #4
(Sidenote: even if the comments were not part of that regex, the $ sign is in the middle of the text and matches end of string, so anything afterwards will fail the match.)
ga...@google.com <ga...@google.com> #5
Filip, can you please take a look?
pa...@google.com <pa...@google.com> #6
Thanks for the detailed examples and repro steps. This was due to the matcher od "dontwarn" being to relaxed and consuming also new lines and comments.
Pending cl with fix is here:
https://android-review.googlesource.com/c/platform/frameworks/support/+/1151458
The fix will be available once we release new jetifier which should be in few weeks at most. Sorry for troubles.
Pending cl with fix is here:
The fix will be available once we release new jetifier which should be in few weeks at most. Sorry for troubles.
ap...@google.com <ap...@google.com> #7
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 0ca83fae309187d476d8e5baa59d7e0f33c6f8d8
Author: Filip Pavlis <pavlis@google.com>
Date: Fri Oct 25 16:34:14 2019
Fix proguard regular expression.
The matcher in dontwarn was too hungry and was also matching new
lines and comments.
Also make sure we don' match comments in ProGuardClassSpecParser.
Test: Added
Bug: b/134100420
Change-Id: I77cf40dd880b5bee9a30dad82c82dc1fa5a71aa9
M jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/proguard/ProGuardClassFilterParser.kt
M jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/proguard/ProGuardClassSpecParser.kt
M jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/proguard/patterns/PatternHelper.kt
M jetifier/jetifier/processor/src/test/kotlin/com/android/tools/build/jetifier/processor/transform/proguard/ClassFilterTest.kt
M jetifier/jetifier/processor/src/test/kotlin/com/android/tools/build/jetifier/processor/transform/proguard/ProguardSamplesTest.kt
https://android-review.googlesource.com/1151458
https://goto.google.com/android-sha1/0ca83fae309187d476d8e5baa59d7e0f33c6f8d8
Branch: androidx-master-dev
commit 0ca83fae309187d476d8e5baa59d7e0f33c6f8d8
Author: Filip Pavlis <pavlis@google.com>
Date: Fri Oct 25 16:34:14 2019
Fix proguard regular expression.
The matcher in dontwarn was too hungry and was also matching new
lines and comments.
Also make sure we don' match comments in ProGuardClassSpecParser.
Test: Added
Bug:
Change-Id: I77cf40dd880b5bee9a30dad82c82dc1fa5a71aa9
M jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/proguard/ProGuardClassFilterParser.kt
M jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/proguard/ProGuardClassSpecParser.kt
M jetifier/jetifier/processor/src/main/kotlin/com/android/tools/build/jetifier/processor/transform/proguard/patterns/PatternHelper.kt
M jetifier/jetifier/processor/src/test/kotlin/com/android/tools/build/jetifier/processor/transform/proguard/ClassFilterTest.kt
M jetifier/jetifier/processor/src/test/kotlin/com/android/tools/build/jetifier/processor/transform/proguard/ProguardSamplesTest.kt
pa...@google.com <pa...@google.com> #8
Jetifier 1.0.0-beta08 was released and has a fix for this.
To avoid waiting for new Android Studio you can workaround this in the meantime by forcing usage of a new version of jetifier in gradle:
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:x.y.z'
classpath 'com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta08' // <- Add this
}
}
To avoid waiting for new Android Studio you can workaround this in the meantime by forcing usage of a new version of jetifier in gradle:
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:x.y.z'
classpath 'com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta08' // <- Add this
}
}
pa...@gmail.com <pa...@gmail.com> #9
Thanks pa..., it's really nice to receive updates and useful details (root cause, CL, workaround) about the issue. I wish everyone was like this!
Description
Java version "1.8.0_121"
Jetifier version: 1.0.0-beta04
Let there be a Library Foo with the following 'proguard-rules.txt' file:
# DBFlow
-keep class * extends com.raizlabs.android.dbflow.config.DatabaseHolder { *; }
-dontwarn com.raizlabs.android.dbflow.**
# Note: the configuration keeps the entry point 'com.raizlabs.android.dbflow.config.FlowManager$GlobalDatabaseHolder { FlowManager$GlobalDatabaseHolder(com.raizlabs.android.dbflow.config.FlowManager$1); }', but not the descriptor class 'com.raizlabs.android.dbflow.config.FlowManager$1'
-keep class com.raizlabs.android.dbflow.config.FlowManager$*
When trying to jetify this library:
./jetifier-standalone -i /Users/someuser/Downloads/foo/foo.aar -o newfoo.aar
The Jetifier fails with the following output:
Exception in thread "main" java.util.regex.PatternSyntaxException: Illegal repetition near index 147
com/raizlabs/android/dbflow/.*
# Note: the configuration keeps the entry point 'com/raizlabs/android/dbflow/config/FlowManager$GlobalDatabaseHolder { FlowManager$GlobalDatabaseHolder(com/raizlabs/android/dbflow/config/FlowManager$1); }'
^
at java.util.regex.Pattern.error(Pattern.java:1955)
at java.util.regex.Pattern.closure(Pattern.java:3157)
at java.util.regex.Pattern.sequence(Pattern.java:2134)
at java.util.regex.Pattern.expr(Pattern.java:1996)
at java.util.regex.Pattern.compile(Pattern.java:1696)
at java.util.regex.Pattern.<init>(Pattern.java:1351)
at java.util.regex.Pattern.compile(Pattern.java:1028)
at com.android.tools.build.jetifier.core.type.TypesMap.matchOldProguardForNewTypes(TypesMap.kt:112)
[...]
If i remove the notes, the new 'proguard-rules.txt' looks like this:
# DBFlow
-keep class * extends com.raizlabs.android.dbflow.config.DatabaseHolder { *; }
-dontwarn com.raizlabs.android.dbflow.**
-keep class com.raizlabs.android.dbflow.config.FlowManager$*
And this runs through the jetifier just fine. Please provide a fix for this issue, since i have to patch my dependencies currently in order to make AndroidX work for me.