venerdì 29 dicembre 2017

Compilare ARToolKit su Android Studio 3

Le istruzioni per installare ARToolKit su Android Studio sono piuttosto vecchie e di fatto non funzionano nella configurazione attuale (sono state scritte nel 2016)

Per fare funzionare gli esempi, dopo avere compilato la libreria nell'NDK (come da istruzioni), si devono modificare i file di progetto come segue (vedi linee evidenziate in giallo)

---------------------------
buildscript {
    repositories {
        jcenter()
    }
    
    dependencies {
        classpath 'com.android.tools.build:gradle-experimental:0.11.1'

        // NOTE: Do not place your application dependencies here; they belong        // in the individual module build.gradle files    }
}

allprojects {
    repositories {
        jcenter()
    }
}
---------------------------


gradle.wrapper.properties
---------------------------
#Fri Dec 29 14:39:59 CET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
---------------------------


build.gradle (Module ArSimple)
---------------------------

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

model {
    android {
        compileSdkVersion = 23        buildToolsVersion = "23.0.2"
        defaultConfig.with {
            applicationId = "org.artoolkit.ar.samples.ARSimple"            minSdkVersion.apiLevel = 15            targetSdkVersion.apiLevel = 22            versionCode = 1            //Integer type incremented by 1 for every release, major or minor, to Google store            versionName = "1.0" //Real fully qualified major and minor release description
            buildConfigFields.with {
                //Defines fields in the generated Java BuildConfig class, in this case, for                create() {           //default config, that can be accessed by Java code                    type = "int"     //e.g. "if (1 == BuildConfig.VALUE) { /*do something*/}".                    name = "VALUE"                    //See: [app or lib]/build/generated/source/buildConfig/[package path]/                    value = "1"      //     BuildConfig.java                }
            }
        }
    }

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

    android.productFlavors {
    }
    android.sources {
        main {
            jni {
                source {
                    srcDirs = ['src/main/nop']
                }
            }
        }
        main {
            jniLibs {
                source {
                    srcDirs = ['src/main/libs']
                }
            }
        }
    }
    
}

dependencies {
    //compile 'com.android.support:support-v4:23.0.1'    //compile 'com.android.support:appcompat-v7:23.0.1' //Only required when the target device API level is greater than    compile project(':aRBaseLib')
}     

------------------------------------------------------