Android 初始化器错误中的YouTube API异常

Android 初始化器错误中的YouTube API异常,android,youtube-api,Android,Youtube Api,所以在过去的几个月里,我一直在Android Studio中成功地使用YouTube API。我去更新我的应用程序,从今天开始,当它试图初始化YouTube builder时,应用程序一直崩溃。还有其他人遇到过这个问题吗 mYoutubeDataApi = new YouTube.Builder(mTransport, mJsonFactory, null) .setApplicationName(getResources().ge

所以在过去的几个月里,我一直在Android Studio中成功地使用YouTube API。我去更新我的应用程序,从今天开始,当它试图初始化YouTube builder时,应用程序一直崩溃。还有其他人遇到过这个问题吗

mYoutubeDataApi = new YouTube.Builder(mTransport, mJsonFactory, null)
                                .setApplicationName(getResources().getString(R.string.app_name))
                                .build();
应用程序因以下输出而崩溃:

2019-12-09 01:38:06.443 17937-17937/ E/AndroidRuntime: FATAL EXCEPTION: main

    java.lang.ExceptionInInitializerError
        at com.google.api.services.youtube.YouTube.<clinit>(YouTube.java:44)
        at com.google.api.services.youtube.YouTube$Builder.build(YouTube.java:16644)

在1.30.6中,他们添加了以下内容:

要修复此问题,请将build.gradle编辑回1.30.5

dependencies {
  implementation ('com.google.api-client:google-api-client:1.30.5')
  implementation ('com.google.api-client:google-api-client-android:1.30.5')
}
如果有更好的解决办法,我很想听

为了进一步解释为什么1.30.6中的更改会导致崩溃,这里有一些更多的信息

具体而言,问题来自此文件:


据推测,getVersion将返回null,尽管我无法解释原因。鉴于我最近在2-3天前也遇到了这种情况,我们更新的某些内容肯定是相互矛盾的

在1.30.6中,他们添加了以下内容:

要修复此问题,请将build.gradle编辑回1.30.5

dependencies {
  implementation ('com.google.api-client:google-api-client:1.30.5')
  implementation ('com.google.api-client:google-api-client-android:1.30.5')
}
如果有更好的解决办法,我很想听

为了进一步解释为什么1.30.6中的更改会导致崩溃,这里有一些更多的信息

具体而言,问题来自此文件:


据推测,getVersion将返回null,尽管我无法解释原因。鉴于我最近在2-3天前也遇到了这种情况,我们更新的某些内容肯定是相互矛盾的

此错误在com.google.api客户端:google api客户端:1.30.7中已修复。升级到该版本或更高版本将修复此问题

此错误在com.google.api客户端:google api客户端:1.30.7中已修复。升级到该版本或更高版本将修复此问题

这回答了你的问题吗?这回答了你的问题吗?这个修好了!非常感谢你!不用担心,我也很困惑。希望有一个比降级更好的解决方案,因为现在我们基本上停留在这个版本上。但是现在。。。我想这是可行的。我想你必须把我的回答标记为“接受”谢谢——在这个愚蠢的问题上浪费了两个小时,最后才发现这个问题。这里报告的错误:这修复了它!非常感谢你!不用担心,我也很困惑。希望有一个比降级更好的解决方案,因为现在我们基本上停留在这个版本上。但是现在。。。我想这是可行的。我想你必须把我的回答标记为“接受”谢谢——在这个愚蠢的问题上浪费了两个小时,最后才发现这个问题。此处报告的错误:不,这仍然发生在'com.google.api客户端:google api客户端android:1.31.4'不,这仍然发生在'com.google.api客户端:google api客户端android:1.31.4'中
     Caused by: java.lang.IllegalStateException: No successful match so far
        at java.util.regex.Matcher.ensureMatch(Matcher.java:1116)
        at java.util.regex.Matcher.group(Matcher.java:382)
        at com.google.api.client.googleapis.GoogleUtils.<clinit>(Unknown Source:26)
  public static final String VERSION = getVersion();

  static final Pattern VERSION_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)(-SNAPSHOT)?");

  static {
    Matcher versionMatcher = VERSION_PATTERN.matcher(VERSION);
    versionMatcher.find();
    MAJOR_VERSION = Integer.parseInt(versionMatcher.group(1));
    MINOR_VERSION = Integer.parseInt(versionMatcher.group(2));
    BUGFIX_VERSION = Integer.parseInt(versionMatcher.group(3));
  }

private static String getVersion() {
    String version = GoogleUtils.class.getPackage().getImplementationVersion();
    // in a non-packaged environment (local), there's no implementation version to read
    if (version == null) {
      // fall back to reading from a properties file - note this value is expected to be cached
      try (InputStream inputStream =
          GoogleUtils.class.getResourceAsStream("google-api-client.properties")) {
        if (inputStream != null) {
          Properties properties = new Properties();
          properties.load(inputStream);
          version = properties.getProperty("google-api-client.version");
        }
      } catch (IOException e) {
        // ignore
      }
    }
    return version;
  }