Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile multiple modules in Android Gradle Dependency

I'm trying to create an app with andEngine WITH its physicsBox2D extension. For that, I have to add 2 modules and then compile in my app - andEngine and andEngine PhysicsBox2D. I have the following Gradle code -

apply plugin: 'com.android.model.application'

model {

android {
    compileSdkVersion = 22
    buildToolsVersion = "22.0.1"

    defaultConfig.with {
        applicationId = "com.sample.practice"
        minSdkVersion.apiLevel = 9
        targetSdkVersion.apiLevel = 22
        versionCode = 1
        versionName = "1.0"
    }
}

android.buildTypes {
    release {
        minifyEnabled = false
        proguardFiles += file('proguard-rules.pro')
    }
}
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':andEnginePhysicsBox2D')
    compile project(':andEngine')
}

But this code gives this error while running - ...java.exe finished with non zero exit value 2

If I remove compile project(':andEnginePhysicsBox2D') from Gradle, the app runs fine. But this code is important for the app to work. Any ideas how I can implement both andEngine and andEngine PhysicsBox2D in the dependencies of Gradle?

Thanx

PS - I'm using experimental Android Gradle Plugin V.0.2 with Android Studio 1.3 for some NDK stuff.

like image 549
FadedCoder Avatar asked Oct 31 '22 19:10

FadedCoder


1 Answers

Box2d extension needs AndEngine module as its dependency and your project also needs both of them as its dependencies. Also It should be noted that order of dependencies matters as well.

So you should make sure you have three gradle files configured like below.

  • Your game gradle file:

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile project(':andEngine')
        compile project(':andEnginePhysicsBox2D')
    }
    
  • AndEngine gradle file:

    It does not have any dependency.

  • Box2d Extension gradle file:

    dependencies {
        compile project(':andEngine')
    }
    
like image 80
frogatto Avatar answered Nov 13 '22 08:11

frogatto