使用非官方金属档案库API时发生意外崩溃

时间:2019-02-27 17:34:11

标签: android android-gradle

因此,我正在使用一个外部(非官方)库来查找网站https://www.metal-archives.com/上的各个频段,让您从中获取诸如唱片和曲目列表之类的信息。

我遇到的问题是,当我查询搜索时,与网站(?)的连接出现问题,然后使应用程序崩溃。 ADB Logcat showed that it throwed some IllegalStateExceptions but I'm not sure how to fix them.

我正在使用的(非官方)API:https://github.com/Loki-Afro/metalarchives

我已使用Gradle将其添加到我的应用中,所有功能都显示在我的代码中,因此已正确添加到项目中:

implementation 'com.github.loki-afro:metalarchives-api:0.5.0'

API包含一些我在like this one之后尝试使用的示例类(不起作用断言),但是在github上的readme.md中使用示例用法也使我同样崩溃。

我的代码从EditText获取字符串,并将其传递给负责进行搜索的getBand()函数。通过onClick按钮执行。

public void doSearchAndUpdateResults(View view){
    EditText searchMetalArchivesBar = findViewById(R.id.searchMetalArchives);
    TextView resultView = findViewById(R.id.queryResult);
    String search = searchMetalArchivesBar.getText().toString();

    try {
        resultView.setText(getBand(search));
    } catch (MetallumException e){
        e.printStackTrace();
    }
}

public String getBand(String bandToSearchFor) throws MetallumException{
    BandSearchService bandSearchService = new BandSearchService();
    bandSearchService.setLoadSimilar(true);
    BandSearchQuery bandSearchQuery = new BandSearchQuery();
    bandSearchQuery.setBandName(bandToSearchFor, true);
    bandSearchQuery.setGenre("Black Metal");
    bandSearchQuery.setLabel("*", false);
    bandSearchQuery.setYearOfFormationFrom(1970);
    bandSearchQuery.setProvince("*", "*");
    bandSearchQuery.setLyricalThemes("*");
    bandSearchService.performSearch(bandSearchQuery);
    if (!bandSearchService.isResultEmpty()) {
        return bandSearchService.getResultAsList().get(0).getName();
    }
    return "no band found";
}

我已经尝试过将apache添加到我的gradle构建文件中,但这给了我一个重复的错误。

0 个答案:

没有答案