Android Proguard - how to keep onClick handlers only referenced from XML layouts

前端 未结 3 1623
温柔的废话
温柔的废话 2021-01-11 10:47

In my Android app I ofter don\'t create a View\'s on-click handler in code, but rely on the ability to specify it in the XML layout file, like this:

   

        
3条回答
  •  抹茶落季
    2021-01-11 11:38

    This seems to be the best answer, as it is 100% robust to naming of such methods:

    # This will avoid all the onClick listeners referenced from XML Layouts from being removed
    -keepclassmembers class * extends android.app.Activity { 
           public void *(android.view.View); 
    }
    

    Hope it helps.

提交回复
热议问题