【问题标题】:ARToolkit gradle build errorARToolkit gradle 构建错误
【发布时间】:2016-11-14 11:32:38
【问题描述】:

我正在尝试使用 ARToolkit 中的 ntfSimpleProj 示例。 我设置环境变量:

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

在我成功构建 android 文件夹 ./build.sh 和 ./build_native_examples.sh 中的两个脚本后

但是 gradle 的构建返回了这个错误:

错误:尝试从为规则 android.sources { ... } @ nftSimple/build.gradle 第 40 行第 5 列提供的模型元素“android.sources”的只写视图中读取属性“main”

这是我的 gradle 文件:

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

有人可以帮我吗?

非常感谢!

【问题讨论】:

    标签: android gradle android-ndk artoolkit


    【解决方案1】:

    我修复了错误,我必须更改 gradle 中的源声明。

    从这里:

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

    到这里:

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

    【讨论】:

      猜你喜欢
      • 2015-07-02
      • 2016-10-21
      • 2016-05-08
      • 2015-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多