jonalmeida
jonalmeida

Reputation: 1236

Extending a class in a different module, builds in Android Studio but cannot resolve symbols

In my project, I have module A with com.example.foo which I want to extend a class in that module in my module B which is com.example.foo.bar. I've added module A as a dependency in module B and it builds just fine.

My problem starts when I'm trying to extend the class as so:

package com.example.foo.bar;

public class Subject extends com.example.foo.SomeClass {
    ...
}

In Android Studio, all the references to module A show up as red (since it cannot resolve those symbols), but I can still successfully build my project regardless.

How do I configure AS to properly recognize the dependency?

Upvotes: 0

Views: 939

Answers (1)

jonalmeida
jonalmeida

Reputation: 1236

Figured out the solution to my problem. This is primarily a bug in Android Studio that's being tracked here: https://code.google.com/p/android/issues/detail?id=65915

The fix is simple, my project modules all had their own settings.gradle in them because they each came from their own git submodule project and AS has a problem ignoring them.

The "fix" is to delete the settings.gradle from all modules except the root project directory.

For example, in my situation, my project structure looks like this:

build.gradle
settings.gradle
library_module:
   build.gradle
   settings.gradle
      library:
         build.gradle
         settings.gradle
android_app:
   settings.gradle
   build.gradle

After deleting, the structure looked like this:

build.gradle
settings.gradle
library_module:
   build.gradle
      library:
         build.gradle
android_app:
   build.gradle

Upvotes: 1

Related Questions