Android Debug Unsupported major.minor version 52.0 - android

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'
}

Related

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'

Android Studio Gradle DSL method not found: 'compile()'

I am getting the following error:
Error:(4, 0) Gradle DSL method not found: 'compile()'
Possible causes:The project 'Jp' 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.
I tried looking to other similar questions, but nothing worked.
My build.gradle(Project:JP) file is below:
Error:(4, 0) Gradle DSL method not found: 'compile()'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.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
}
build.gradle(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.jal.jp"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(":sdk-audio-1.60.1")
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
}
build.gradle(sdk-audio-1.60.1)
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.jal.jp"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(":sdk-audio-1.60.1")
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
}
settings.gradle:
include ':app', ':sdk-audio-1.60.1'
can anyone help me to fix this?
Thanks
Your build gradle tools seem too old, change the following line in the root build.gradle:
classpath 'com.android.tools.build:gradle:1.5.0'
to
classpath 'com.android.tools.build:gradle:2.3.3'
And don't forget to add google maven to your build.gradle too:
maven { url "https://maven.google.com" }
This is because all support library are moved to maven as in the release note at https://developer.android.com/topic/libraries/support-library/revisions.html:
Important: The support libraries are now available through Google's
Maven repository. You do not need to download the support repository
from the SDK Manager. For more information, see Support Library Setup.
So then your root build.gradle will be something like this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://maven.google.com" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

zipAlignDebug input file does not exist Error

Ever since I updated to gradle alpha 6, I've been getting this error and can't build:
Error:A problem was found with the configuration of task ':app:zipalignDebug'.
> File 'C:\User\...\app\build\outputs\apk\app-debug-unaligned.apk' specified for property 'inputFile' does not exist.
I've tried all the suggestions and nothing is fixing this. Any tips? It was working on alpha 2, but now it gives me an error saying my version is too old and I need to move to a newer one. Thanks!
// 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-alpha6'
// 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 "23.0.2"
defaultConfig {
applicationId "com.nwoodthorpe.waterloohacks"
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.1'
}
Try to run build every time before Run 'app'.

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