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

9

60

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.

Basilio answered 26/8, 2017 at 3:26 Comment(3)
Did you set baseFeature=true in topekaui build.gradle because data binding aren't currently supported in non-base feature modules? I did it and also met your problem. And also cant found good solution for it...Desirable
I have not found the solution yet eitherBasilio
the most annoying thing is that i cannot even find where the dependent feature was defined. no log, no debug info. nothing. Its getting worse and worse to develop in Android Studio. So freaking frustrating.Deontology
L
11

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).

Leann answered 28/8, 2017 at 18:47 Comment(1)
Posting my exact message to help with search engines: Caused by: com.android.builder.internal.aapt.AaptException: Dependent features configured but no package ID was set.Gabriella
L
136

I had an issue in that I had an Android app and an Android Library, but I had used the wrong plugin by mistake.

For an app:

plugins {
    id "com.android.application"
    id "kotlin-android"
}

For a library:

plugins {
    id "com.android.library"
    id "kotlin-android"
}
Levelheaded answered 23/10, 2020 at 20:9 Comment(1)
Thank you so much! For some reason, Android Studio automatically created the plugin id "com.android.application" in library gradle too!Katsuyama
P
37

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 dependent module's build.gradle file, I had:

apply plugin: 'com.android.feature'

It should have been:

apply plugin: 'com.android.library'
Polly answered 18/12, 2017 at 18:56 Comment(3)
Thanks good buddy! You saved my day! How you ever figured out that was the cause of the error I will never know. Next time I will need to use the Android Library option when I create a new module. However, this 'library' contains no Android-specific code.Tupungato
apply plugin: 'com.android.library' please correct spelling mistake @PollyPigskin
Perfect Answer.Flyboat
G
17

You might have added a dependent module as an application, it should be added as a library. Check build.gradle file of the module and

Replace

plugins {
    id 'com.android.application'

to

plugins {
    id 'com.android.library'

also remove applicationId, versionCode, and versionName from build.gradle's of the inner module if it's added in defaultConfig block.

Gregg answered 16/1, 2023 at 12:12 Comment(0)
L
11

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).

Leann answered 28/8, 2017 at 18:47 Comment(1)
Posting my exact message to help with search engines: Caused by: com.android.builder.internal.aapt.AaptException: Dependent features configured but no package ID was set.Gabriella
S
10

I did it in build.gradle(...mylibrary), fixed it and it worked:

plugins {
- id 'com.android.application'
+ id 'com.android.library'}

defaultConfig {
    - applicationId "com.example.mylibrary"
    minSdk 21
    targetSdk 32}
Supersession answered 7/4, 2022 at 16:47 Comment(0)
C
4

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

Cockayne answered 2/1, 2019 at 15:42 Comment(0)
F
1

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.

Faunus answered 26/8, 2017 at 15:2 Comment(1)
WARNING: The com.android.feature plugin is deprecated and will be removed in a future gradle plugin version. Please switch to using dynamic-features or libraries. For more information on converting your application to using Android App Bundles, please visit developer.android.com/topic/google-play-instant/…Zink
Q
1

With the following gradle pugin

classpath 'com.android.tools.build:gradle:3.5.1'

In my case, after adding to app's build.gradle

android{
dataBinding {
        enabled = true
    }
}

I got the posted error, then doing the following

Android studio -> invalidate cache and restart

Issue got fixed!

Not Fixed Yet?

Probably there is a conflicting dependency residing in build.gradle, like the older and current version of the same library

Quadratic answered 23/10, 2020 at 12:31 Comment(0)
T
0

This solution will work 100%

Step 1) Open gradle.properties

Step 2) Add android.enableJetifier=true to the file

Done!

See The Screen Shot: enter image description here

Tautomer answered 8/7, 2022 at 12:5 Comment(1)
It worked for once, but after my second Make Project comment, it crashed. So, this is not helpful, but it might not just for me I'm not sure.Rope

© 2022 - 2024 — McMap. All rights reserved.