Issue
I have an android studio project with several external modules (modules are located on different file paths) and I can`t manage to make the Android Studio see the abstract class from a module.
Some of the modules depends on other modules, eg: ModuleA is a dependency for ModuleB and ModuleB is a dependency to my main app module. The ModuleB can see the abstract class from ModuleA but my main app module cannot see the abstract class from ModuleB.
I have included on my main app module in the gradle file the module dependency
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:design:23.1.1'
compile project(':ModuleB') }I have only one settings.gradle which is located on the root of the main app module. In the settings.gradle I have file paths to the modules I use in this project.
In my main app module I have a class projectHelper that extends abstract class from ModuleB. eg:
public class projectHelper extends Helper {
}
And whatever I tried I cannot make the main module app to see the abstract Helper class from ModuleB module.
Gradle sync passes ok but the Studio reports that the Helper class cannot be resolved.
I have tried to include the package from the ModuleB, even extend the class something like "extends com.android.ModuleB.Helper" but the class nor the package cannot be resolved.
I am using Android Studio 1.5.1 and Android NDK with com.android.tools.build:gradle-experimental:0.4.0 plugin.
I have done this in Eclipse and it works without a problem.
It also offers me to move the class from ModuleB to my main App module (but I cannot do that), see image: (I had to obscure the package names).
Solution
For now, this can`t be done with experimental NDK plugin.
I have solved this with android.productFlavors. The point is to make the code beside your main dir in separate dir, like flavour1, give it java->packageName>someClass.java. It must have the same package name as the main app, but ignore that because you can change it in gradle at that specific build flavour
create("googleFree") {
applicationId = "com.example.mySpecialPackage"
}
and that package name will be replaced in the manifest when the APK is built.
I have learned this from this link http://blog.robustastudio.com/mobile-development/android/building-multiple-editions-of-android-app-gradle/
Answered By - Adrian Ivasku
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.