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'
Related
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.
I have imported a project that I worked for so many days, but I had to upgrade the Android Studio, then, I get this error :
Error:(1, 1) A problem occurred evaluating project ':app'.
> java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin :
Unsupported major.minor version 52.0
Also, When I check my classes I get a red line on every R. and says can not resolve symbol R.
Do you have Any idea how to fix it?
My android Studio Version is : 2.3.3
build Gradle :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
// 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
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "hadirfinal.amjad.hadirfinal"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android {
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.tools.build:gradle:2.1.3'
}
First, check your Java version. The Unsupported major.minor version 52.0 is related to Java 8. Check your JDK in your SDK Location from File -> Project Structure -> SDK Location:
Then upgrade your root build.gradle with build:gradle:2.3.3:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Then update compileSdkVersion, buildToolsVersion, targetSdkVersion, and support library with the same version in your app build.gradle. Here we use version 25. Then remove the following line compile 'com.android.tools.build:gradle:2.1.3' because you don't need that. So, it will look like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "hadirfinal.amjad.hadirfinal"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android {
useLibrary 'org.apache.http.legacy'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
}
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+'
I get the following error while I am trying to run the app.I have earlier updated the Android Studio.Gradle has also been posted below.
Error:
Error:(1, 1) A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
> Could not create plugin of type 'AppPlugin'.
Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.jobinsabu.georgetravels"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases' }
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.0'
}
Check your grade file and update classpath version here:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
Try to change your classpath version and then update.
Make sure you are connected to internet for gradle syncing.
Hope it may helpful to you.
Thanks,
Bhuvnesh
I am trying to use facebook SDK in my android apps, and I am starting to add maven central repository to my build.gardle. Although, I've found 2 build.gardle which belong to project and app. Here they are;
Android Studio: 1.5.1
Gradle Version: 2.8
Android Plugin Version: 1.5.0
Build.gardle (Project)
buildscript {
repositories {
jcenter()
mavencentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
}
}
allprojects {
repositories {
jcenter()
mavencentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Build.gardle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.test"
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.2.0'
compile 'com.android.support:design:23.2.0'
}
Yet I get this following error during build;
Gradle DSL method not found: mavencentral()
I have tried;
Checking both gardle files
Removing android compile dependencies that's actually should be there
Checking android packagingOptions.exclude
Checking if there's android method in the gardle
And, I haven't tried to update my gardle or android studio, but I am just wondering whether it's really needed or I am doing something wrong with my build.gardle.
Any suggestion is appreciated. Thank you.
The Facebook SDK page is clear. Add into your project/build.gradle
repositories {
mavenCentral() //note the uppercase C
}
and into your project/app/build.gradle
dependencies {
compile 'com.facebook.android:facebook-android-sdk:4.+'
}