4

I'm attempting to generate a signed APK and receiving the following error:

Error:(59, 44) AppCompatButton.setSupportBackgroundTintList can only be called from within the same library group (groupId=com.android.support)

Since the last time I've done so, AppCompatButton.setSupportBackgroundTintList has been annotated with @RestrictTo(LIBRARY_GROUP).

When trying to generate the APK, lint flags this as an error. I've read this question and its answers, however, suppressing the lint analysis still does not allow me to generate an APK, generating the same error as above.

So, I changed the call to conform with the new preferred way of making compat calls: ViewCompat.setBackgroundTintList(view, tintList). Unfortunately, this change still does not allow me to generate a signed APK, generating the same error as above.

Android Studio version 3.1
Build tools version 27.0.3
Gradle wrapper version gradle-4.5.1-all
Android gradle build tools version 3.1.0

What am I missing?

Edit

Well, this is weird and pretty embarrassing. Apparently, when I updated Android Studio and imported my settings, it allowed itself to continue displaying a now deprecated Messages window. This window wasn't receiving messages being generated by the build output. After investigating further, I found that Messages output is now in the new Build window. After checking that output, it seems my problem was something else entirely.

The solution for @RestrictTo(LIBRARY_GROUP) continues to be using the appropriate compat call.

nukeforum
  • 1,284
  • 3
  • 16
  • 38
  • 2
    Do you mean [`setBackgroundTintList()`](https://developer.android.com/reference/android/support/v4/view/ViewCompat.html#setBackgroundTintList(android.view.View,%20android.content.res.ColorStateList)), instead of `setSupportBackgroundTintList()`? – CommonsWare Mar 30 '18 at 17:33
  • No, I need to support API prior to 21 when `setBackgroundTintList()` was added. **edit**: scratch that, I see what you meant. The code is correct, I just mistyped – nukeforum Mar 30 '18 at 17:34
  • OK, just checking. So, you're getting this error now for that `ViewCompat.setBackgroundTintList()` call? Or are you getting that error for some new problem? Also, what version of the Support Libraries are you using? – CommonsWare Mar 30 '18 at 17:37
  • Actually, bizarrely, it's giving me the error on the line before the one containing `ViewCompat.setBackgroundTintList()`. That line contains `view.setEnabled(false)` – nukeforum Mar 30 '18 at 17:39
  • That feels like the build system is looking at some code that is different than what you're editing. – CommonsWare Mar 30 '18 at 17:40
  • 1
    I thought the same thing, so I've done a clean, invalidate cache and restart, and I've double-checked the directories. I can't find anything pointing to an out-of-date file. – nukeforum Mar 30 '18 at 17:41
  • The error message still refers to `AppCompatButton.setSupportBackgroundTintList()`? Are you referencing that anywhere else? – CommonsWare Mar 30 '18 at 17:44
  • It does, and I am not. The error points specifically to the file I've fixed, and the line just before the line where the error used to point to. I can attach some screenshots if that helps. – nukeforum Mar 30 '18 at 17:46
  • 1
    I don't think screenshots will help me personally, though it might help others encountering your question. Frankly, right now, I'm stumped. Sorry! – CommonsWare Mar 30 '18 at 17:51
  • Well, I appreciate you checking my sanity, even though we couldn't solve it. :) – nukeforum Mar 30 '18 at 17:52
  • @CommonsWare so, this ended up being an embarrassing issue. But I thought you'd be interested in knowing what happened (I put it in my edit). – nukeforum Mar 30 '18 at 19:29
  • Glad that you got to the bottom of it! – CommonsWare Mar 30 '18 at 19:32

0 Answers0