I tried all solutions to fix it, but nothing has succeeded. (Turned gradle to "offline work", deleted .gradle files, invalidated and restarted. I also removed the jdk-android studio completely and installed again.)
Here is the problem's screenshot:
Android Studio 3.0 Gradle Sync Problem
Here is my java version
and here is the system/log file:
I think add build tools and sdk version 23 or 24
and if you select to use 23 build tools and sdk version, add dependency like this
compile 'com.android.support:appcompat-v7:23.1.1'
Note:
Wherever its written 26, replace with 23, only if you choose to 23 build tools and sdk version
If there is still any problem you can ask.
You can open build.gradle file in Android studio, then change compileSdkVersion , buildToolsVersion dependencies like this
android {
compileSdkVersion 23
buildToolsVersion "24.0.1"
....
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
}
If you did not understood it, can you please share screen shots of your build.gradle file ?
Which is in left side of android studio, under Gradle Scripts -> build.gradle (Modual:app)
Do it this way
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
defaultConfig {
applicationId "com.example.hackl.happybirthday"
minSdkVersion 15
targetSdkVersion 23
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:23.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'}
and click sync now (it will be automatically appear when you make changes in this file)
Take these easy steps as per developer.android.com
first add these lines on build.gradle file
buildscript {
repositories {
jcenter()
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
after that
update Gradle manually, edit the URL in gradle-wrapper.properties to the following:
distributionUrl=\
https\://services.gradle.org/distributions/gradle-4.1-all.zip
For your reference you can check the below link
https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html
I uninstalled Android Studio completely and reinstall 3 times. In every step I clicked on Gradle Sync error messages and installed all missing files. 3rd time installation has succeeded with get rid of gradle sync problem with installing missing files correctly. I don't know how and why it has not been successful 1st and 2nd time installation. Anyway, it's done.
Note: Before that I have tried all of answers. Thanks a lot.
Succeeded
Related
I am having some issue with my android studio, I recently updated my android studio to version 3.5 and since then I having been encountering with Gradle build error.
I even went ahead and created a new project with no code and an empty activity, when sync it compile without any issue. but upon launching it on my virtual device emulator, it brings this Gradle error
C:\Users.gradle\caches\transforms-2\files-2.1\995db56542b8715d4dfc10fddfcc653d\aapt2-3.5.0-5435860-windows
Config file
// 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.5.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
}
App's config:
[apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.loyalteams.application"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: \['*.jar'\])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}][1]
I was able to fix it, it was due to paint virus that was on my pc, so during Gradle runtime and build, the hijack any exe file resulting in Gradle cache build error.
As the sole aim of this malware was to affect any runnable exe file on one's desktop and at the same time reduce the size to some kb.
What I did to fix the issue was to install Malwarebytes and Rkill to fix the issue.
I hope this helps some of us being face with the same issue.
In the main configuration file build.gradle compare what lines you have for example I have these:
What was missing is that of google() in the allprojects;
==========================================================
The gradle-wrapper.properties configuration file should look like this:
Finally I found,
I try change versions and more (taked one day from me)
Do those steps:
Remove .gradle directories
Remove all *.iml files
Remove .idea files
Reopen project
Remove intellij system directory (it is contains caches)
Everyhitg work fine ;)
After the new update of Android Studio (3.3.0) I'm getting error from Gradle sync saying "ERROR: Cause: invalid type code: 68". Even in project, that have been created before the update and hasn't changed at all.
I've tried to reinstall Android Studio, which hasn't helped either, so there has to be something incompatible with my project, but it doesn't say what and why.
App gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "cz.cubeit.cubeit"
minSdkVersion 21
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:cardview-v7: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.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
}
Project gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.11'
ext.anko_version='0.10.7'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.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 {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I had the same problem. I was working on a project on two PCs: one at my office and one at home. In my office, after the AS 3.3 update, everything was fine but at home, after the same steps that I did at the office, the Error code 68 came out.
After a couple of hours, I figured out how to solve it.
Android Studio 3.3 has the " Only sync the active variant" option enabled by default in Settings>Experimental. Disabling this feature resolved the problem. But reactivating the feature the same error shows up, even after a successful Gradle sync. So I think this isn't a complete solution, but at least now I can work.
I had the same issu with IntelliJ 2019.1, Untick this option works for me.
Alter path JDK location to .....\Android Studio\jre
I got a similar message ("invalid type code: E5") and resolved it by first building from the command line, which revealed it was a Firebase libs version conflict, and then switching to use firebase-bom instead of manually specifying each version.
I had the same error (6C) during a LinkedIn Learning course, I managed to solve it through the following steps
Updating Kotlin in project-level build.gradle file
Update gradle build version in project-level build.gradle file.
Open Project Structure and using the Suggestions tab, update all modules to the latest version.
Update the compileSdkVersion & targetSdkVersion to latest.
Whenever i add implemntation 'com.google.android.material:material:1.0.0-alpha1' when i try to build my project Android Studio says:
Program type already present: android.support.v4.app.INotificationSideChannel$Stub$Proxy
Message{kind=ERROR, text=Program type already present: android.support.v4.app.INotificationSideChannel$Stub$Proxy, sources=[Unknown source file], tool name=Optional.of(D8)}
This is my gradle script:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-P'
defaultConfig {
applicationId "it.smart.bab3"
minSdkVersion 21
targetSdkVersion 'p'
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:28.0.0-alpha1'
implementation 'com.google.android.material:material:1.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
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.android.support:design:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'
}
I'm new ith this type of errors, and i didn't find anithing with this error. Thanks
I've been struggling all day with this issue too. Finally I managed to compile and run the project successfully.
First of all, get rid of this:
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'
Add the following in your gradle.properties file:
android.useAndroidX = true
android.enableJetifier = false
And finally, sync the project and then compile.
If it doesn't work, clean the project and then rebuild.
PS: I can't get targetSdkVersion 'p' to work. My build.gradle file end up as follows:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-P'
defaultConfig {
applicationId "com.github.alvarosct02.demo"
minSdkVersion 19
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 'com.google.android.material:material:1.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
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'
}
Hope it works for you too.
I wasted 2 days looking for a solution. Anyone who's still looking for a solution can follow the steps below:
Update your Android Studio to the latest version.
Update your compileSdkVersion and targetSdkVersion to 28.
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.your.appid"
minSdkVersion 19
targetSdkVersion 28
versionCode 50
versionName "1.50"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
setProperty("archivesBaseName", "your-app-$versionName")
resConfigs "en"
}
}
Go to your project structure and change your gradle version to 4.10.
Add this dependency first:
implementation 'com.google.android.material:material:1.0.0'
Now remove all the support library dependencies:
implementation "com.android.support:design:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:support-v4:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:multidex:1.0.3'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
androidTestImplementation('com.android.support.test.espresso:espresso-
core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.code.findbugs', module: 'jsr305'
})
Now paste the following into your gradle.properties file:
android.useAndroidX = true
android.enableJetifier = true
In your project level build.gradle file:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.google.gms:google-services:4.1.0'
};
For those who are using Butterknife add below lines in your project level build.gradle file:
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://dl.bintray.com/drummer-aidan/maven/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
And in your module build.gradle file add below dependencies:
implementation "com.jakewharton:butterknife:9.0.0-SNAPSHOT"
annotationProcessor "com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT"
Now Goto Build > Rebuild Project then you might be getting a lot of errors.
Now refer this link.
It has the list of all the old (android.support) vs new (androidx.*) dependencies.
Replace all your old imports with the new ones(Use replaceAll feature of android studio [ctrl + shift + R] which will save you some time).
Finally After refactoring all the old libraries with the new ones:Rebuild the project again and hopefully it should work.
Note: You can also use Refactor > Migrate to androidx in android studio but it didn't work for me.
I started getting this error after upgrading the ButterKnife to the version 8.8.1.
So, I run the command gradle -q dependencies to generate a dependency report, after that you should see where D8 is coming from. In my case from the "ButterKnife" library:
+--- com.jakewharton:butterknife:8.8.1
| | \--- com.android.support:support-compat:d8
Also you can see your android dependencies by going to your Android Studio Gradle view (In Android Studio tool bar navigate to "View/Tool Windows/Gradle"), and selecting the target "androidDependencies" under "My-Project-Name/Tasks/android" (Double click to run or Right click and run).
To solve this problem I added this piece of code exclude module: 'support-compat' to my "app/build.gradle" as below:
implementation ('com.jakewharton:butterknife:8.8.1') {
exclude module: 'support-compat'
}
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
Hope it works for someone else :] Cheers!
Android Studio v3.2+ resolves this issue. It also adds a "Migrate to AndroidX" item under the Refactor menu. No work-around or rollback required.
Update Android Studio from the beta channel to use 3.2+ or wait until a stable version is released.
EDIT: Android Studio v3.2 is now in the stable channel. It is important you no longer use the support libraries and migrate to AndroidX libraries because support for the old support libraries has ended.
If you are including a library that has a transitive dependency on the Android support library you also have to use the jetifier feature that is part of the Android Gradle plugin version 3.2.0-alpha14 or higher. You can determine if you have a library that depends on the support library by running your Gradle dependencies task.
From the Android Developer's blog post (https://android-developers.googleblog.com/2018/05/hello-world-androidx.html):
If you depend on a library that references the older Support Library,
Android Studio will update that library to reference androidx instead
via dependency translation. Dependency translation is automatically
applied by the Android Gradle Plugin 3.2.0-alpha14, which rewrites
bytecode and resources of JAR and AAR dependencies (and transitive
dependencies) to reference the new androidx-packaged classes and
artifacts. We will also provide a standalone translation tool as a
JAR.
In your gradle.properties file make sure that you have:
android.enableJetifier=true
android.useAndroidX=true
I had this issue with Leak Canary on a small project and it was solved by upgrading the Android Gradle plugin to the appropriate version. https://github.com/square/leakcanary/issues/1103
Go to app/build.gradle, in dependencies, remove this line:
implementation "com.android.support:appcompat-v7
Try to add
android.enableD8 = false
to gradle.properties file.
If you want to use
com.android.support:support-v4:28.0.0-alpha1,
then you have to use
com.android.support:design:28.0.0-alpha1
instead of
com.google.android.material:material:1.0.0-alpha1.
Use this
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 28
defaultConfig {
applicationId "ir.uncode.newdesign"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguardrules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support:cardview-v7:28.0.0-alpha3'
implementation 'com.android.support:design:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
implementation 'com.android.support:animated-vector-drawable:28.0.0-alpha3'}
repositories {
mavenCentral()
}
and If the problem persists change "import" on class and xml.
like :
import androidx.fragment.app.Fragment;
import android.support.v4.app.Fragment;
or
import androidx.core.app.ActivityCompat;
import android.support.v4.app.ActivityCompat;
or
com.google.android.material.bottomappbar.BottomAppBar
android.support.design.bottomappbar.BottomAppBar
If you are using Android Studio V. 3.2.1 , You can simply go to the tools bar open Refactor -> migrate to AndroidX and Android studio will take care of the rest.
I am using android studio 3.3 version. I wasted my one and a half day looking for this solution. I tried all the answer in this post but nothing helped. Then I find the link which helped me to solve the error.
I removed the below dependency I added,
implemntation 'com.google.android.material:material:1.0.0'
Instead, I used android design support library,
implementation 'com.android.support:design:27.1.1'
try setting android.enableJetifier=true and android.useAndroidX=true
in your gradle.properties file.
If you have 3.1.0 change to 3.2.0:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
You need to move to androidx
Remove all the imports which start with
import android.support.*
Change All imports to import androix.* and corresponding components.
When I try to compile I get this error
"Failed to resolve: com.google.android.gms:play-services:fp9.0.0" in Android Studio. I am trying to include the play services in my project. This is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "Application name"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.google.android.gms:play-services:fp9.0.0'
}
The only thing I have changed in this file is this line:
compile 'com.google.android.gms:play-services:fp9.0.0'
I have installed Google Play Services and it's version number is 30.
I had the same issue yesterday. In the messages section when running a gradle sync or build, I got a message with an option to update something from the M2 repo. Clicking the link downloaded the latest version and fixed the issue.
You could also try compile 'com.google.android.gms:play-services:9.0.0'
If you are only using maps, consider only downloading maps using compile 'com.google.android.gms:play-services-maps:9.0.0' as it can save you hitting the 65K method dex limit later in development.
Try to add and change this in your Project Level Gradle.
Update classpath com.google.gms:google-services:2.1.0 to classpath com.google.gms:google-services:3.0.0
And
Also try to change compile Dependencies as below.
compile 'com.google.android.gms:play-services:9.0.0'
Or for map you can only use this.
compile 'com.google.android.gms:play-services-maps:9.0.0'
I am a beginner to Android Programming. I am trying to create a basic Hello World App using Android Studio. I am getting following errors in Java File immediately after following the initial steps to create the Hello World Program.
"Cannot resolve Symbol FloatingActionButton"
"Cannot resolve Symbol Snackbar"
"Cannot resolve Symbol AppCompatActivity"
"Cannot resolve Symbol Toolbar"
As you can see in the attached Image the errors are in red.
Please help me out here.
My build file content:
defaultConfig {
applicationId "com.example.helloworld.helloworld"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
}
Seems like I have added all the relevant dependencies.
I had the same issue after inserting a new module with a blank activity into an existing project.
My module's build.gradle file looked like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.networkingtest"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
}
To resolve the issue I changed the versions of the appcompat and design dependencies from 23.1.0 to 23.0.1 (Note: this is the same version as in buildToolsVersion). Next I hit "Sync project with gradle files" followed by Build > Clean Project. After completion the project would run, but I changed the dependency versions back to 23.1.0, hit "Sync project with gradle files" followed by Build > Clean Project again. Now everything works.
Include compile 'com.android.support:design:25.3.1' in build.gradle(Module:app)
Change the version 25.3.1 to match your compile 'com.android.support:appcompat-v7:25.3.1' dependency
Import import android.support.design.widget.FloatingActionButton; in activity
Did you sync your project?
Also try deleting all "red" imports and re-import this classes.
I ran into the same issue when i created a project with an empty activity and further added a second activity which was of type Blank activity.
The steps which got me out was
1-Build->Clean Project
2-Sync Project with Gradle Files
Tried it on Android Studio version 1.5.1 with minSDKVersion 17.
add the support:design in build.gradle: module app to dependencies this will fix it
compile 'com.android.support:design:26.+'
had the same problem. try to insert
compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:design:25.2.0'
at the end of you buidl.gradle file.