How to import backend module class into application module in android studio

In my Android project, I have two modules,

  • Application module

  • backend module

I want to import the backend module class into one of the classes of my application module. but when I try to import it like this

import com.me.you.backend.entities 

I get an error Error:(52, 58) error: package com.me.you.backend.entities does not exist

The next thing I tried is to compile my backend module in my build.gradle application, like this

 dependencies { .... compile project(':backend') } 

But I get 13 warnings! of this type

 WARNING: Dependency org.apache.httpcomponents:httpclient:4.4.1 is ignored for debug as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages 

And when I run my application module, I get this error

  Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'. 

java.util.zip.ZipException: duplicate entry: com / google / appengine / repackaged / com / google / api / client / auth / oauth2 / AuthorizationCodeFlow $ Builder.class

Question

How can I successfully import my base class?

+5
source share
2 answers

The solution was to add a backend module dependency in my build.gradle application build.gradle like this

 compile project(path: `:backend`, configuration: `android-endpoints`) 

After that, I will rebuild the project (Build> Rebuild project). and everything was in order.

+1
source

why don’t you try creating a new Commons module. There you can put all the common classes between "Backend" and "app" by adding gradle to your files:

 compile project(':commons') 
0
source

Source: https://habr.com/ru/post/1233861/


All Articles