I'm having hard time with configuration of a testing environment based on JUnit Jupiter (5). I have two different errors there:
WARNING: TestEngine with ID 'spek' failed to discover tests
org.junit.platform.commons.util.PreconditionViolationException: Could not load class with name...
Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform.launcher.Launcher.execute(Lorg/junit/platform/launcher/LauncherDiscoveryRequest;)V
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:61)...
And the configuration goes as follows.
Main build.gradle:
apply plugin: 'org.junit.platform.gradle.plugin'
buildscript {
ext.kotlin_version = '1.1.4-3'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta5'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.junit.platform:junit-platform-gradle-plugin:1.0.0"
classpath "de.mannodermaus.gradle.plugins:android-junit5:1.0.0"
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "http://dl.bintray.com/jetbrains/spek" }
}
}
junitPlatform {
filters {
engines {
include 'spek'
}
}
}
Module build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'de.mannodermaus.android-junit5'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
...
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
...
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.0.2'
implementation 'com.android.support:recyclerview-v7:26.0.2'
testImplementation 'org.jetbrains.spek:spek-api:1.1.4'
testImplementation 'org.jetbrains.spek:spek-junit-platform-engine:1.1.4'
testImplementation junit5()
// testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.0.0' not needed when using the one above
testImplementation 'org.junit.platform:junit-platform-runner:1.0.0'
testImplementation 'org.mockito:mockito-core:2.8.47'
testImplementation 'com.nhaarman:mockito-kotlin-kt1.1:1.5.0'
testCompileOnly "de.mannodermaus.gradle.plugins:android-junit5-embedded-runtime:1.0.0"
}
This configuration is supposed to be based on https://github.com/aurae/android-junit5. But I also tried without it.
Have anyone managed to find a working configuration of dependencies for these libraries?
As posted here https://stackoverflow.com/a/48427771/4249825 you need the following in your build.gradle:
app's build.grale:
buildscript {
...
dependencies {
...
classpath "de.mannodermaus.gradle.plugins:android-junit5:1.0.30" // latest atm
}
}
module's build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "de.mannodermaus.android-junit5"
android {
...
sourceSets {
test.java.srcDirs += 'src/test/kotlin'
androidTest.java.srcDirs += 'src/androidTest/kotlin'
}
}
project.ext {
spekVersion = "1.1.5" // latest atm
mockitoKotlinVersion = "2.0.0-alpha02" // latest atm
kluentVersion = "1.34" // latest atm
}
dependencies {
...
//
// TESTS
testCompile "com.nhaarman.mockitokotlin2:mockito-kotlin:$mockitoKotlinVersion"
testImplementation "org.amshove.kluent:kluent-android:$kluentVersion"
testImplementation("org.jetbrains.spek:spek-api:$spekVersion") {
exclude group: "org.jetbrains.kotlin"
}
testImplementation("org.jetbrains.spek:spek-junit-platform-engine:$spekVersion") {
exclude group: "org.junit.platform"
exclude group: "org.jetbrains.kotlin"
}
testImplementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
testImplementation junit5.unitTests()
// see https://github.com/mannodermaus/android-junit5#android-studio-workarounds
testCompileOnly junit5.unitTestsRuntime()
}
Related
My top level build.gradle
apply plugin: 'kotlin'
buildscript {
ext.kotlin_version = '1.3.30'
repositories {
mavenLocal()
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
//region realm
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' }
//endregion
}
dependencies {
//region google()
classpath 'com.android.tools.build:gradle:3.3.2'
//endregion
//region jcenter()
classpath 'com.google.gms:google-services:4.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
//endregion
//region maven { url 'https://maven.fabric.io/public' }
//to check fabric gradle ver
//https://s3.amazonaws.com/fabric-artifacts/public/io/fabric/tools/gradle/maven-metadata.xml
classpath 'io.fabric.tools:gradle:1.+'
//endregion
//region realm
classpath "io.realm:realm-gradle-plugin:5.8.0"
//endregion
}
}
Here is my library module build.gradle
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'realm-android'
android {
...
defaultConfig {
...
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.support:appcompat-v7:${supportLibVer}"
implementation "io.reactivex:rxjava:${rxJavaVersion}"
implementation("io.reactivex:rxandroid:${rxAndroidVersion}") {
exclude group: 'io.reactivex', module: 'rxjava'
}
implementation("com.github.davidmoten:rxjava-extras:${rxExtrasVersion}") {
exclude group: 'io.reactivex', module: 'rxjava'
}
implementation('io.reactivex:rxjava-math:1.0.0') {
exclude group: 'io.reactivex', module: 'rxjava'
}
implementation "com.google.dagger:dagger:${daggerVersion}"
implementation("com.google.dagger:dagger-android-support:${daggerVersion}") {
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.android.support', module: 'support-fragment'
}
annotationProcessor "com.google.dagger:dagger-compiler:${daggerVersion}"
kapt "com.google.dagger:dagger-compiler:${daggerVersion}"
annotationProcessor "com.google.dagger:dagger-android-processor:${daggerVersion}"
kapt "com.google.dagger:dagger-android-processor:${daggerVersion}"
implementation "javax.inject:javax.inject:${javaxInjectVersion}"
implementation "javax.annotation:jsr250-api:${javaxAnnotationVersion}"
implementation "com.android.support:support-annotations:${supportLibVer}"
...
}
In result I can't make Sync, error is:
ERROR: Unable to resolve dependency for ':module#debug/compileClasspath': Could not resolve all dependencies for configuration ':module:debugCompileClasspath'.
Show Details
Affected Modules: module
But if I remote
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
then all works fine
Found issue: it was because of I have failOnVersionConflict() at top build gradle
To fix the issue:
top build.gradle file:
buildscript {
ext.kotlin_version = '1.3.31'
repositories {
mavenLocal()
google()
jcenter()
//region realm
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' }
maven { url 'https://dl.bintray.com/realm/maven' }
//endregion
}
dependencies {
//region google()
classpath 'com.android.tools.build:gradle:3.3.2'
//endregion
//region jcenter()
classpath 'com.google.gms:google-services:4.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
//endregion
//region realm
classpath "io.realm:realm-gradle-plugin:5.11.0"
//endregion
}
}
allprojects {
...
configurations.all {
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jre7'
resolutionStrategy {
// fail eagerly on version conflict (includes transitive dependencies)
// e.g. multiple different versions of the same dependency (group and name are equal)
failOnVersionConflict()
//this is needed:
force "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version",
"org.jetbrains.kotlin:kotlin-android-extensions-runtime:$kotlin_version",
"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version",
}
}
}
I am currently using Realm with Kotlin. Here are my gradle files.
It seems like the order of Kotlin-kapt and kotlin-android-extensions in the app gradle should be switched around. Check below
App gradle file:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
android {
compileSdkVersion 28
defaultConfig {
applicationId "xxx"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0-alpha03'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
implementation 'com.google.android.material:material:1.1.0-alpha04'
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-core:16.0.1'
// Add dependency
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'
androidTestImplementation 'androidx.test:runner:1.1.2-alpha02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha02'
}
apply plugin: 'com.google.gms.google-services'
Root level gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.71'
ext.lifecycle_version = '2.0.0'
ext.anko_version='0.10.8'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:4.0.1'
classpath 'com.android.tools.build:gradle:3.2.1'
// Add dependency
classpath 'io.fabric.tools:gradle:1.26.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.realm:realm-gradle-plugin:5.10.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Change your root build.gradle to
apply plugin: 'kotlin'
buildscript {
ext.kotlin_version = '1.3.31'
repositories {
google()
jcenter()
maven {
url 'http://oss.jfrog.org/artifactory/oss-snapshot-local'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.google.gms:google-services:4.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.realm:realm-gradle-plugin:5.11.0-SNAPSHOT"
}
}
allprojects {
repositories {
jcenter()
google()
maven {
url 'http://oss.jfrog.org/artifactory/oss-snapshot-local'
}
}
}
and it should work just fine (it does sync on my sample project). Note the allprojects block that you forgot. Also, you should apply plugin: 'kotlin-kapt' last.
I want to use the common module both on mobile and backend. In backend module everything works fine, but I can't use common module on mobile. When I was build mobile project I got an error: Project with path ':common' could not be found in project ':app'
Project tree:
kibar
.git
gradle
idea
backend
src
build.gradle
common
src
build.gradle
mobile
.gradle
.idea
app
src
build.gradle
proguard-rules.pro
build.gradle
settings.gradle
settings.gradle
kibar:settings.gradle
rootProject.name = 'kibar'
include 'backend', 'mobile', 'common'
common:build.gradle
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.2.71'
}
repositories {
mavenCentral()
}
sourceSets {
main.kotlin.srcDirs += 'src/main/kotlin'
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:1.2.71"
testCompile group: 'junit', name: 'junit', version: '4.12'
}
backend:build.gradle
buildscript {
ext.kotlin_version = '1.2.71'
repositories {
jcenter()
mavenCentral()
maven { url "http://dl.bintray.com/kotlin/kotlin-eap" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'kotlin-kapt'
apply plugin: 'application'
sourceCompatibility = 1.8
mainClassName = "App"
repositories {
jcenter()
mavenCentral()
maven { url "https://dl.bintray.com/kotlin/exposed" }
maven { url "http://dl.bintray.com/kotlin/kotlin-eap" }
}
dependencies {
compile project(":common")
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
kotlin {
experimental {
coroutines "enable"
}
}
idea {
module {
sourceDirs += files('build/generated/source/kapt/main', 'build/generated/source/kaptKotlin/main')
generatedSourceDirs += files('build/generated/source/kapt/main', 'build/generated/source/kaptKotlin/main')
}
}
sourceSets {
main.resources.srcDir('conf')
main.java.srcDirs += 'src/main/java'
main.java.srcDirs += 'src/main/kotlin'
test.java.srcDirs += 'src/test/kotlin'
}
mobile:build.gradle
buildscript {
ext{
kotlin_version = "1.2.71"
lifecycle_version = "2.0.0"
}
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://maven.google.com" }
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0-alpha13'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://maven.google.com" }
maven { url "https://jitpack.io" }
}
}
mobile:settings.gradle
include ':app'
mobile.app:build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
buildToolsVersion = '28.0.3'
compileSdkVersion 28
defaultConfig {
versionCode 1
versionName "1.0"
applicationId "com.example"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
androidExtensions {
experimental = true
}
kapt {
generateStubs = true
}
kotlin {
experimental {
coroutines "enable"
}
}
dependencies {
compile project(':common')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.30.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:0.30.2'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.core:core-ktx:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.android.material:material:1.0.0'
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
}
You should have only one settings.gradle file in your whole project, at root directory level. Remove the mobile/settings.gradle.
Gradle multi-project build is expecting a single settings.gradlefile located in project root directory , and this settings.gradlemust declare all sub-projects. In your case, you need to add mobile:app sub-project in your kibar:settings.gradle file:
rootProject.name = 'kibar'
include 'backend', 'mobile:app', 'common'
For reference: https://docs.gradle.org/current/userguide/build_lifecycle.html#sec:settings_file
I'm developing an android application. I've an 'dependencies.gradle' file in the root project:
ext {
// Android
kotlinVersion = '1.2.51'
gradleVersion = '3.1.3'
}
The problem is that I can use this properties in the App 'build.gradle' file but can't use inside Root 'build.gradle' file and it gives me this error:
Could not get unknown property 'kotlinVersion' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
This is my 'Root Build Gradle':
apply from: 'dependencies.gradle'
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:3.1.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And this is my 'App Build Gradle' :
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.shimibox.client"
minSdkVersion 18
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
I've found the problem. The ext must be inside the buildscript block. So I moved the apply from: 'dependencies.gradle' inside of that block.
Now Root build.gradle file is:
buildscript {
apply from: 'dependencies.gradle'
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:3.1.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
Out of nowhere, I suddenly can no longer import or use any Firebase classes. The class names show up in intellisense, but when hitting tab to import, it inserts their fully qualified name, and an error in the class name.
build.gradle (app)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 'android-P'
defaultConfig {
applicationId "com.opticalgenesis.lbp.dogg"
minSdkVersion 21
targetSdkVersion 'P'
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.0'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-ml-model-interpreter:16.0.0'
implementation 'com.google.android.material:material:1.0.0-alpha1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
}
apply plugin: 'com.google.gms.google-services'
build.gradle (project)
buildscript {
ext.kotlin_version = '1.2.41'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0-alpha16'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url="https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
small snippet
private fun setupModel() {
val builder = com.google.firebase.ml.custom.model.FirebaseModelDownloadConditions.Builder()
}
FirebaseModelDownloadConditions is not the only class that doesn't import, they all don't.
Any help is appreciated.
Thanks.
Android Studio 2.3.3
My project bulid.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.3'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:2.0.0-alpha6'
classpath "io.realm:realm-gradle-plugin:3.5.0"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://dl.bintray.com/jetbrains/anko' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
repositories {
mavenCentral()
}
My app build.gradle.
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
dexOptions {
jumboMode = true
}
defaultConfig {
applicationId "my.project.com"
minSdkVersion 15
targetSdkVersion 23
versionCode 53
versionName "1.1.13"
javaCompileOptions {
annotationProcessorOptions {
arguments = ["resourcePackageName": android.defaultConfig.applicationId]
}
}
}
// exclude buildTypes = "debug" from build Variants
variantFilter { variant ->
if (variant.buildType.name.equals('debug')) {
variant.setIgnore(true);
}
}
buildTypes {
def APP_NAME_STAGE = "My project Stage"
def APP_ID_SUFFIX_STAGE = ".stage"
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
stage {
initWith(debug)
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
lintOptions {
abortOnError false
}
}
def AAVersion = '4.3.0'
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile('com.digits.sdk.android:digits:1.11.0#aar') {
transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics:2.6.0#aar') {
transitive = true;
}
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.baoyz.swipemenulistview:library:1.3.0'
compile 'com.google.android.gms:play-services-gcm:9.0.2'
compile 'com.google.code.gson:gson:2.7'
compile 'com.miguelcatalan:materialsearchview:1.4.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.7.3'
compile 'com.squareup.okhttp:okhttp:2.7.3'
compile 'com.theartofdev.edmodo:android-image-cropper:2.2.5'
compile 'commons-codec:commons-codec:1.9'
compile 'commons-io:commons-io:2.4'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'org.apache.httpcomponents:httpcore:4.4.4'
compile 'org.apache.httpcomponents:httpmime:4.3.6'
compile 'us.feras.mdv:markdownview:1.1.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.jetbrains.anko:anko-sdk15:0.9.1'
annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
testCompile 'junit:junit:4.12'
}
And project bulid and run success.
So now I want to add Realm. I add in build.gradle
apply plugin: 'realm-android'
And as result I get error.
Error:Annotation processor '__gen.AnnotationProcessorWrapper_stage_io_realm_processor_RealmProcessor' not found
Error:Execution failed for task ':app:compileStageJavaWithJavac'.
Compilation failed; see the compiler error output for details.
:app:compileDevJavaWithJavac
Destination for generated sources was modified by kapt. Previous value = myProject\app\build\generated\source\apt\dev
error: Annotation processor '__gen.AnnotationProcessorWrapper_dev_io_realm_processor_RealmProcessor' not found
I found solution. Two approach:
By apt plugin
in app's budile.gradle:
apply plugin: 'com.neenbedankt.android-apt'
apt {
arguments {
resourcePackageName android.defaultConfig.applicationId
androidManifestFile variant.outputs[0]?.processResources?.manifestFile
}
}
dependencies {
apt 'io.realm:realm-android-library:3.5.0'
apt "org.androidannotations:androidannotations:$AAVersion"
}
OR
By kapt plugin
apply plugin: 'kotlin-kapt'
kapt {
arguments {
arg( "resourcePackageName", android.defaultConfig.applicationId)
arg( "androidManifestFile",
variant.outputs[0]?.processResourcesTask?.manifestFile)
}
}
dependencies {
kapt 'io.realm:realm-android-library:3.5.0'
kapt "org.androidannotations:androidannotations:$AAVersion"
}
If you use Kotlin, then you'll need to use KAPT.
annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
should be
kapt "org.androidannotations:androidannotations:$AAVersion"
and
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'
should be
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'
and
// javaCompileOptions {
// annotationProcessorOptions {
// arguments = ["resourcePackageName": android.defaultConfig.applicationId]
// }
// }
kapt {
arguments {
arg('resourcePackageName', android.defaultConfig.applicationId)
}
}
EDIT: based on https://stackoverflow.com/a/34708575/2413303
kapt {
arguments {
arg('androidManifestFile', variant.outputs[0]?.processResources?.manifestFile)
arg('resourcePackageName', android.defaultConfig.applicationId)
}
}
If that still doesn't work, then the question becomes AndroidAnnotations related.