Android工程去掉注释爆红,当我将AspectJ应用于Android项目并且Android注释...

我正在使用Androidstudio 0.8.9并使用gradle构建.

但编译失败,并抛出一些错误消息

:app:compileDebugJava

Internal compiler error: java.lang.IllegalStateException: java.lang.IllegalArgumentException: Unknown location : SOURCE_OUTPUT at org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.BatchAnnotationProcessorManager.discoverNextProcessor(BatchAnnotationProcessorManager.java:183)

:app:compileDebugAspectj FAILED

FAILURE: Build failed with an exception.

* What went wrong:

Execution failed for task ':app:compileDebugAspectj'.

> Internal compiler error: java.lang.IllegalStateException: java.lang.IllegalArgumentException: Unknown location : SOURCE_OUTPUT at org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.BatchAnnotationProcessorManager.discoverNextProcessor(BatchAnnotationProcessorManager.java:183)

* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 13.616 secs

Unknown location : SOURCE_OUTPUT at org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.BatchAnnotationProcessorManager.discoverNextProcessor(BatchAnnotationProcessorManager.java:183)

2:04:32: External task execution finished 'build'.

我的build.gradle是

repositories {

mavenCentral()

}

buildscript {

repositories {

mavenCentral()

}

dependencies {

classpath 'com.android.tools.build:gradle:0.12.2'

classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2+'

classpath 'com.uphyca.gradle:gradle-android-aspectj-plugin:0.9.+'

}

}

def androidAnnotationsVersion = '3.1';

def daggerVersion = '1.0.0';

apply plugin: 'com.android.application'

apply plugin: 'android-aspectj'

apply plugin: 'android-apt'

android {

compileSdkVersion 19

buildToolsVersion "20.0.0"

defaultConfig {

applicationId "com.flask.aspectjtest"

minSdkVersion 16

targetSdkVersion 20

versionCode 1

versionName "1.0"

}

buildTypes {

release {

runProguard false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

}

}

lintOptions {

abortOnError false

}

}

configurations {

apt

ajc

aspects

ajInpath

}

apt {

arguments {

androidManifestFile variant.processResources.manifestFile

resourcePackageName "com.flask.aspectjtest"

}

}

ext.aspectjVersion = '1.8.2'

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:20.0.0'

apt "org.androidannotations:androidannotations:${androidAnnotationsVersion}"

compile "org.androidannotations:androidannotations:${androidAnnotationsVersion}"

apt "com.squareup.dagger:dagger-compiler:${daggerVersion}"

compile "com.squareup.dagger:dagger:${daggerVersion}"

}

所以,我单独测试了aspectj插件工作(没有android-annotations),效果很好.

我找到了一些答案(Android Annotations and MonkeyTalk?),FAQ Page of AA.

但是我认为这是eclipse解决方案,我无法用这个答案来解决我的问题.

我将注释处理器android-apt更改为ajc.但是现在,它无法找到AndroidManifest.xml文件. (因为apt配置不可用)

repositories {

mavenCentral()

maven { url 'http://repo.spring.io/snapshot' }

}

buildscript {

repositories {

mavenCentral()

maven {

url "https://oss.sonatype.org/content/repositories/snapshots/"

}

}

dependencies {

classpath 'com.android.tools.build:gradle:0.12.2'

classpath 'com.uphyca.gradle:gradle-android-aspectj-plugin:0.9.+'

}

}

def androidAnnotationsVersion = '3.1';

def daggerVersion = '1.2.2';

apply plugin: 'com.android.application'

apply plugin: 'android-aspectj'

android {

compileSdkVersion 19

buildToolsVersion "20.0.0"

defaultConfig {

applicationId "com.flask.aspectjtest"

minSdkVersion 16

targetSdkVersion 20

versionCode 1

versionName "1.0"

}

buildTypes {

release {

runProguard false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

}

}

lintOptions {

abortOnError false

}

sourceSets {

main {

manifest.srcFile 'src/main/AndroidManifest.xml'

java.srcDirs = ['src/main/java', 'build/generated/source/apt/${variant.dirName}']

resources.srcDirs = ['src/main/resources']

res.srcDirs = ['src/main/res']

assets.srcDirs = ['src/main/assets']

}

}

}

