android - ARToolkit Gradle构建错误

标签 android gradle android-ndk artoolkit

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

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



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

但是gradle的构建会向我返回此错误:

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



这是我的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

有人能帮我吗?

非常感谢!

最佳答案

我更正了错误,我必须更改gradle中的source声明。

由此:

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"
            }
        }
    }
}

关于android - ARToolkit Gradle构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40587753/

相关文章:

android - 服务如何监听触摸手势/事件?

java - 错误 : java. util.concurrent.ExecutionException : com. android.builder.internal.aapt.v2.Aapt2Exception: 在 Windows 10 上编译时出现 AAPT2 错误

android - dlopen 在旧版 Android 上失败

javascript - 移动设备上的网站登陆页面,键盘问题

android - 我如何设计一个类似 "family tree"的用户界面?

android - 如何在 gradle javadoc 任务中设置指向外部 AndroidX 引用的链接?

java - Android 中 Java 和 NDK (JNI) 之间的共享静态变量访问

java-native-interface - FindClass 在 Android NDK 中崩溃

java - 在java中将对象传递给方法似乎是通过引用(而Java是通过val)

java - 我们如何在 Maven 中为主要和测试 java 代码集拥有不同的 PMD 规则集?