Why is the package in the library module not present at compile time, even though Android Studio does not show a code error?… here is a solution to the problem.
Why is the package in the library module not present at compile time, even though Android Studio does not show a code error?
I have a library module (AndEngine) in my libs/AndEngine folder. Compiled code.
In my root settings.gradle file I have this:
include ':app:libs:AndEngine'
include ':app'
Then in my app’s build.gradle file, I have this in dependencies:
compile project('libs:AndEngine')
In my app code, all imports and even autocomplete don’t have any errors. In Android Studio, all packages are found. But when I went to compile, I got about a hundred errors like this :
error: package org.andengine.entity.primitive does not exist
import org.andengine.entity.primitive.Rectangle;
I’m from ADK and eclipse, so I’m new to Android Studio. I would appreciate it if anyone had any answer to this question!
Solution
Change this line.
compile project('libs:AndEngine')
In
compile project(':app:libs:AndEngine')
In any case, it is not a good idea to put a library module in an application module.
I suggest you use this structure:
root
settings.gradle
.app
build.gradle
libs
AndEngine
build.gradle
Then in your settings.gradle
include ':libs:AndEngine'
include ':app'
In your app/build.gradle
compile project(':libs:AndEngine')