Recently upgrading Google API versions from 11.8.0 to 12.0.1 resulted in task.result.release()
in my completion listener from Task<AutocompletePredictionBufferResponse>
being marked as internal.
Should I handle the possibility of an internal data leak differently? Does the Google Places API now handle releasing the result itself? I cannot find information about this in the release notes for 12.0.0 or 12.0.1. The current documentation still says you must release the result.
Here is where I use it:
.addOnCompleteListener { task: Task<AutocompletePredictionBufferResponse> ->
if (task.isSuccessful) {
{...}
//Release to avoid internal data leak
task.result.release()
} else {
Log.e("AutoCompletePredictions", task.exception?.message)
//Release to avoid internal data leak
task.result.release()
}
}
.addOnFailureListener(this@NewLocationActivity) {
Log.e("AutoCompletePredictions", it.message)
}
This is the error message I am receiving:
zzb.release is marked as internal and should not be accessed from apps less... (⌘F1) This API has been flagged with a restriction that has not been met. Examples of API restrictions: * Method can only be invoked by a subclass * Method can only be accessed from within the same library (defined by the Gradle library group id) .* Method can only be accessed from tests. . You can add your own API restrictions with the @RestrictTo annotation.
The full getSuggestions()
method in which I use the completion listener
private fun getSuggestions() {
val filter = AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS)
.setCountry(CountryManager.getCountryISO())
.build()
Places.getGeoDataClient(this@NewLocationActivity/*, null*/) // uncomment for v11.8.0
.getAutocompletePredictions(
activity_new_location_edit_text.text.toString(),
null,
filter
)
.addOnCompleteListener { task: Task<AutocompletePredictionBufferResponse> ->
if (task.isSuccessful) {
val addressList: ArrayList<String> = arrayListOf()
var index = 0
for(item in task.result) {
if(index >= MAX_SUGGESTION_RESULTS)
break
addressList.add(item.getFullText(null).toString())
index++
}
if(!(addressList.size == 1 && addressList[0] == activity_new_location_edit_text.text.toString()))
loadGoogleAddressesIntoSuggestionList(addressList)
//Release to avoid internal data leak
task.result.release()
} else {
Log.e("AutoCompletePredictions", task.exception?.message)
//Release to avoid internal data leak
task.result.release()
}
}
.addOnFailureListener(this@NewLocationActivity) {
Log.e("AutoCompletePredictions", it.message)
}
}
Seems like an unintended change.
It started in 12.0.0, that has the following "known issue" in its release notes:
An annotation causes spurious lint errors claiming
GoogleSignIn
andCredentialsClient
are internal-only. These can safely be ignored.
Guess they weren't only for GoogleSignIn
and CredentialsClient
, but they fixed only those in 12.0.1:
Fixes issue that caused spurious Android lint errors claiming
GoogleSignIn
andCredentialsClient
were internal-only.
The corresponding source code of release()
appears to be the same across versions 11.8.0-12.0.1, so i believe you can safely ignore these warnings.