Does anybody know how to use Android Annotations with the jack compiler ?
Here my app/build.gradle and here my project build.gradle
With this configuration, I have this error message when I build my project :
Error:Could not get unknown property 'classpath' for task ':app:transformJackWithJackForDebug' of type com.android.build.gradle.internal.pipeline.TransformTask.
You should remove the android-apt plugin and the apt block completely, because it does not work with Jack annotation processing. Also, you have to declare processsors in the annotationProcessor configuration. Lastly, you have to add the annotation processing parameters to jack (which has no public API per-variant, yet).
Here is your modified build.gradle:
repositories {
jcenter()
mavenCentral()
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.frlgrd.streamzone"
minSdkVersion 21
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
// Android Annotations
def AAVersion = '4.0.0'
dependencies {
// Google
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
// Android Annotations
annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
// RX
compile 'com.tbruyelle.rxpermissions:rxpermissions:0.7.1#aar'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.6'
}
// add annotation processing options to jack
android.applicationVariants.all { variant ->
variant.variantData.variantConfiguration.javaCompileOptions.annotationProcessorOptions
.arguments = ['androidManifestFile': variant.outputs[0]?.processResources?.manifestFile?.absolutePath]
}
Related
I'm beginner with android and gradle. I saw this error so I removed the hamcrest dependency from my module gradle but I still see the following error:
Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
Conflict with dependency 'org.hamcrest:hamcrest-core' in project ':app'. Resolved versions for app (1.1) and test app (1.3)
differ.
This dependency is causing the problem:
compile 'com.android.support.test:testing-support-lib:0.1'
app grade:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
module gradle (I have a single module):
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.stavalfi.app1"
minSdkVersion 18
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
implementation 'com.google.android.gms:play-services-maps:11.0.4'
implementation 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.firebase:firebase-core:11.0.4'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
compile 'com.android.support:support-annotations:22.2.0'
androidTestCompile 'com.android.support.test:runner:1.0.0'
androidTestCompile 'com.android.support.test:rules:1.0.0'
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.0'
compile 'com.android.support.test:testing-support-lib:0.1'
compile 'com.android.support.test.uiautomator:uiautomator-v18:2.0.0'
}//testImplementation
apply plugin: 'com.google.gms.google-services'
What I have tried:
//testCompile 'junit:junit:4.12'
testCompile('junit:junit:4.12') { // Prevent duplication conflicts
exclude module: 'hamcrest-core'
exclude module: 'hamcrest-library'
exclude module: 'hamcrest-integration'
}
But I get the same error.
I also saw this solution but I don't know where to add the configurations exactly:
Robolectric 3.0-rc2 Hamcrest-core conflict
And I don't see why I need to have this problem if I don't use hamcrest anyway.
Thanks!
add configuration.all below buildtypes.
configurations.all {}
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.nfs.ui.notesapp"
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations.all {
resolutionStrategy.force 'com.android.support:support-annotations:24.0.0'
}
}
I'm working on an Android library that allows communication with a Bluetooth device. The library itself has two important dependencies.
The goal is to make an .aar available of the library for others to include in their apps, with a sample app being available for reference.
I'm currently working on the sample app, and I've successfully imported the library into the app, but the library's dependencies are not being included so I'm receiving errors such as java.lang.NoClassDefFoundError: Failed resolution of: ...
It was my understanding that the library's gradle file would be used when compiling the library, but this does not seem to be the case?
My library's gradle file is as follows:
apply plugin: 'com.android.library'
apply plugin: 'me.tatarka.retrolambda'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.6.0'
}
}
repositories {
mavenLocal()
}
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
publishNonDefault true
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:support-annotations:25.3.1'
compile 'com.polidea.rxandroidble:rxandroidble:1.3.2'
compile 'com.github.zafarkhaja:java-semver:0.9.0'
testCompile 'junit:junit:4.12'
}
Any ideas?
Below is my app.gradle apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.crayond.vlearning"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
jackOptions {
enabled true
}
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
incremental false
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile project(':recyclerview')
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'
compile 'com.github.Kunzisoft:Android-SwitchDateTimePicker:1.5'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.yalantis:phoenix:1.2.3'
testCompile 'junit:junit:4.12'
/* compile 'com.google.dagger:dagger:2.0'
annotationProcessor 'com.google.dagger:dagger-compiler:2.0'*/
annotationProcessor 'org.androidannotations:androidannotations:4.1.0'
compile 'org.androidannotations:androidannotations-api:4.1.0'
}
I get the following error while syncing gradle:
Error:Could not get unknown property 'classpath' for task ':app:transformJackWithJackForDebug' of type com.android.build.gradle.internal.pipeline.TransformTask.
To update your android project jdk version to 1.8 use retrolambda library.
In your app level build.gradle file add:
1.
apply plugin: 'me.tatarka.retrolambda' in the top of the file.
2.
android{
//Other stuff
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
3. And then add new dependency to your project level build.gradle file.
dependencies {
//Other dependencies
classpath 'me.tatarka:gradle-retrolambda:3.4.0'
}
Voila! Now you are able to use java 1.8 features in your android project.
Am getting en error while try to run the project
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/annotation/DimenRes.class
Here is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Inc.:Google APIs:23'
buildToolsVersion "24.0.0"
compileOptions.encoding = 'windows-1251'
defaultConfig {
applicationId "org.radiomango.app"
minSdkVersion 11
targetSdkVersion 23
multiDexEnabled true
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
}
buildTypes {
release {
minifyEnabled true
proguardFiles 'proguard.cfg'
}
}
}
dependencies {
compile 'com.google.code.gson:gson:2.2.2'
compile files('libs/acra-4.5.0.jar')
compile files('libs/android-support-v13.jar')
compile files('libs/org.apache.commons.httpclient.jar')
compile files('libs/org.apache.http.legacy.jar')
compile project(':seekArc_library')
compile project(':socialauthandroid')
compile project(':SwipeMenuListView')
compile 'com.android.support:design:24.0.0'
}
i tried by cleaning the project
Build - > Clean
after that rebuild, But no effect
The i sync and clean the project, still no result.
Finally i restart the android studio, but the issue still exciting.
Can any one please help me
I think this is because you use compile files('libs/android-support-v13.jar') and compile 'com.android.support:design:24.0.0' may be this library are conflicting with each other.
Exclude part of library which is common in both of them.
Using exclude
e.g.
compile('com.commonsware.cwac:camera-v9:0.5.4') {
exclude module: 'support-v4'
}
Replace
compile files('libs/android-support-v13.jar')
with
com.android.support:support-v13:24.0.0
You added the design library, which also makes use of the support-v4 lib. If you add both via maven-dependency, this should be handled by gradle.
Replace
compile files('libs/android-support-v13.jar')
with
com.android.support:support-v13:24.0.0
Apply this in gradle also add packagingOptions
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Inc.:Google APIs:23'
buildToolsVersion "24.0.0"
compileOptions.encoding = 'windows-1251'
defaultConfig {
applicationId "org.radiomango.app"
minSdkVersion 11
targetSdkVersion 23
multiDexEnabled true
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
packagingOptions {
exclude 'META-INF/NOTICE.txt' // will not include NOTICE file
exclude 'META-INF/LICENSE.txt' // will not include LICENSE file
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
}
buildTypes {
release {
minifyEnabled true
proguardFiles 'proguard.cfg'
}
}
}
dependencies {
compile 'com.google.code.gson:gson:2.2.2'
compile files('libs/acra-4.5.0.jar')
compile 'com.android.support:appcompat-v7:23.4.0'
complie `com.android.support:support-v13:24.0.0` //or you used 23.4.0
compile files('libs/org.apache.commons.httpclient.jar')
compile files('libs/org.apache.http.legacy.jar')
compile project(':seekArc_library')
compile project(':socialauthandroid')
compile project(':SwipeMenuListView')
compile 'com.android.support:design:24.0.0'//or you used compile 'com.android.support:design:23.4.0'
}
I'm using Android Studio 1.1 beta 4 with gradle plugin 1.0.1 and trying to add Android Annotations to my project following the official insturctions. So I get the following build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "ru.itloft.moneytracker"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
}
}
def AAVersion = '3.2'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile 'org.springframework.android:spring-android-rest-template:2.0.0.M1'
compile 'com.google.code.gson:gson:2.3'
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
}
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
// if you have multiple outputs (when using splits), you may want to have other index than 0
resourcePackageName 'ru.itloft.moneytracker'
// If you're using Android NBS flavors you should use the following line instead of hard-coded packageName
// resourcePackageName android.defaultConfig.packageName
// You can set optional annotation processing options here, like these commented options:
// logLevel 'INFO'
// logFile '/var/log/aa.log'
}
}
And all works fine, but I get a warning in the line androidManifestFile variant.outputs[0].processResources.manifestFile saying: 'getAt' in 'org.codehaus.groovy.runtime.DefaultGroovyMethods' cannot be applied to '(java.lang.Integer)'. How can I get rid of this warning?
How #WonderCsabo already told this is a false positive. You can avoid this warning if you access the outputs explicit as collection
androidManifestFile variant.outputs.collect()[0].processResources.manifestFile