Home » Android » android – A dependent feature was defined but no package ID was set. You are probably missing a feature dependency in the base feature

android – A dependent feature was defined but no package ID was set. You are probably missing a feature dependency in the base feature

Posted by: admin June 15, 2020 Leave a comment

Questions:

I am following one of the Google Codelabs for making an Instant App.

And I was trying to create topeka-ui (A UI feature module for Instant Apps).

When I try to run one of the instant app module it says :

A dependent feature was defined but no package ID was set.
You are probably missing a feature dependency in the base feature.

How to&Answers:

I just ran through the codelab on AS 3.0 beta 2 without issues (*note). After what point in the codelab did your issue appear?

You might’ve missed a step. Double check that your base module’s build.gradle has:

dependencies {
    ...
    application project(":topekaapk")
    feature project(":topekaui")
}

Leaving out feature project(":topekaui") can cause this error:

Error:com.android.builder.internal.aapt.AaptException: A dependent
feature was defined but no package ID was set. You are probably
missing a feature dependency in the base feature.

Note: because data-binding has been disabled for non-base modules (https://issuetracker.google.com/63814741), there requires some additional steps in the multi-feature step-7 to get around it (ie. getting rid of the DataBindingUtil).

Answer:

I had this issue in my Dynamic Feature Module when I forgot to add a reference to it in the base module’s android.dynamicFeatures = [":module_name"] array

Answer:

Since this is the only stackoverflow question for “A dependent feature was defined but no package ID was set. You are probably missing a feature dependency in the base feature.” I will answer what my issue was here rather than create a new question. I had a module that was giving me this error and couldn’t figure out the problem. In the module’s build.gradle file, I had:

apply plugin: 'com.android.feature'

It should have been:

apply plugin: 'com.android.libary'

Answer:

Base from basic instant app project structure,

When you build your instant app, this module takes all of the features and creates Instant App APKs. It does not hold any code or resources; it contains only a build.gradle file and has the com.android.instantapp plugin applied to it. Here’s an example:

apply plugin: 'com.android.instantapp'
...
dependencies {
    implementation project(':base')
    // if there additional features, they go here
    implementation project(':feature1')
}

Furthermore, note that

The base feature module’s build configuration file needs to apply the com.android.feature gradle plugin. The build.gradle file does not contain any instant app specific modifications.

With this and in line with your encountered error, you may want to check your base feature module’s build configuration file. Lastly, make sure that you also sync your project with gradle files.

See Android Instant Apps documentation for more information.