Google服务封装好的sdk地址
https://github.sheincorp.cn/googleapis/google-api-java-client-services/tree/main/clients
Google服务使用之前得先认证
implementation 'com.google.auth:google-auth-library-oauth2-http:1.19.0'
基础使用方法
public class GooglePlayDeveloperAPI {
private static final String API_KEY = "api-xxxxx-xxxxx.json";
public static void main(String[] args) {
try {
GoogleCredentials credentials = GoogleCredentials.fromStream(new FileInputStream(API_KEY))
.createScoped(PlaydeveloperreportingScopes.all());
credentials.refreshIfExpired();
AccessToken token = credentials.getAccessToken();
HttpRequestInitializer requestInitializer = httpRequest -> {
//jwt认证
httpRequest.getHeaders().setAuthorization("Bearer " + token.getTokenValue());
};
//选择的Google服务库
Playdeveloperreporting build = new Playdeveloperreporting.Builder(new NetHttpTransport(), GsonFactory.getDefaultInstance(), requestInitializer).setApplicationName("应用包名").build();
GooglePlayDeveloperReportingV1beta1AnrRateMetricSet execute = build.vitals().anrrate().get("apps/应用包名/anrRateMetricSet").execute();
System.out.println(execute);
} catch (Exception e) {
e.printStackTrace();
}
}
}