Edijae Crusar
Edijae Crusar

Reputation: 3541

How to import a backend module class into an app module in android studio

In my android project, i have two modules,

I want to import a backend module class into one of my app module class. 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 that i tried is to compile my backend module in my app's build.gradle 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 app 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 backend class?

Upvotes: 5

Views: 1212

Answers (2)

Edijae Crusar
Edijae Crusar

Reputation: 3541

Solution was to add dependancy on backend module in my app module's build.gradle like this

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

After this i rebuild my project (Build > Rebuild project). and everything was ok.

Upvotes: 1

johnny_kb
johnny_kb

Reputation: 714

why don't you try to create a new module "Commons". There you can put all shared classes between 'Backend' and 'app' by adding on your gradle files:

compile project(':commons')

Upvotes: 0

Related Questions