3

i've tried to follow the google's guide, but it says to create a new empty module and in the newest version there's no option for that... how can i do it? thank you.

DomeWTF
  • 2,342
  • 4
  • 33
  • 46

1 Answers1

4

This is whole tutorial how to work with AndEngine and PhysicsBox2D extension using Android Studio and Gradle. As long as gradle doesn't support native libs I'm using the hack described here Android Studio Gradle with native libs error

My project structure is:
- ProjectRoot
- build.gradle
- settings.gradle
- MainProject
-- src
-- res
-- aidl
- Modules
-- AndEngine
--- src
--- res
--- libs
---- libs.jar
--- build.gradle
-- PhysicBox2D
--- src
--- res
--- libs
---- libs.jar
--- build.gradle
--- settings.gradle

in both AndEngine and PhysicsBox2D i put folders armeabi, armeabi-v7 and so on into lib folder, then zipped it and renamed into libs.jar. It's described in the link i gave above.

My main settings.gradle file looks like this

include 'Modules:AndEngine'
include 'Modules:PhysicBox2D'

and build.gradle like this

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.3'
    }
}
apply plugin: 'android'

dependencies {
    compile project(':Modules:PhysicBox2D')
    compile project(':Modules:AndEngine')

}

task wrapper(type: Wrapper) {
    gradleVersion = '1.8'
}

android {
    compileSdkVersion 19
    buildToolsVersion "19"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['MainProject/src']
            resources.srcDirs = ['MainProject/resources']
            aidl.srcDirs = ['MainProject/src']
            renderscript.srcDirs = ['MainProject/src']
            res.srcDirs = ['MainProject/res']
            assets.srcDirs = ['MainProject/assets']
        }

        instrumentTest.setRoot('MainProject/tests')
    }

    dependencies {

    }

    defaultConfig {
        ...
    }

    signingConfigs {
        ...
    }

    buildTypes {
        debug {
            ...
        }
        release {
            ...
        }
    }
}

Modules/PhysicBox2D/settings.gradle

include ':Modules:AndEngineGLES2'

Modules/PhysicsBox2D/build.gradle

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.3'
    }
}

apply plugin: 'android-library'

    dependencies {

        compile project(':Modules:AndEngineGLES2')
        compile fileTree(dir: 'libs', include: 'libs.jar')
    }
    android {

    buildToolsVersion "19"
    compileSdkVersion 19

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
    }

    repositories {
        mavenCentral()
    }


sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['aidl']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
    }
}

Modules/AndEngine/build.gradle

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.3'
    }
}

apply plugin: 'android-library'

dependencies {
    compile fileTree(dir: 'libs', include: 'libs.jar')
}

android {

    buildToolsVersion "19"
    compileSdkVersion 19

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
    }

    repositories {
        mavenCentral()
    }


    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['aidl']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
    }
}

And Everything works fine. I hope I've put all the necessary information to make it running.

Community
  • 1
  • 1
mar3kk
  • 1,886
  • 2
  • 17
  • 21
  • Where do you download "AndEngine" and "PhysicBox2D" from and where should I put them? (Where is "google's guide"?) – user5262 Aug 10 '14 at 14:54
  • ANdEngine - https://github.com/nicolasgramlich/AndEngine/tree/GLES2-AnchorCenter, Box2D for AndEngine - https://github.com/nicolasgramlich/AndEngine/tree/GLES2-AnchorCenter – mar3kk Aug 12 '14 at 06:39
  • Thanks for your response. But can you post a step-by-step instruction, please? (i.e.: 1. create the directory structure, 2. extract the .zip files, 3. ?) – user5262 Aug 19 '14 at 14:45
  • Or, easier, can you upload your project structur, as you posted it above, somewhere? – user5262 Aug 19 '14 at 14:53