getOpenSourceSoftwareLicenseInfo is returning null now

£可爱£侵袭症+ 提交于 2019-12-12 07:49:22

问题


A trivial but annoying issue has come up in the last few days. Previously my menu option which popped up a dialog to show the legal text for using Google Services was very full (if a little slow to load), but now it is null with no change to the code..

GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
        int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
        if (resultCode == ConnectionResult.SUCCESS) {
            AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
            builder.setTitle("About");
            builder.setMessage(apiAvailability.getOpenSourceSoftwareLicenseInfo(this));
            builder.setPositiveButton("OK", null);
            builder.show();

        }

Is this a problem common to others, i.e. a new bug introduced by a Google update or some other possibility?


回答1:


according to https://code.google.com/p/gmaps-api-issues/issues/detail?id=9813

It appears that google changed the file name it was looking for from oss_notice to third_party_licenses. They basically broke getting the license info for any play services implementation below 9.0.0.

you will need to update the version to 9.0.0 to get the license info back for device with later versions of play services.

EDIT (June 6, 2016): Google is looking into the issue now.

Project Member #3 l...@google.com

Thanks for the reports. We've filed this internally and will look into it.

Status: Accepted Labels: Internal-29143355




回答2:


Yes, upgrading Google Play Services to last version (9.0.0 at time of writing this answer) solves the issue.

I had the same problem and after upgrading Google Play Services I started getting the licenses properly.




回答3:


If you're maintaining an old app and can't reasonably update from a very old version of Google Play Services without breaking a whole lot of ancient features, there's a viable workaround:

Decompile the getOpenSourceSoftwareLicenseInfo() method with Android Studio, copy the method into your project, and change the line to point from "oss_notice" to "third_party_licenses".

    Uri var1 = (new android.net.Uri.Builder()).scheme("android.resource").authority("com.google.android.gms").appendPath("raw").appendPath("oss_notice").build();

to

    Uri var1 = (new android.net.Uri.Builder()).scheme("android.resource").authority("com.google.android.gms").appendPath("raw").appendPath("third_party_licenses").build();



回答4:


This method has been deprecated and is no longer necessary: https://developers.google.com/android/reference/com/google/android/gms/common/GooglePlayServicesUtil.html#getOpenSourceSoftwareLicenseInfo(android.content.Context)

This license information is displayed in Settings > Google > Open Source on any device running Google Play services. Applications do not need to display this license text, and this method will be removed in a future version of Google Play services.

👍



来源:https://stackoverflow.com/questions/37273810/getopensourcesoftwarelicenseinfo-is-returning-null-now

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!