News‎ > ‎

Build and reference Rajawali 3D engine using Android Studio

posted 29 Apr 2014, 04:35 by Simon Šander   [ updated 29 Apr 2014, 23:43 ]

Introduction

I have tried to get Rajawali 3D engine work with Android Studio. After some searching on Google with no success, I have realized that I'll have to do it myself.

Prerequisites

  • Installed latest version of Android Studio

The hard way

  1. Go to GitHub page of Rajawali 3D engine source (https://github.com/MasDennis/Rajawali)
  2. Click Download ZIP button and save it to your computer
  3. Unzip it to Rajawali folder (let say c:\temp\Rajawali) go to that folder and you should see this



  4. Start Android Studio and select File -> New project and create new blank project (see image below)



  5. Go to forder where project was created (for this example it is c:\temp\MyApplication2\)
  6. You should see structure like this


  7. Now copy folder gradle and files gradlew.bat, build.gradle and local.properties to folder c:\temp\Rajawali


  8. Copy and paste thext below to gradle.build file

    buildscript {
        repositories {
            mavenCentral()
        }

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

    apply plugin: 'android-library'

    repositories {
        mavenCentral()
        mavenLocal()    
    }

    android {
        compileSdkVersion 19

        buildToolsVersion "19.0.3"

        defaultConfig {
            versionCode 1
            versionName "1.0"
            minSdkVersion 14
            targetSdkVersion 19
        }

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

        lintOptions {
            abortOnError false
        }
    }


  9. Run Android Studio again and select Import project. Navigate to c:\temp\Rajawali and select build.gradle file.
  10. Click Sync Project With Gradle Files 

  11. Open Command prompt and navigate to c:\temp\Rajawali
  12. Type gradlew build
  13. If everything was done right project should compile and you'll get new build folder. There is folder called libs inside that contains Rajawali.aar library.
  14. You can now install Rajawali.aar library to your local maven repository like this:

    mvn install:install-file -Dfile=.\build\libs\Rajawali.aar -DgroupId=rajawali.framework -DartifactId=rajawaliframework -Dversion=1 -Dpackaging=aar

  15. Now you can put maven reference to jour local Rajawali into build.gradle file of your project

    android {
        dependencies {
            compile 'rajawali.framework:rajawaliframework:1'
        }
    }

  16. Build your project.

The easy way

You can just download Android Studio ready version from here https://github.com/sajmons/Rajawali and run gradlew build from Command prompt for same effect.

If you find this tutorial useful please share it with your friends.
Comments