I cannot compile my project, scenario i converted one of my activity to kotlin using Android Studio's "Convert Java File to Kotlin File" and fixed all errors for code that was not properly converted.
Java complier log:
Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
com.android.tools.r8.CompilationFailedException: Compilation failed to complete
com.android.tools.r8.utils.AbortException: Error: null, Cannot fit requested classes in a single dex file (# methods: 110666 > 65536 ; # fields: 67264 > 65536)
build.gradle (app)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
versionName "2.2.4"
versionCode 13
minSdkVersion 16
targetSdkVersion 27
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
debug {
applicationIdSuffix ".debug"
versionNameSuffix ".d.5"
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "server"
productFlavors {
prod {
applicationId "com.test.test"
dimension "server"
buildConfigField "String", "SERVER_HOST", "\"http://www.test.com\""
}
dev {
applicationId "dev.test.test"
versionNameSuffix ".dev"
dimension "server"
buildConfigField "String", "SERVER_HOST", "\"http://localhost/test\""
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha4', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation('com.crashlytics.sdk.android:crashlytics:2.7.1#aar') {
transitive = true
}
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.schibstedspain.android:leku:6.0.0'
implementation 'com.github.sparklit:adbutler-android-sdk:1.0'
implementation 'com.j256.ormlite:ormlite-core:5.0'
implementation 'com.j256.ormlite:ormlite-android:5.0'
implementation 'com.squareup.okhttp:okhttp:2.4.0'
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.cardview:cardview:1.0.0-beta01'
implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01'
implementation 'com.google.android.material:material:1.0.0-beta01'
implementation 'androidx.vectordrawable:vectordrawable:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.facebook.fresco:fresco:1.9.0'
implementation 'com.jakewharton.timber:timber:4.7.0'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
testImplementation 'junit:junit:4.12'
def nav_version = "1.0.0-alpha09"
implementation "android.arch.navigation:navigation-fragment:$nav_version"
// use -ktx for Kotlin
implementation "android.arch.navigation:navigation-ui:$nav_version"
// use -ktx for Kotlin
implementation 'pub.devrel:easypermissions:1.1.1'
implementation 'devlight.io:navigationtabbar:1.2.5'
}
configurations.all {
exclude group: 'com.google.guava', module: 'listenablefuture'
}
apply plugin: 'com.google.gms.google-services'
repositories {
mavenCentral()
}
build.gradle (project)
buildscript {
ext.kotlin_version = '1.3.11'
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.27.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
maven { url "https://maven.google.com" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My bad (FIXED now)
Add this to build.gradle (app) in defaultConfig
multiDexEnabled true
build.gradle (app)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
versionName "2.2.4"
versionCode 13
minSdkVersion 16
targetSdkVersion 27
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
debug {
applicationIdSuffix ".debug"
versionNameSuffix ".d.5"
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "server"
productFlavors {
prod {
applicationId "com.tfwm.lighting"
dimension "server"
buildConfigField "String", "SERVER_HOST", "\"http://www.test.com\""
}
dev {
applicationId "dev.tfwm.lighting"
versionNameSuffix ".dev"
dimension "server"
buildConfigField "String", "SERVER_HOST", "\"http://localhost/test\""
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha4', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation('com.crashlytics.sdk.android:crashlytics:2.7.1#aar') {
transitive = true
}
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.schibstedspain.android:leku:6.0.0'
implementation 'com.github.sparklit:adbutler-android-sdk:1.0'
implementation 'com.j256.ormlite:ormlite-core:5.0'
implementation 'com.j256.ormlite:ormlite-android:5.0'
implementation 'com.squareup.okhttp:okhttp:2.4.0'
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.cardview:cardview:1.0.0-beta01'
implementation 'androidx.recyclerview:recyclerview:1.0.0-beta01'
implementation 'com.google.android.material:material:1.0.0-beta01'
implementation 'androidx.vectordrawable:vectordrawable:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.facebook.fresco:fresco:1.9.0'
implementation 'com.jakewharton.timber:timber:4.7.0'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
testImplementation 'junit:junit:4.12'
def nav_version = "1.0.0-alpha09"
implementation "android.arch.navigation:navigation-fragment:$nav_version"
// use -ktx for Kotlin
implementation "android.arch.navigation:navigation-ui:$nav_version"
// use -ktx for Kotlin
implementation 'pub.devrel:easypermissions:1.1.1'
implementation 'devlight.io:navigationtabbar:1.2.5'
}
configurations.all {
// this is a workaround for the issue:
// https://stackoverflow.com/questions/52521302/how-to-solve-program-type-already-present-com-google-common-util-concurrent-lis
exclude group: 'com.google.guava', module: 'listenablefuture'
}
apply plugin: 'com.google.gms.google-services'
repositories {
mavenCentral()
}
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex in Android Studio 3.0 [closed]
Also solution is NOT REQUIRED if your minSdkVersion is set to 21 and above
Related
Error:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
Failed to calculate the value of task ':app:compileDebugJavaWithJavac' property 'options.generatedSourceOutputDirectory'.
Querying the mapped value of map(java.io.File property(org.gradle.api.file.Directory, property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, C:\Users\saura\AndroidStudioProjects\FutsalNepal\app\build\generated\ap_generated_sources\debug\out))) org.gradle.api.internal.file.DefaultFilePropertyFactory$ToFileTransformer#63c94fba) before task ':app:compileDebugJavaWithJavac' has completed is not supported
Here is my build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: "androidx.navigation.safeargs.kotlin"
android {
compileSdkVersion 32
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.androiddevs.mvvmnewsapp"
minSdkVersion 21
targetSdkVersion 32
versionCode 1
versionName "1.0"
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 = JavaVersion.VERSION_1_8.toString()
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.3.0-alpha03'
// Architectural Components
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
// Room
implementation "androidx.room:room-runtime:2.2.5"
kapt "androidx.room:room-compiler:2.2.5"
// Kotlin Extensions and Coroutines support for Room
implementation "androidx.room:room-ktx:2.2.5"
// Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5'
// Coroutine Lifecycle Scopes
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0"
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
implementation "com.squareup.okhttp3:logging-interceptor:4.5.0"
// Navigation Components
implementation "androidx.navigation:navigation-fragment-ktx:2.2.1"
implementation "androidx.navigation:navigation-ui-ktx:2.2.1"
implementation 'android.arch.navigation:navigation-fragment-ktx:1.0.0-rc02'
implementation 'android.arch.navigation:navigation-ui-ktx:1.0.0-rc02'
// Glide
implementation 'com.github.bumptech.glide:glide:4.11.0'
kapt 'com.github.bumptech.glide:compiler:4.11.0'
}
Here is my settings.gradle:
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "Futsal Nepal"
include ':app'
I have implementation 'com.google.firebase:firebase-core:16.0.7' and it works great!
After update to implementation 'com.google.firebase:firebase-core:17.2.0' I have so many problems:
Module: app
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 28
defaultConfig {
applicationId "free.success.kneu"
minSdkVersion 19
targetSdkVersion 28
versionCode 223
versionName "2.2.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
useLibrary 'org.apache.http.legacy'
multiDexEnabled true
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:multidex:1.0.3'
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'
implementation 'org.jsoup:jsoup:1.11.3'
implementation 'org.apache.commons:commons-lang3:3.8.1'
implementation 'com.google.firebase:firebase-core:17.2.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
apply plugin: 'com.google.gms.google-services'
Project
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.google.gms:google-services:4.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
flatDir {
dirs 'libs'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
There are several questions but no relevant answer yet.
In my android studio project, I use several libraries with a different version. Now I facing error to run the project. I have some libraries with two different SDK version. One is sdk=25.3.1 and another is sdk=28.0.0
Here is my different build.gradle file.
My Project build.gradle file
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.2.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
}
}
allprojects {
repositories {
google()
maven { url 'http://raw.github.com/saki4510t/libcommon/master/repository/' }
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
supportLibraryVersion = '28.0.0' // variable that can be referenced to keep support libs consistent
supportLibVersion = '25.3.1'
commonLibVersion= '1.5.20'
//versionBuildTool = '26.0.2'
//versionCompiler = 25
//versionTarget = 22
//versionNameString = '1.0.0'
javaSourceCompatibility = JavaVersion.VERSION_1_7
javaTargetCompatibility = JavaVersion.VERSION_1_7
}
app: build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.jiangdg.usbcamera"
minSdkVersion 19
targetSdkVersion 22
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
compile project(':libusbcamera')
compile project(':libmlkit')
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.android.support:design:25.3.1'
}
My Library build.gradle file
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
group='com.github.jiangdongguo'
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion 19
targetSdkVersion 22
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
compile("com.serenegiant:common:${commonLibVersion}") {
exclude module: 'support-v4'
}
}
Another Library build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
aaptOptions {
noCompress "tflite"
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:exifinterface:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
implementation 'com.google.firebase:firebase-ml-vision:18.0.1'
implementation 'com.google.firebase:firebase-ml-vision-image-label-model:17.0.2'
implementation 'co`apply plugin: 'com.google.gms.google-services'
}
The following error occur..
Android dependency 'com.android.support:appcompat-v7' has different version >for the compile (25.3.1) and runtime (28.0.0) classpath. You should manually >set the same version via DependencyResolution
You have to set the config for all project in your build.gradle file
subprojects {
afterEvaluate {
project -> if (project.hasProperty("android")) {
android {
compileSdkVersion 28
buildToolsVersion '28.0.0'
}
}
}
}
then in your apps build.gradle file replace config for all other lib
configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support') {
details.useVersion "28.0.0"
}
}
}
I just updated my CompileSDKVersion and TargetSDK Version to 27, and updated the dependencies accordingly, and now my app won't run, it's getting this error:
Program type already present: com.android.vending.billing.IInAppBillingService
Message{kind=ERROR, text=Program type already present: com.android.vending.billing.IInAppBillingService, sources=[Unknown source file], tool name=Optional.of(D8)}
I'm using a billing library called checkout. I've tried reverting back to 26 and disabling certain dependencies but nothing seems to work.
My App Level Build.Gradle
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "me.paxana.cwnet"
minSdkVersion 16
targetSdkVersion 27
versionCode 9
versionName "2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'com.google.android.gms:play-services-ads:15.0.0'
implementation 'com.google.firebase:firebase-messaging:15.0.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:gridlayout-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:support-media-compat:27.1.1'
implementation 'com.android.support:customtabs:27.1.1'
implementation 'com.android.support:animated-vector-drawable:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.squareup.okhttp3:okhttp:3.9.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.google.firebase:firebase-core:15.0.0'
implementation 'com.google.firebase:firebase-auth:15.0.0'
implementation 'com.google.firebase:firebase-database:15.0.0'
implementation 'com.google.firebase:firebase-ads:15.0.0'
implementation 'com.google.firebase:firebase-crash:15.0.0'
implementation 'com.firebaseui:firebase-ui-auth:3.3.0'
implementation 'com.firebaseui:firebase-ui-database:3.0.0'
implementation 'org.solovyev.android:checkout:1.2.1'
implementation 'com.google.android.gms:play-services-auth:15.0.0'
implementation 'com.facebook.android:facebook-android-sdk:4.29.0'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.daimajia.slider:library:1.1.5#aar'
implementation 'me.zhanghai.android.materialratingbar:library:1.2.0'
implementation 'com.squareup.moshi:moshi:1.5.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.7.1#aar') {
transitive = true
}
implementation 'com.anthonymandra:ToggleButtons:2.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.jakewharton:butterknife:8.8.1'
implementation 'com.mikepenz:iconics-core:3.0.3#aar'
implementation 'com.mikepenz:fontawesome-typeface:5.0.6.0#aar'
implementation 'com.anjlab.android.iab.v3:library:1.0.44'
testImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
my project level build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
google()
maven {
url 'https://maven.fabric.io/public'
}
maven { url 'https://repo.spring.io/plugins-snapshot' }
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.google.gms:google-services:3.2.1'
classpath 'io.fabric.tools:gradle:1.24.4'
classpath 'io.spring.gradle:dependency-management-plugin:1.0.6.BUILD-SNAPSHOT'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
jcenter()
maven {
url "https://maven.google.com" // Google's Maven repository
}
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I am very new to Gradle and Android but since I have added Kotlin to my project anytime I get an error in Android Studio I need to go through the Gradle console which does not give me any of the nice stack traces or pathing by default. In the Gradle messages view where errors did appear now I only get
Error:Execution failed for task ':app:kaptDebugKotlin'.
Internal compiler error. See log for more details
Is this the intended functionality because it seems to work ok in the jetbrains example projects.
My Project Gradle file
buildscript {
ext.kotlin_version = '1.1.4-2'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
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()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My App level Gradle file
buildscript {
ext.kotlin_version = '1.1.4-2'
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.test.andrew.ccombo_breaker"
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'
}
}
sourceSets {
main.java.srcDirs += 'src/main/java'
main.java.srcDirs += 'src/main/kotlin'
}
}
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:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.google.dagger:dagger:2.9'
kapt 'com.google.dagger:dagger-compiler:2.9'
testCompile 'junit:junit:4.12'
}
I did not see any problems,May be you can see here [Gradle Console] ,it print all bulid log.you can see error details,and post error message.
That is old config,May be you can config new like this:
1.remove all about Kotlin config.
2.use the menu->tools-->Kotlin-->Configure Kotlin in project-->Android with Gradle
3.change version to 1.1.2-2, the version 1.1.4-2 for gradle:2.3.3 has something bug
4.Sync gradle
other. The new version use extensions only config this:
apply plugin: 'kotlin-android-extensions'
dont use this:
dependencies {
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
}
ultimate,config like this
Project Gradle file
buildscript {
ext.kotlin_version = '1.1.2-2'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
App level Gradle file
apply plugin: 'kotlin-kapt'
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.test.andrew.ccombo_breaker"
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'
}
}
}
kapt {
generateStubs = 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:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile 'com.google.dagger:dagger:2.9'
kapt 'com.google.dagger:dagger-compiler:2.9'
testCompile 'junit:junit:4.12'
}
Kotlin official doc