DeepLinkDispatch - 不兼容的类型:List <Object>无法转换为List <DeepLinkEntry>

Jos*_*ird 5 android

按照github页面上的教程,我有:

添加到我的项目的父级build.gradle:

dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' <---

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
Run Code Online (Sandbox Code Playgroud)

添加到我的应用程序build.gradle:

apply plugin: 'com.neenbedankt.android-apt'

...

compile 'com.airbnb:deeplinkdispatch:3.0.0'
apt 'com.airbnb:deeplinkdispatch-processor:3.0.0'
Run Code Online (Sandbox Code Playgroud)

创建了一个模块类并对其进行了注释:

@DeepLinkModule
public class AppDeepLinkModule
{

}
Run Code Online (Sandbox Code Playgroud)

现在,当我尝试构建时,它会显示以上错误消息:

Error:(12, 82) error: incompatible types: List<Object> cannot be converted to List<DeepLinkEntry>
Run Code Online (Sandbox Code Playgroud)

然后它指向我自动生成的这个类:

public final class AppDeepLinkModuleLoader implements Parser {
  public static final List<DeepLinkEntry> REGISTRY = Collections.unmodifiableList(Arrays.asList(
  )); <-- this line here

  @Override
  public DeepLinkEntry parseUri(String uri) {
    for (DeepLinkEntry entry : REGISTRY) {
      if (entry.matches(uri)) {
        return entry;
      }
    }
    return null;
  }
}
Run Code Online (Sandbox Code Playgroud)

我已经提到他们的示例应用程序,我的看似相同.这是他们班级的链接,它做同样的事情.

我完成了进一步的步骤,直到我需要使用自动生成的类,以防这是问题,但这也没有解决问题.AndroidManifest.xml:

<activity
        android:name=".deeplink.DeepLinkActivity"
        android:theme="@android:style/Theme.NoDisplay">
        <intent-filter>
            <action android:name="android.intent.action.VIEW"/>

            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.BROWSABLE"/>

            <data
                android:host="slackwebsocket"
                android:scheme="http"/>
        </intent-filter>
    </activity>
Run Code Online (Sandbox Code Playgroud)

DeepLinkActivity:

@DeepLinkHandler({AppDeepLinkModule.class})
public class DeepLinkActivity extends AppCompatActivity
{
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
    }
}
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

nan*_*ito 2

当应用程序未指定任何深层链接目标时,就会出现此问题。在这种情况下,代码生成器创建一个空列表,这会引发编译器错误。

您可以通过注释类(例如 an )来从语法Activity上解决此问题@DeepLink:

@DeepLink("scheme://authority")
public class TargetActivity extends Activity {
}
Run Code Online (Sandbox Code Playgroud)

代码生成器将向该列表添加一个元素。