Fix plugin version and sync project Error In Android Studio - android

I am currently opening this file Android Studio 2.1 and the the app is created in Android Studio version 1.5.
Error:(1, 0) Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to "abf87974ef3c08e3258fe37c7d5001161385f549"
Fix plugin version and sync project
Open File
I have problem during importing Android Project and it shows error.
After pressing "Fix Plugin" it shows me "Failed To Update".
This is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "app.asharbhutta.com.challanlogin"
minSdkVersion 13
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.1'
classpath 'com.android.tools.build:gradle:2.1.4'
}
This is gradle-wrapper.properties
#Wed Oct 21 11:34:03 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip

I'm not able to find 'com.android.tools.build:gradle:2.1.4' in Jcenter / Bintray.
Therefore, this error makes sense
Fix plugin version and sync project
As of this post, the latest stable version is 2.1.2
Note: Gradle is completely separate from the Android plugin. The version of gradle-2.14-bin does not always match the plugin number.
This should all be self-explanatory, but to clarify, this is the corrected build.gradle.
Project /build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
app/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "app.asharbhutta.com.challanlogin"
minSdkVersion 13
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.1'
// classpath 'com.android.tools.build:gradle:2.1.4' // This shouldn't be here
}

In Build.gradel
in Dependencies classpath end with + sign like i shown
classpath 'com.android.tools.build:gradle:2.2.0+'

Related

Gradle build in Android Studio

I updated my Android Studio to version 3.0.1, and then Gradle to 4.2 and Android plugin tools to 3.0.1. After that whenever I create a new project it gives me the Gradle build problem.
This is my module build.gradle:
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.nasser.studio.test"
minSdkVersion 14
targetSdkVersion 27
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:27.0.3'
}
Also I unchecked the work offline for gradle.
I also checked AS settings which displays some errors:
Update 1:
When I change the compile SDK to version 25 like this, the Gradle build is completed correctly.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.nasser.studio.test"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:25.3.1'
}
But changing to latest versions (26 or 27), it gives me the same error. I also should mention that during Gradle build process for these versions, it's downloading files from Maven repositories which doesn't happen in version 25 ( I'm using a proxy connection).
Moreover, the search box of AS for support library gives me this version which is not the latest version (27.0.2).
You should use stable v7:27.0.2 instead off v7:27.0.3.
implementation "com.android.support:appcompat-v7:27.0.2"
FYI
If you are using Android Studio 3.0 or above make sure, your build.gradle (PROJECT level) file looks like this:
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
}
google()
}
}
Then Clean-Rebuild-Run.
Add this to your project level build.gradle file:
allprojects {
repositories {
maven {
url 'https://maven.google.com'
}
}
}
Change this on your Project level build.gradle
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
first, check with your gradle-wrapper.properties which should be having this
distributionUrl=\
https\://services.gradle.org/distributions/gradle-4.1-all.zip
and in project-level build.gradle
build script {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
also you need to change according this
https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#new_configurations
and see the topic Migrate dependency configurations for local modules
you will get better idea what things need to change in dependencies.

gradle sync failed when use android.support.library

I want to add android.support to project:
build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
}
}
apply plugin: 'com.android.application'
repositories {
jcenter()
maven{
url "https://maven.google.com"
}
}
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.example.myapplication2_gradle26_3.app"
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
}
and when sync the gralde this error fired
Error:Gradle: Execution failed for task ':app:processDebugManifest'.
Error: [E:\AndroidExamples\MyApplication2-gradle26-3\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\26.0.0-alpha1\AndroidManifest.xml:21]
Invalid instruction 'overrideLibrary', valid instructions are :
REMOVE,REPLACE,STRICT
the project sync successfully when i add appcompat-v7:22.+ but not when want to add appcompat-v7:26.0.0-alpha1
i tried to update gradle but IDE errored 'u cant use this version'
my IDE is IntelliJ 13.1.15
Update the Android Plugin for Gradle.
Change:
classpath 'com.android.tools.build:gradle:0.12.2'
with:
classpath 'com.android.tools.build:gradle:2.3.3'
Also there is no reason to use an alpha version of appcompat. Use the latest stable version of the support libraries:
compile 'com.android.support:appcompat-v7:26.1.0'

How to fix "Error:Error:line (23)Gradle DSL method not found: 'android()"

I was working on my project in Android Studio on Windows but now I am trying to open it on Ubuntu but it keeps complaining that:
Error:Error:line (23)Gradle DSL method not found: 'android()' Possible causes: //(Error23,0)
The project 'POSTER' may be using a version of Gradle that does not contain the method. Open Gradle wrapper file
The build file may be missing a Gradle plugin. Apply Gradle plugin
Project Gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
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 {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android {
compileSdkVersion 23
buildToolsVersion '24.0.0'
}
App Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.ozuf.poster"
minSdkVersion 16
targetSdkVersion 23
versionCode 5
versionName "0.5 Beta"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile project(':volley')
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'org.jsoup:jsoup:1.9.1'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'ch.acra:acra:4.9.0-RC-2'
compile 'com.google.firebase:firebase-core:9.0.2'
compile 'com.google.firebase:firebase-ads:9.0.2'
}
apply plugin: 'com.google.gms.google-services'
Gradle-wrapper.properties
#Fri Apr 08 19:27:52 WAT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
Please, do you have any idea what's causing this and how to fix it?
delete android settings in project gradle
android {
compileSdkVersion 23
buildToolsVersion '24.0.0'
}
if you want to set as common config, you can use is like this:
project gralde:
ext {
compileSdkVersion 23
buildToolsVersion '24.0.0'
}
app gralde:
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.ozuf.poster"
minSdkVersion 16
targetSdkVersion 23
versionCode 5
versionName "0.5 Beta"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

Android Studio - Gradle can't resolve appcompat-v7:23.1.1

I have started a new Project with Android Studio 2.0 Preview 3b
I have SDK updated.
But when the project has been created, gradle launch error message:
That's how lok build.gradle (module) file:(auto-generated by AS)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.xxxxx.xxxxx"
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:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
And build.gradle (project):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha2'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
When I click on the first option from the error log, AS opens this window:
Finally say that I have
How can I solve this problem?
I resolved uninstalling Android Studio. The real problem was SDK. When you uninstalling AS SDK is still on computer, and I deleted all these files from SDK folder. The best option if you install AS and SDK directly on C:. After that AS working without any problems.

How do I build Android project using a newer version of gradle?

I have an Android project built using gradle 1.10. I would like to build it using gradle 2.4. There are few threads where some changes are suggested which should do the job. Some users have said these changes have worked and some have not worked.
I would like to know if there is a way I can copy certain number of files and build the whole thing from scratch using Gradle 2.4?
Thanks.
It was built using Android Studio 0.5.1.
Here is Project level build.gradel:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
Here is the module level build.gradle:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 19
versionName "19.1"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v4:18.0.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Using the current Android Studio 1.3 you should use this top-level build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
allprojects {
repositories {
mavenCentral()
}
}
The module/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion XX
buildToolsVersion "XX.X.X"
defaultConfig {
minSdkVersion 14
targetSdkVersion XX
versionCode 19
versionName "19.1"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:XX.X.X'
compile 'com.android.support:support-v4:XX.X.X'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Pay attention to use gradle 2.4 and change the gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip

Categories

Resources