Android Studio 3 can't build my project - java

I am using Android Studio 3 preview to code and build a android kotlin project but it does not seem to compile due to this error:
: java.lang.Exception: Unable to get response from daemon in 10000 ms
Could not perform incremental compilation: Could not connect to Kotlin
compile daemon Could not connect to kotlin daemon. Using fallback
strategy.
Error:Failed to complete Gradle execution.
Cause:
Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)
Here is my gradle build file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.3-2'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha9'
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 {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
buildToolsVersion '26.0.1'
defaultConfig {
applicationId "com.jr.app"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
buildConfigField "String", "DEMO_SERVER_URL", "https://demoserver.restlet.net/v1/"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:26.0.0'
implementation 'com.android.support:design:26.0.0'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.android.support:support-v4:26.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.0'
}
Thanks

Maybe you have the same error I had.
I solved here

Try to close android studio, delete .gradle and then open it. I had the same problem and it's fixed now.

Related

Unable to resolve dependency error while integrating any liabrary in android studio 3.1.3

Recently i have updated android studio to 3.1.3 everytime i am getting the "Unable to resolve Ddependency" error. Stuck with this problem already i have wasted lotts of days solving this error but nothing works. Please help me to resolve this error.I have uploaded my gradle file here and also the error log.
Below is my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.administrator.myapplication1"
minSdkVersion 15
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'
}
}
`}`
`repositories {`
`maven {`
url "https://jitpack.io"
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.android.support:design:27.1.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation('com.github.ozodrukh:CircularReveal:2.0.1#aar') {
transitive = true;
}
implementation project(':library')
api 'com.github.ozodrukh:CircularReveal:1.1.1'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.google.gms.google-services'
`
Error log:
Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Unable to resolve dependency for ':app#debug/compileClasspath': Could not download okhttp.jar (com.squareup.okhttp3:okhttp:3.11.0): Skipped due to earlier error
Open File
Show Details
Unable to resolve dependency for ':app#debugAndroidTest/compileClasspath': Could not download okhttp.jar (com.squareup.okhttp3:okhttp:3.11.0): Skipped due to earlier error
Open File
Show Details
Unable to resolve dependency for ':app#debugUnitTest/compileClasspath': Could not download okhttp.jar (com.squareup.okhttp3:okhttp:3.11.0): Skipped due to earlier error
Open File
Show Details
Unable to resolve dependency for ':app#release/compileClasspath': Could not download okhttp.jar (com.squareup.okhttp3:okhttp:3.11.0): Skipped due to earlier error
Open File
Show Details
Unable to resolve dependency for ':app#releaseUnitTest/compileClasspath': Could not download okhttp.jar (com.squareup.okhttp3:okhttp:3.11.0): Skipped due to earlier error
Open File
Show Details
`
Project(build.gradle):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
allprojects {
repositories {
maven {
url "http://dl.bintray.com/florent37/maven"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
maven {
url "https://jitpack.io"
}
Please add this line in your project level gradle file under repositories. because the library circularReveal is using repo from jitpack. Also remove circular Reveal and rebuild the project, it should be able to build properly.
Project Level Gradle
buildscript {
repositories {
google()
jcenter()
maven {
url "https://jitpack.io"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App Level Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.yourcomp.stackoverflow"
minSdkVersion 16
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(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.android.support:design:27.1.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
}
You Just need to update your SDK tools according to the library, and it will work.

Unable to MergeDex in Android Studio after updating Firebase and Google play services

The error which I am receiving is this:
Error:Execution failed for task
':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge
dex
My build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "app.monmos"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '27.0.3'
productFlavors {
}
}
android {
defaultConfig {
multiDexEnabled true
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.github.jd-alexander:android-flat-button:v1.1'
//Libraries
//noinspection GradleCompatible
implementation 'com.google.firebase:firebase-messaging:12.0.0'
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation 'com.cepheuen.elegant-number-button:lib:1.0.2'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-core:12.0.0'
implementation 'com.google.firebase:firebase-database:12.0.0'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'com.android.support:support-annotations:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.0'
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.firebaseui:firebase-ui-database:3.1.1'
}
apply plugin: 'com.google.gms.google-services'
This is my project build.gradle project:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have updated the firebase version from 10.2.0 to 12.0.0 and the app is bringing up an error saying telling me to merge dex. I think 2 libraries are clashing.
This is because the following Firebase-UI:
implementation 'com.firebaseui:firebase-ui-database:3.1.1'
Has a strict dependencies of:
Firebase/Play services version 11.6.2
Support Library version 27.0.1
So, you need change the dependencies according to it.
You can view the documentation in case you need to use the recent supported Firebase/Play service at Firebase-UI for Android.

Could not find android-maven-gradle-plugin.jar in Android Studio 3.1?

My Android is work fine in Android Studio 3.0.1 , but it show the follow build error after I update to the Android Studio 3.1.
Could not find android-maven-gradle-plugin.jar (com.github.dcendents:android-maven-gradle-plugin:2.0).
Searched in the following locations:
https://jcenter.bintray.com/com/github/dcendents/android-maven-gradle-plugin/2.0/android-maven-gradle-plugin-2.0.jar
The build.gradle is like the following:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
// 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"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And in app/build.gradle :
apply plugin: 'com.android.application'
apply plugin: 'android-maven'
apply plugin: 'com.github.dcendents.android-maven'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.aitrix.wen.seaglider"
minSdkVersion 21
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'
}
}
}
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'
testImplementation 'junit:junit:4.12'
compile project(':AHRSView')
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
Did I missing something ? Thanks in advance.
After I update the following , the project work fine.
Update
classpath 'com.android.tools.build:gradle:3.0.1'
to
classpath 'com.android.tools.build:gradle:3.1.0'
And Update
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
to
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
also update the gradle-wrapper.properties to
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

Gradle Build Error java.lang.IllegalArgumentException

I'm getting a grade build error when i want to launch my project. It goes like that:
Error:Execution failed for task ':app:processDebugResources'.
> java.lang.IllegalArgumentException (no error message)
I copy pasted some stuff into this project, which caused a few errors before, so it might be an error because of copy/pasting...
Here is my build.grade files:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and another build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.example.leodr.upgradeadmin"
minSdkVersion 15
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'
}
}
}
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 files('libs/gson-1.4.jar')
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
I hope you can help me, TY for your help!
Update your project level build.grade:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
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
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and your module level build.gradle :
Change these line:
compileSdkVersion 26
buildToolsVersion "26.0.2"
to:
compileSdkVersion 27 //buildToolsVersion is not needed
and:
targetSdkVersion 26
to:
targetSdkVersion 27
and the dependency line:
compile 'com.android.support:appcompat-v7:26.+'
to:
compile 'com.android.support:appcompat-v7:27.0.1'
Now sync your project and if it prompts your to download just click on the link in the error to download.

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. try to sending emails

