简体   繁体   中英

“can't find referenced class” with Proguard and Kotlin

I am having a strange problem with proguard and kotlin. I am gradually converting a proguarded project to kotlin - which went very fine so far but I am getting proguard errors when converting certain classes. I could not yet isolate what the special property of these classes is so it breaks - they seems to be no different than the other ones. As an example InputStreamWithSource is just:

package org.ligi.passandroid.model

import java.io.InputStream

class InputStreamWithSource(val source: String, val inputStream: InputStream)

and it completely works in the IDE - I can deploy to a device - also all UI tests are running fine. Just when trying to assembleRelease the project I am getting proguard errors I do not understand:

Warning: org.ligi.passandroid.ui.FileUnzipControllerSpec: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.FileUnzipControllerSpec: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.InputStreamProvider: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.InputStreamProvider: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.InputStreamProvider: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.InputStreamProvider: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.InputStreamProvider: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.InputStreamProvider: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.PassImportActivity$ImportAndShowAsyncTask: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.PassImportActivity$ImportAndShowAsyncTask: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.PassImportActivity$ImportAndShowAsyncTask: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.PassImportActivity$ImportAndShowAsyncTask: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.PassImportActivity$ImportAndShowAsyncTask: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.PassViewActivityBase$UpdateAsync: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.PassViewActivityBase$UpdateAsync: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.PassViewActivityBase$UpdateAsync: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.SearchPassesIntentService: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.UnzipPassController: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.UnzipPassController: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.UnzipPassController$InputStreamUnzipControllerSpec: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.UnzipPassController$InputStreamUnzipControllerSpec: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.UnzipPassController$InputStreamUnzipControllerSpec: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.UnzipPassController$InputStreamUnzipControllerSpec: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.UnzipPassDialog: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.UnzipPassDialog: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.UnzipPassDialog$1AlertDialogUpdater: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource
Warning: org.ligi.passandroid.ui.UnzipPassDialog$1AlertDialogUpdater: can't find referenced class org.ligi.passandroid.model.InputStreamWithSource

when I add a dontwarn for these classes in the proguard configuration than it crashes at runtime - so these classes are really removed - but they should not be removed as they are used.

I can work around this problem by adding keep class/enum for these classes in the proguard-config - but the question is why this is needed for these classes - IMHO it should not be needed

Anyone has some Idea what could cause this or how best to investigate this problem? The full source is here: https://github.com/ligi/PassAndroid

I would make sure that I have my own package defined in proguard - something like this:

-dontwarn org.ligi.passandroid.**
-keep class org.ligi.passandroid.** { *; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM