gpt4 book ai didi

java - 使用 NDK 应用在 gradle 中不起作用的插件

转载 作者:太空宇宙 更新时间:2023-11-04 12:20:38 25 4
gpt4 key购买 nike

我正在尝试将 Realm 添加到我的应用程序中。他们的文档指出我需要将类路径依赖项添加到项目级别的 build.gradle 文件中。并将realm-android插件应用到顶级应用程序级别的build.gradle文件中。 (https://realm.io/docs/java/latest/)

我这样做了,但收到此错误:

Error:(2, 0) 'com.android.application' or 'com.android.library' plugin required.

我的项目gradle:

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.7.0-alpha4'
classpath "io.realm:realm-gradle-plugin:1.1.1"
}
}

allprojects {
repositories {
jcenter()
}
}

我的应用程序 gradle 使用 NDK:

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


Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def superpowered_sdk_path = properties.getProperty('superpowered.dir')

model {
repositories {
libs(PrebuiltLibraries) {
superpowered { // this is where you declare the "superpowered" static library
headers.srcDir "${superpowered_sdk_path}"
binaries.withType(StaticLibraryBinary) { // attaching library files to each platform
def platformName = targetPlatform.getName()
if (platformName == "armeabi-v7a") {
staticLibraryFile = file("${superpowered_sdk_path}/libSuperpoweredAndroidARM.a")
} else if (platformName == "arm64-v8a") {
staticLibraryFile = file("${superpowered_sdk_path}/libSuperpoweredAndroidARM64.a")
} else if (platformName == "x86") {
staticLibraryFile = file("${superpowered_sdk_path}/libSuperpoweredAndroidX86.a")
} else if (platformName == "x86_64") {
staticLibraryFile = file("${superpowered_sdk_path}/libSuperpoweredAndroidX86_64.a")
}
}
}
}
}

android { // main settings for your application
compileSdkVersion = 23
buildToolsVersion = "23.0.2"


defaultConfig {
applicationId "com.superpowered.crossexample"
minSdkVersion.apiLevel = 16 // more than 95% of all active Android devices
targetSdkVersion.apiLevel = 23
versionCode 1
versionName "1.0"
}
}

android.ndk { // your application's native layer parameters
moduleName = "SuperpoweredExample"
platformVersion = 16
stl = "c++_static"
CFlags.addAll(["-O3", "-fsigned-char"]) // full optimization, char data type is signed
cppFlags.addAll(["-fsigned-char", "-I${superpowered_sdk_path}".toString()])
ldLibs.addAll(["log", "android", "OpenSLES"]) // load these libraries: log, android, OpenSL ES (for audio)
abiFilters.addAll(["armeabi-v7a", "arm64-v8a", "x86", "x86_64"]) // these platforms cover 99% percent of all Android devices
}

android.sources.main.jni {
source {
srcDir "jni"
srcDir "${superpowered_sdk_path}/AndroidIO"
}
dependencies {
library "superpowered" linkage "static" // this is where you attach the "superpowered" static library to your app
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.facebook.fresco:fresco:0.12.0'
compile 'com.android.support:design:23.4.0'
}

最佳答案

看起来您正在使用实验性插件? 应用插件:'com.android.model.application'。这是正确的吗?

Realm 目前不适用于实验性插件。请参阅https://github.com/realm/realm-java/issues/2539

关于java - 使用 NDK 应用在 gradle 中不起作用的插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38881649/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com