I am using some kotlin classes in an existing Android project(already having realm), the kotlin classes are not using any realm feature, now on runtime I am getting this error
:app:compileDebugKotlin
Using kotlin incremental compilation
:app:compileDebugJavaWithJavac
Destination for generated sources was modified by kapt. Previous value = /home/debu/AndroidStudioProjects/WT_Application/app/build/generated/source/apt/debug
error: Annotation processor '__gen.AnnotationProcessorWrapper_debug_io_realm_processor_RealmProcessor' not found
1 error
:app:compileDebugJavaWithJavac FAILED
:app:copyDebugKotlinClasses SKIPPED
FAILURE: Build failed with an exception.
my app's build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'realm-android'
android {
def globalConfiguration = rootProject.extensions.getByName("ext")
compileSdkVersion globalConfiguration.getAt("androidCompileSdkVersion")
buildToolsVersion globalConfiguration.getAt("androidBuildToolsVersion")
defaultConfig {
applicationId globalConfiguration.getAt("androidApplicationId")
minSdkVersion globalConfiguration.getAt("androidMinSdkVersion")
targetSdkVersion globalConfiguration.getAt("androidTargetSdkVersion")
versionCode globalConfiguration.getAt("androidVersionCode")
versionName globalConfiguration.getAt("androidVersionName")
testInstrumentationRunner globalConfiguration.getAt("testInstrumentationRunner")
/*jackOptions {
enabled true
}*/
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
dataBinding {
enabled = true
}
}
dependencies {
def presentationDependencies = rootProject.ext.presentationDependencies
def presentationTestDependencies = rootProject.ext.presentationTestDependencies
def developmentDependencies = rootProject.ext.developmentDependencies
compile presentationDependencies.dagger
compile presentationDependencies.butterKnife
compile presentationDependencies.recyclerView
compile presentationDependencies.cardview
compile presentationDependencies.rxJava
compile presentationDependencies.rxAndroid
compile presentationDependencies.appcompat
compile presentationDependencies.constraintLayout
compile presentationDependencies.design
compile presentationDependencies.retrofit
compile presentationDependencies.gsonconverter
compile presentationDependencies.rxjavaadapter
compile presentationDependencies.glide
compile presentationDependencies.flexbox
compile presentationDependencies.maps
compile presentationDependencies.mapUtils
compile presentationDependencies.pagerIndicator
annotationProcessor presentationDependencies.daggerCompiler
annotationProcessor presentationDependencies.butterKnifeCompiler
provided presentationDependencies.javaxAnnotation
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
androidTestCompile presentationTestDependencies.junit
androidTestCompile presentationTestDependencies.mockito
androidTestCompile presentationTestDependencies.dexmaker
androidTestCompile presentationTestDependencies.dexmakerMockito
androidTestCompile presentationTestDependencies.espresso
androidTestCompile presentationTestDependencies.testingSupportLib
//Development
compile developmentDependencies.leakCanary
compile files('libs/YouTubeAndroidPlayerApi.jar')
}
repositories {
mavenCentral()
}
project build.gradle
apply from: 'buildsystem/dependencies.gradle'
buildscript {
ext.kotlin_version = '1.1.2-4'
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath "io.realm:realm-gradle-plugin:3.2.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 {
ext {
androidApplicationId = 'com.wandertrails'
androidVersionCode = 1
androidVersionName = "1.0"
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
testApplicationId = 'com.wandertrails.test'
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Now can someone kindly figure out what is the reason of this error????
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
And
kapt presentationDependencies.daggerCompiler
kapt presentationDependencies.butterKnifeCompiler
Might fix it.
Related
I made a project, Gradle sync does succeed but when I run ord debug project the Gradle returns errors, I search on the internet but no luck. I'm a beginner in android studio, someone can do the code of Gradle?
build.gradle(project) :
buildscript {
ext.kotlin_version = '1.6.21'
repositories {
google()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.android.tools.build:gradle:7.2.1'
}
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(module) :
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-android-extensions'
id 'com.google.gms.google-services'
}
android {
compileSdk 32
buildFeatures {
viewBinding = true
}
defaultConfig {
applicationId "com.example.progetto_tpsi"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.firebase:firebase-database:20.0.5'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation'com.android.tools.build:gradle:7.2.1'
implementation 'com.github.bumptech.glide:glide:4.4.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'
implementation 'org.greenrobot:eventbus:3.3.1'
implementation 'com.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
}
settins.gradle :
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "progetto_tpsi"
include ':app'
ERROR:
Task :app:dexBuilderDebug
FAILURE: Build completed with 3 failures.
1: Task failed with an exception.
I was integrating Crashlytics following this article
https://firebase.google.com/docs/crashlytics/get-started
This is my project level gradle
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
// Add dependency
classpath 'io.fabric.tools:gradle:1.27.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://maven.google.com' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
// Define versions in a single place
ext {
// Sdk and tools
minSdkVersion = 16
targetSdkVersion = 28
compileSdkVersion = 28
// App dependencies
supportLibraryVersion = '27.1.1'
sqlbriteVersion = '0.7.0'
rxjavaVersion = '2.0.8'
rxandroidVersion = '2.0.1'
retrofitVersion = '2.3.0'
daggerVersion = '2.11'
playServicesVersion = '16.0.0'
constraintLayoutVersion='2.0.0-alpha2'
roomVersion = '1.0.0'
picassoVersion = '2.5.2'
flexboxVersion = '0.3.2'
firebaseMessagingVersion='17.3.4'
firebaseCoreVersion='16.0.6'
crashlyticsVersion='2.9.8'
}
This is my app level gradle
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.seed.app"
minSdkVersion 17
targetSdkVersion 26
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = 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 {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//dagger
compile "com.google.dagger:dagger:$rootProject.daggerVersion"
annotationProcessor "com.google.dagger:dagger-compiler:$rootProject.daggerVersion"
compile "com.google.dagger:dagger-android:$rootProject.daggerVersion"
compile "com.google.dagger:dagger-android-support:$rootProject.daggerVersion"
implementation 'com.android.support:multidex:1.0.3'
//firebase
implementation "com.google.firebase:firebase-messaging:$rootProject.firebaseMessagingVersion"
implementation "com.google.firebase:firebase-core:$rootProject.firebaseCoreVersion"
// Crashlytics
implementation "com.crashlytics.sdk.android:crashlytics:$rootProject.crashlyticsVersion"
}
repositories {
mavenCentral()
}
apply plugin: 'com.google.gms.google-services'
This is how I crash my application in the MainActivity.
Crashlytics.getInstance().crash();
I am unable to get any errors in my firebase console and get an error message in the log
2019-01-02 20:36:55.139 21274-21274/com.seed.app E/CrashlyticsCore: This app relies on Crashlytics. Please sign up for access at https://fabric.io/sign_up,
install an Android build tool and ask a team member to invite you to this app's organization.
What has my crashlytics installation gotta do with Fabric?
I was able to get this to work by repositioning the apply plugins in my app gradle to
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
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"
}
}
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.
I have next issue during the project building process: build process just stuck on app:kaptDebugKotlin task.
My root project build.gradle:
apply plugin: "kotlin"
buildscript {
ext.kotlin_version = '1.1.2-2'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
}
ext {
buildToolsVersion = '25.0.2'
supportLibVersion = '25.3.1'
runnerVersion = '0.5'
rulesVersion = '0.5'
espressoVersion = '2.2.2'
archLifecycleVersion = '1.0.0-alpha1'
archRoomVersion = '1.0.0-alpha1'
}
and the app build.gradle itself:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 25
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.test.roomtest"
minSdkVersion 14
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'
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.3.1'
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'io.reactivex.rxjava2:rxjava:2.1.0'
compile "io.reactivex.rxjava2:rxandroid:2.0.1"
compile "android.arch.persistence.room:runtime:${rootProject.archRoomVersion}"
compile "android.arch.persistence.room:rxjava2:${rootProject.archRoomVersion}"
kapt "android.arch.persistence.room:compiler:${rootProject.archRoomVersion}"
}
repositories {
mavenCentral()
}
I tried to use different plugin versions but it didn't help. As for using Room seems it's not a problem because this example builds without problems. Will be very appreciate for any help.
Is this still an issue?
The same problem for me was resolved by just using the newest kotlin - 1.3.60.