6

There is method called onDelete in a Kotlin class.

override fun onDelete(position: Int) {
    templates?.apply {
         val deleteDialog = DeleteTemplateDialog(view.getViewContext())
            deleteDialog.confirmListener = {
                CustomTemplateRepository.getInstance().deleTemplate(this[position].templateId!!)
                        .subscribe({
                            deleteDialog.dismiss()
                            this.removeAt(position)
                            customTemplateAdapter?.notifyDataSetChanged()
                            view.showEmptyView(this.isEmpty())
                        }, {})
            }
    }
}

When I build release-apk, I enable proguard but it failed because of below warning.

Warning: com.uniquestudio.android.iemoji.module.library.customtemplate.MyTemplatePresenter$onDelete$1$1$2: can't find referenced class com.uniquestudio.android.iemoji.module.library.customtemplate.MyTemplatePresenter$onDelete$1$1

When I use dex2jar to retrieve this class from debug-APK. I got this.

public void onDelete(final int paramInt)
{

    final DeleteTemplateDialog localDeleteTemplateDialog = new DeleteTemplateDialog(this.view.getViewContext());
    localDeleteTemplateDialog.setConfirmListenner((Function0)new Lambda(localArrayList)
    {
    public final Disposable invoke()
    {
        CustomTemplateRepository localCustomTemplateRepository = CustomTemplateRepository.Companion.getInstance();
        String str = ((Template)this.receiver$0.get(paramInt)).getTemplateId();
        if (str == null) {
        Intrinsics.throwNpe();
        }
        localCustomTemplateRepository.deleTemplate(str).subscribe((Action)new Action()
        {
        public final void run()
        {
            this.this$0.$deleteDialog.dismiss();
            this.this$0.receiver$0.remove(this.this$0.$position$inlined);
            CustomTemplateAdapter localCustomTemplateAdapter = MyTemplatePresenter.access$getCustomTemplateAdapter$p(this.this$0.this$0);
            if (localCustomTemplateAdapter != null) {
            localCustomTemplateAdapter.notifyDataSetChanged();
            }
            this.this$0.this$0.getView().showEmptyView(this.this$0.receiver$0.isEmpty());
        }
        }, (Consumer)MyTemplatePresenter.onDelete.1.1.2.INSTANCE);
    }
    });
}

I don't know:

  • Who is com.uniquestudio.android.iemoji.module.library.customtemplate.MyTemplatePresenter$onDelete$1$1$2
  • Who is com.uniquestudio.android.iemoji.module.library.customtemplate.MyTemplatePresenter$onDelete$1$1
  • Why the first can't find referenced class
Marit
  • 2,399
  • 18
  • 27
CoXier
  • 2,523
  • 8
  • 33
  • 60
  • 1
    Did you tried "-dontwarn", like here: https://stackoverflow.com/a/7003061/1438493 ? Seems like similar problem. – thorin86 Oct 16 '18 at 21:51
  • 1
    Can you add your proGuard configuration? It seems like it may be minifying the class or method names, then the code is not able to find them. – Eric Martori Oct 18 '18 at 09:24
  • To get more information about the classes structure you could have a look within your build folder. There you should find these classes. I think `MyTemplatePresenter$onDelete$1$1$2` is the error consumer `{}` and therefore `MyTemplatePresenter$onDelete$1$1` should be the confirmation listener. – tynn Oct 21 '18 at 07:18

1 Answers1

2

Seems to be a kotlin issue, the issue can be watched here: https://youtrack.jetbrains.com/issue/KT-16084

Rewrite the apply and everything should work...

prom85
  • 16,896
  • 17
  • 122
  • 242