简体   繁体   中英

ARToolkit gradle build error

I'm trying to use ntfSimpleProj example from ARToolkit. I set the environment variables:

export ANDROID_HOME=/media/applica/Storage/Android/Sdk; export ANDROID_NDK_ROOT=$ANDROID_HOME/ndk-bundle; export NDK=$ANDROID_NDK_ROOT;

after I build successfully the two scripts in android folder ./build.sh and ./build_native_examples.sh

but the build of gradle return me this error:

Error:Attempt to read property 'main' from a write only view of model element 'android.sources' given to rule android.sources { ... } @ nftSimple/build.gradle line 40, column 5

this is my gradle file:

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

model {
    android {
        compileSdkVersion = 22
        buildToolsVersion = "23.0.3"

        defaultConfig.with {
            applicationId = "org.artoolkit.ar.samples.NftSimple"
            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
                }
            }

            ndk.with {
                moduleName = "NftSimple"
            }
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    'proguard-rules.pro'
        }
    }

    android.productFlavors {
    }

    android.sources {
        main.jni {
            source {
     apply plugin: 'com.android.model.application'

model {
    android {
        compileSdkVersion = 22
        buildToolsVersion = "23.0.3"

        defaultConfig.with {
            applicationId = "org.artoolkit.ar.samples.NftSimple"
            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
                }
            }

            ndk.with {
                moduleName = "NftSimple"
            }
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    'proguard-rules.pro'
        }
    }

    android.productFlavors {
    }

    android.sources {
                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')
}                                                       //the compile and target of the app being deployed to the device

Can someone help me?

Thanks a lot!

I fixed the error, I have to change the sources declaration in the gradle.

From this:

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

To this:

android.sources {
    main{
        jni {
            source {
                srcDirs "src/main/nop"
            }
        }

        jniLibs {
            source {
                srcDirs "src/main/libs"
            }
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM