I have added in my app Kotlin support for existing app
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.10"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.1'
I have tried adding those proguard rules :
-dontwarn kotlin.
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}
-keepclassmembernames class kotlinx. { *; }
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
static void checkParameterIsNotNull(java.lang.Object, java.lang.String);
}
i have tried to remove those rules too, but everytime proguard throw exception :
Warning: Exception while processing task java.io.IOException: java.util.EmptyStackException
Thread(Tasks limiter_5): destruction
Task :app:transformClassesAndResourcesWithProguardForRelease FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
Job failed, see logs for detail
I am using latest proguard beta. Not using rxjava or any other starnge libraries.
Just android and kotlin
why i this happening ?
With the gradle option --info --stacktrace, you should get more information about the crash. That may not be sufficient though. Do you have a small sample project that reproduces the issue?
I don't know why but it is solved by using :
-dontwarn kotlin.
-keepclassmembernames class kotlin. { ; }
-assumenosideeffects class kotlin.jvm.internal.Intrinsics { static void checkParameterIsNotNull(java.lang.Object, java.lang.String); }
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}
-keepclassmembernames class kotlinx.* { volatile <fields>; }</fields>
if remove this line -keepclassmembernames class kotlin.* { ; } it will throw exception.
Kotlin doesn't say to use this config in official doc.
This is the problem :
FAILURE: Build failed with an exception.
I don't know why but the issue doesn't happen if add this rule :
-keepclassmembernames class kotlin.** { public <methods>; }
I am using :
FYI, I was using Proguard 6.0.3 on my Android java projects (no kotlin).
Then I updated some dependencies and Proguard 6.0.3 was hanging probably because of https://github.com/square/okio/issues/516 )
So I bumped to Proguard 6.1.1 and now I have this very same bug.
As Emin Kokalari, I added
and the problem is now solved.
FYI, dependencies:
Would this be okhttp / retrofit that causes this issue by bringing some kotlin in the game?
Possibly through this path up to okio and then kotlin? (version numbers are not correct/checked: I just copied this from another dependenciy tree)
Last edit: Pascal Dal Farra 2019-09-06
Hello. Any news on this issue?
I'm still able to reproduce it on newest Kotlin 1.3.50 + Proguard 6.2.0 in Android project.
Also, usage of AspectJ leads to same problems.
Ignore Koltin classed is not an option for performance reason of our project.
There is a way to debug ProGuard someway to find where the issue exact.
Thanks.
We have the same issue with Kotlin 1.3.60 + proguard 6.2.0
This patch fixes the issue. We need check that stack is not empty like few lines above.
--- core/src/proguard/obfuscate/MappingPrinter.java
+++ core/src/proguard/obfuscate/MappingPrinter.java
@@ -230,7 +230,9 @@
{
// When exiting a top-level inlined block, the source might be null.
// See LineNumberLinearizer, line 185, exiting an inlined block.
- enclosingLineNumbers.pop();
+ if (!enclosingLineNumbers.isEmpty()) {
+ enclosingLineNumbers.pop();
+ }
}
But also seems that some logic is missed here and we should not receive such error.
I beleive that error occurs after inlined method lines printing was added in ProGuard 6.1.
Last edit: zyz36134 2019-11-28
This problem has been fixed and will be included in the upcoming release 6.2.1.