I'm trying to send an e-mail like in this post:
Sending Email in Android using JavaMail API without using the default/built-in app
And adding in my build.gradle and app file this lines: https://javaee.github.io/javamail/Android
Error:
Error:Execution failed for task
':app:transformClassesWithDexForDebug'. >
com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException: com.android.dex.DexException:
Multiple dex files define
Lcom/sun/activation/registries/LineTokenizer;
But with the following app file I have a execution failed and don't know why.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.github.ocaparrostortosa.MyApplication"
minSdkVersion 21
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'
}
}
packagingOptions {
pickFirst 'META-INF/LICENSE.txt' // picks the JavaMail license file
}
}
dependencies {
compile 'com.sun.mail:android-mail:1.5.5'
compile 'com.sun.mail:android-activation:1.5.5'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-database:10.2.1'
compile 'com.google.firebase:firebase-auth:10.2.1'
compile 'com.google.android.gms:play-services-auth:10.2.1'
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'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
And this one is my Project gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.java.net/content/groups/public/"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Can someone help me please? I'm close to finish the project :D
P.D: Sorry for my English and for the presentation, I'm new in stackoverflow.
this error is quite tricky. i also had a hard time on this. I solve my problem somehow by adding this multiDexEnabled true on my gradle build.config
android {
defaultConfig {
minSdkVersion 14 x
targetSdkVersion 23
multiDexEnabled true
}
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
Take note, this solution is case to case basis.
One scenario is - my app was very large that it exceeds 64MB limit. If this does not work, check your dependencies.
Other scenario was caused by Google Maps API dependencies that the version needs to be inline with the APP target SDK.

Categories

Resources