DeepLinkDispatch - Incompatible Types: List <Object> could not be converted to List <DeepLinkEntry>

Following the guide on the github page I:

added to parent project 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
    }

      

added to my app build.gradle

:

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

...

compile 'com.airbnb:deeplinkdispatch:3.0.0'
apt 'com.airbnb:deeplinkdispatch-processor:3.0.0'

      

Created a module class and annotated it:

@DeepLinkModule
public class AppDeepLinkModule
{

}

      

Now when I try to build it displays the above error message:

Error:(12, 82) error: incompatible types: List<Object> cannot be converted to List<DeepLinkEntry>

      

He then points me to this class, which is autogenerated:

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;
  }
}

      

I mentioned their sample application and mine seems to be identical. Here is a link to their class that does the same.

I followed further steps until I needed to use the autogenerated class if that would be a problem, but that didn't help either. 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>

      

DeepLinkActivity

:

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

      

How to fix it?

+3


source to share


2 answers


This issue occurs when the application does not specify any deep link targets. In this case, the code generator creates an empty list, which causes a compiler error.

You can syntactically fix this problem by annotating the class for example. a Activity

, c @DeepLink

:



@DeepLink("scheme://authority")
public class TargetActivity extends Activity {
}

      

The code generator will add the item to this list.

0


source


Have you tried a simple cast?

(List<DeepLinkEntry>)



I mean public static final List<DeepLinkEntry> REGISTRY = (List<DeepLinkEntry>) Collections.unmodifiableList(Arrays.asList( )); <-- this line here

0


source







All Articles