gpt4 book ai didi

android - 当 realm-gradle-plugin :1. 0.0 添加到 Android Studio 项目时,Gradle 同步失败

转载 作者:搜寻专家 更新时间:2023-11-01 09:46:45 24 4
gpt4 key购买 nike

首先,这是我的第一个问题,我想向大家问好。这个社区很棒,每次我编码时,我在这里找到的答案都会帮助我。这次不行。

所以,我正在为 Android 编写小应用程序,是时候添加数据库层了。为此,我经历了 realm installation guide并添加到我的项目 build.gradle 行:

classpath "io.realm:realm-gradle-plugin:1.0.0"

然后在我的应用程序模块 build.gradle 下一行:

apply plugin: 'realm-android'

但是我的问题开始了。在添加这两行之前,gradle 正在同步并成功构建项目,但是在添加这两行之后,它无法同步并显示错误消息:

Error:Could not find property 'options' on task ':app:compileDebugJavaWithJack'.

事件日志显示:

17:24:48 Gradle sync started
17:24:50 Gradle sync failed: Could not find property 'options' on task ':app:compileDebugJavaWithJack'. Consult IDE log for more details (Help | Show Log)

我试过 ./gradlew clean 但它没有改变任何东西,也没有删除我主目录中的 .gradle 并让 Android Studio 从头开始​​处理依赖项.

这是我项目的build.gradle:

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath "io.realm:realm-gradle-plugin:1.0.0"
}
}
allprojects {
repositories {
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

还有我的应用模块的 build.gradle:

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

android {
compileSdkVersion 23
//compileSdkVersion 'android-N'
//buildToolsVersion "23.0.3"
buildToolsVersion "24.0.0-rc4"

defaultConfig {
applicationId "agh.jitp2.quizzy"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
testCompile 'org.assertj:assertj-core:3.4.1'
testCompile 'org.mutabilitydetector:MutabilityDetector:0.9.5'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
}

你有什么提示可以告诉我需要做什么才能构建这个项目吗?

提前致谢,抱歉我的英语不好。

编辑:
@cricket_007:上面是我在消息窗口和事件日志中得到的所有信息。 Gradle 控制台是空的。但是当我使用 --info 标志在应用程序模块 build.gradle 上运行 build 时,我得到以下输出:

[...]
Starting Build
Settings evaluated using settings file 'C:_Dev_Repos\AGH\Quizzy\settings.gradle'.
Projects loaded. Root project using build file 'C:_Dev_Repos\AGH\Quizzy\build.gradle'.
Included projects: [root project 'Quizzy', project ':app']
Evaluating root project 'Quizzy' using build file 'C:_Dev_Repos\AGH\Quizzy\build.gradle'.
Evaluating project ':app' using build file 'C:_Dev_Repos\AGH\Quizzy\app\build.gradle'.
Creating configuration compile
Creating configuration apk
Creating configuration provided
Creating configuration wearApp
Creating configuration androidTestCompile
Creating configuration androidTestApk
Creating configuration androidTestProvided
Creating configuration androidTestWearApp
Creating configuration testCompile
Creating configuration testApk
Creating configuration testProvided
Creating configuration testWearApp
Creating configuration debugCompile
Creating configuration debugApk
Creating configuration debugProvided
Creating configuration debugWearApp
Creating configuration testDebugCompile
Creating configuration testDebugApk
Creating configuration testDebugProvided
Creating configuration testDebugWearApp
Creating configuration releaseCompile
Creating configuration releaseApk
Creating configuration releaseProvided
Creating configuration releaseWearApp
Creating configuration testReleaseCompile
Creating configuration testReleaseApk
Creating configuration testReleaseProvided
Creating configuration testReleaseWearApp
Parsing the SDK, no caching allowed
Parsing C:_Dev\Android\SDK\add-ons\addon-google_apis-google-23\package.xml
Parsing C:_Dev\Android\SDK\build-tools\23.0.3\package.xml
Parsing C:_Dev\Android\SDK\build-tools\24.0.0-preview\package.xml
Parsing C:_Dev\Android\SDK\docs\package.xml
Parsing C:_Dev\Android\SDK\extras\android\m2repository\package.xml
Parsing C:_Dev\Android\SDK\extras\google\m2repository\package.xml
Parsing C:_Dev\Android\SDK\extras\google\usb_driver\package.xml
Parsing C:_Dev\Android\SDK\extras\intel\Hardware_Accelerated_Execution_Manager\package.xml
Parsing C:_Dev\Android\SDK\platform-tools\package.xml
Parsing C:_Dev\Android\SDK\platforms\android-23\package.xml
Parsing C:_Dev\Android\SDK\platforms\android-N\package.xml
Parsing C:_Dev\Android\SDK\sources\android-23\package.xml
Parsing C:_Dev\Android\SDK\system-images\android-23\google_apis\x86\package.xml
Parsing C:_Dev\Android\SDK\tools\package.xml
Incremental Java compilation disabled in variant debug as you are using an incompatible plugin
Not using incremental javac compilation.
Incremental java compilation is an incubating feature.
Incremental Java compilation disabled in variant debugUnitTest as you are using an incompatible plugin
Not using incremental javac compilation.
Incremental Java compilation disabled in variant release as you are using an incompatible plugin
Not using incremental javac compilation.
Incremental Java compilation disabled in variant releaseUnitTest as you are using an incompatible plugin
Not using incremental javac compilation.

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ':app'.
    > Could not find property 'options' on task ':app:compileDebugJavaWithJack'.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

    BUILD FAILED

最佳答案

    jackOptions {
enabled true
}

JACK 目前不支持注释处理(用于在 Realm 中生成代理),但它也不生成 Realm 通过 Realm-Transformer 与 Javassist(字节码操作)一起使用的 class 文件,它将所有字段访问转换为代理方法调用。

实际上,这是为了删除强制性的 getter/setter。但随着这次更新,还带来了在 Realm 对象上使用接口(interface)的能力,所以这是一个相当重要的步骤。

关于android - 当 realm-gradle-plugin :1. 0.0 添加到 Android Studio 项目时,Gradle 同步失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37765760/

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