configurations {

ajc

aspects

ajInpath

}

ext.aspectjVersion = '1.8.2'

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:20.0.0'

ajc "org.androidannotations:androidannotations:${androidAnnotationsVersion}"

compile "org.androidannotations:androidannotations:${androidAnnotationsVersion}"

ajc "com.squareup.dagger:dagger-compiler:${daggerVersion}"

compile "com.squareup.dagger:dagger:${daggerVersion}"

}

现在,

:app:generateDebugSources UP-TO-DATE

Note: Resolve log file to /Users/flask/Documents/workspace_android/AspectJTest/app/build/intermediates/classes/androidannotations.log

Note: Initialize AndroidAnnotations 3.1 with options {}

Note: Start processing for 2 annotations on 13 elements

error: Could not find the AndroidManifest.xml file, going up from path [/Users/flask/Documents/workspace_android/AspectJTest/app/build/intermediates/classes/debug] found using dummy file [] (max atempts: file:///Users/flask/Documents/workspace_android/AspectJTest/app/build/intermediates/classes/debug/dummy1412644771646)

Note: Time measurements: [Whole Processing = 10 ms], [Extract Annotations = 7 ms], [Extract Manifest = 2 ms],

Note: Finish processing

Note: Start processing for 0 annotations on 0 elements

Note: Time measurements: [Whole Processing = 0 ms],

Note: Finish processing

1 error

:app:compileDebugJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:

Execution failed for task ':app:compileDebugJava'.

> Compilation failed; see the compiler error output for details.

* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 3.596 secs

Compilation failed; see the compiler error output for details.

10:19:31: External task execution finished 'build'.

androidannotations.log在下面.

10:17:30.890 [Daemon Thread 2] INFO o.a.AndroidAnnotationProcessor:84 - Initialize AndroidAnnotations 3.1 with options {}

10:17:31.58 [Daemon Thread 2] INFO o.a.AndroidAnnotationProcessor:108 - Start processing for 2 annotations on 13 elements

10:17:31.77 [Daemon Thread 2] ERROR o.a.h.AndroidManifestFinder:134 - Could not find the AndroidManifest.xml file, going up from path [/Users/flask/Documents/workspace_android/AspectJTest/app/build/intermediates/classes/debug] found using dummy file [] (max atempts: file:///Users/flask/Documents/workspace_android/AspectJTest/app/build/intermediates/classes/debug/dummy1412644651076)

10:17:31.78 [Daemon Thread 2] INFO o.a.p.TimeStats:81 - Time measurements: [Whole Processing = 19 ms], [Extract Annotations = 15 ms], [Extract Manifest = 2 ms],

10:17:31.78 [Daemon Thread 2] INFO o.a.AndroidAnnotationProcessor:122 - Finish processing

10:19:31.568 [Daemon Thread 3] INFO o.a.AndroidAnnotationProcessor:84 - Initialize AndroidAnnotations 3.1 with options {}

10:19:31.637 [Daemon Thread 3] INFO o.a.AndroidAnnotationProcessor:108 - Start processing for 2 annotations on 13 elements

10:19:31.647 [Daemon Thread 3] ERROR o.a.h.AndroidManifestFinder:134 - Could not find the AndroidManifest.xml file, going up from path [/Users/flask/Documents/workspace_android/AspectJTest/app/build/intermediates/classes/debug] found using dummy file [] (max atempts: file:///Users/flask/Documents/workspace_android/AspectJTest/app/build/intermediates/classes/debug/dummy1412644771646)

10:19:31.648 [Daemon Thread 3] INFO o.a.p.TimeStats:81 - Time measurements: [Whole Processing = 10 ms], [Extract Annotations = 7 ms], [Extract Manifest = 2 ms],

10:19:31.648 [Daemon Thread 3] INFO o.a.AndroidAnnotationProcessor:122 - Finish processing

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值