I just installed a fresh new Android Studio on a fresh new Windows 7. I created a new empty project and Android Studio keeps failing at project syncing. I tried few solutions people posted on SO, but none of them worked so I decided to show you my project structure hoping someone can help.
So, this is my project's gradle 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.0.1'
// 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
}
And module's gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.kompjutor.myapplication"
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 {
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'
testImplementation '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 those are the errors I'm getting:
Any ideas, please?
Issue could be caused by the following reasons
Gradle has not synced the libraries.
Android Studios offline mode is activated.
See this for more info
Go to File->Project Structure.
In the Dependency Tab Choose Plus icon appears green then choose Library dependency. And add through that. If still problem appears update Support Repository through SDK Manager
Related
Please help me...
I want to create a project based on Google Maps. But after building gradle in Android Studio, The following error occurs:
ERROR:
Failed to resolve: com.google.android.gms:play-services-maps:17.0.0
Install Repository and sync project
Show in Project Structure dialog
Affected Modules: app
When i clicked on the 'Install Repository and ...' then this message appear:
Could not find dependency "com.google.android.gms:play-services-maps:17.0.0"
NOTE:
Gradle work online mode.
I went to Setting and Android SDK then downloaded google play services.. but it is not working for me.
I also set up a proxy.
EDIT:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 15
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"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
root gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.31'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
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()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
After much effort, I was able to solve the problem.
Strange as it may seem, the problem was solved by manually adjusting the proxy.
thanks all.
When I added the dependencies as told in the firebase guide and sync the project ,I get the error JAVA__LETTER_OR_DIGIT .I work with MAC OS X Yosemite and my android studio version is 3.1.4
My app grade file
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "e.apple.mse_project"
minSdkVersion 22
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.1.3'
implementation 'com.google.firebase:firebase-analytics:17.2.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'
}
apply plugin: 'com.google.gms.google-services'
My project grade 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.1.4'
classpath 'com.google.gms:google-services:4.3.2'
// 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
}
This is the error that I get in the build console
The error log that shows in my build console
Thanks in advance !
The problem is with Android gradle plugin which doesn't work well with Google's Maven repository.
You can downgrade your google-services down to 4.2.0 as it was said by #mownathi-manigundan. Version 4.2.0 is available in AndroidTools Repository which outdated gradle plugin handles just fine
But it'd be better to update your plugin up to 3.2 or higher and use recommended com.google.gms:google-services:4.3.2. You can read more here how to to this
Try changing your version of gms google service in your project gradle as com.google.gms:google-services:4.2.0
Android Studio is not running any my projects, even a hello world app.
I have tried almost everything.
I have been banging my head for 2 days now. I tried all these:
How do I solve the INSTALL_FAILED_DEXOPT error?
I have disabled instant run with no effect.
I have cleaned my project with no effect.
I have tried building on it a real phone with the same error.
I have tried wiping out data of the emulator with no effect.
After trying almost everything here.
I also uninstalled Android Studio and reinstalled it three times and no effect.
gradle: app
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.tete.myapplication"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.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'
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'
}
The project level gradle file is:
// 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.3.2'
// 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
}
It is a very simple Hello world project.
Please tell me what more information you need.
This issue has started making me angry.
I'm trying to sync with Firebase with my project I use the tool from Android Studio --> Firebase and then I do the steps (This is new Project) Image.
Android Studio version 3.0.1
The build.gradle in App folder is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.eranp.fiberbase"
minSdkVersion 19
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.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-database:11.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
The build.gradle in Project folder
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
compile "com.android.support:support-core-utils:27.1.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
But when I sync the project I have this Error:
Error:(13, 0) Could not find method compile() for arguments
[com.android.support:support-core-utils:27.1.0] on object of type
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Please install the Android Support Repository from the Android SDK
Manager.
But this is installed: Image.
I tried for a week to work with Firebase but anything working to sync.
How can I fix this?
thank you for helping!
After you add this:
compile "com.android.support:support-core-utils:27.1.0"
under the dependencies in the app/build.gradle
then you need to change the:
compileSdkVersion 26
to this:
compileSdkVersion 27
also update the firebase version to this:
implementation 'com.google.firebase:firebase-database:11.8.0'
latest version
You're trying to add a compile dependency to your project buildscript, which is not valid. You are only supposed to add classpath dependencies to your buildscript, which effectively act as plugins for your Gradle build.
compile dependencies are to be using your app's build.gradle, which typically lives in the app folder. These are SDK components that you use to build your app.
If you want to use compile "com.android.support:support-core-utils:27.1.0" in your app, move it from the buildscript dependencies to the app dependencies.
I am not able to understand what is the issue? Can anyone Help, attaching the screenshot for Android Studio
Build grade file is // 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'
// 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
}
My app build.gradle file is
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.a479729.myapplication"
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 {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
Try this,
In your top level build gradle
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
ref: https://developer.android.com/topic/libraries/support-library/setup.html
It seems problem is in your gradle version. Most of the time this error happen when you import others project. Because it can have old gradle scripts than your version. To upgrade your gradle, Delete those gradle files in project . Then clean & rebuild your project. Then android studio ask to download new gradle version from internet. Wait until download is complete. It will solve errors in gradle.