I have two Android apps I'm looking at - one that I created a while back and another that I'm just making now. When I try to compile the new one, I get an error "Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
compileSdkVersion 'android-25' requires JDK 1.8 or later to compile." I do not get this error with the old app. Why the difference?
New app's gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.jtriemstra.forceconnectfromphone"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.0.0'
}
Old app's gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.jtriemstra.timeswitch"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.apache.commons:commons-lang3:3.4'
compile 'commons-codec:commons-codec:1.10'
compile 'com.android.support:appcompat-v7:25.0.0'
compile files('libs/nmdp_speech_kit.jar')
}
In both cases, if I go to File > Project Structure, I see it pointed to the same JDK 1.7 path.
The biggest difference I can see is that the new app is using a newer version of Gradle and the Gradle wrapper...which I changed in an effort to solve another problem (see Why "This app has been built with an incorrect configuration" error occured in some phones?) But I would have expected a compile failure to be more at the javac level, not the build manager level.
It looks like the reason is, in fact, the gradle wrapper. If I take a different approach to solving my initial problem, and roll back my changes to the wrapper to use v2.8, the project compiles.
Related
My app uses google maps for 2 years on version com.google.android.gms:play-services:5.0.89. When I try to upgrade, the app will show no GUI, just blank screen.
Probably the same issue as here, but there is no solution but downgrade.
I have tried
compile 'com.google.android.gms:play-services:9.6.0'
and also just subset as I do not use other services
compile 'com.google.android.gms:play-services-maps:9.6.0'
compile 'com.google.android.gms:play-services-analytics:9.6.0'
Here is complete gradle script
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "cz.benhur.vfrdroid"
minSdkVersion 17
targetSdkVersion 23
versionCode 12
versionName "1.12"
// http://developer.android.com/tools/building/multidex.html
//multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
}
compileOptions {
// sourceCompatibility JavaVersion.VERSION_1_7
// targetCompatibility JavaVersion.VERSION_1_7
}
testOptions {
unitTests.returnDefaultValues = true
}
}
dependencies {
//compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:support-v13:23.4.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services-maps:9.6.0'
compile 'com.google.android.gms:play-services-analytics:9.6.0'
// MPAndroidChart, geodesy: apache2 license
compile 'com.dropbox.core:dropbox-core-sdk:2.1.1'
compile 'com.github.PhilJay:MPAndroidChart:v2.2.2'
compile 'org.gavaghan:geodesy:1.1.3'
//testCompile 'junit:junit:4.12'
}
After 2 days spent copy-pasting my code piece by piece to new project I found the problem:
my app have 2 map fragments. I used to call getMap() on each in setUpMapIfNeeded(). I have to update to getMapAsync().
setUpMapIfNeeded() was called from onCreate() and from onResume(). This was probably generated by Android Studio 2 years ago.
If I remove second setUpMapIfNeeded() (or second getMapAsync()), everything works ok.
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.app.threedb"
minSdkVersion 15
// targetSdkVersion 21
versionCode 1
versionName "1.0"
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:recyclerview-v7:21.0.+'
}
This code I have written in gradle but few functionality like creating new message and adding image from gallery is not working in kitkat version. Please help
Here is my Gradle build file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "problemio.com.problemionew"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
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'
}
My application compiled ok, but when I tried to run it, I got this error:
Any thoughts on what is going wrong here? My machine is set up for Java 6. When I tried to upgrade to Java 7 I got some errors so I had to revert to Java 6.
That error is due to problem in compilation which usually related to duplicated libraries or too many methods and classes. I guess that you are including google play services in you gradle . Try to use specific sub library from here https://developers.google.com/android/guides/setup.
This error
This error about for uses and give referance same classes.Look here
I'm using Android Studio 1.1 beta 4 with gradle plugin 1.0.1 and trying to add Android Annotations to my project following the official insturctions. So I get the following build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "ru.itloft.moneytracker"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
}
}
def AAVersion = '3.2'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile 'org.springframework.android:spring-android-rest-template:2.0.0.M1'
compile 'com.google.code.gson:gson:2.3'
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
}
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
// if you have multiple outputs (when using splits), you may want to have other index than 0
resourcePackageName 'ru.itloft.moneytracker'
// If you're using Android NBS flavors you should use the following line instead of hard-coded packageName
// resourcePackageName android.defaultConfig.packageName
// You can set optional annotation processing options here, like these commented options:
// logLevel 'INFO'
// logFile '/var/log/aa.log'
}
}
And all works fine, but I get a warning in the line androidManifestFile variant.outputs[0].processResources.manifestFile saying: 'getAt' in 'org.codehaus.groovy.runtime.DefaultGroovyMethods' cannot be applied to '(java.lang.Integer)'. How can I get rid of this warning?
How #WonderCsabo already told this is a false positive. You can avoid this warning if you access the outputs explicit as collection
androidManifestFile variant.outputs.collect()[0].processResources.manifestFile
I'm wanting use this github project: https://github.com/makovkastar/FloatingActionButton in my android app, however I dont know if I have to download the project and move to libraries package, or if I have only do this:
dependencies {
compile 'com.melnykov:floatingactionbutton:1.1.0'
}
You need search the file build.gradle of your whole app folder.
There should be 2 of them, open the file under app folder you will see some like:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.melnykov:floatingactionbutton:1.1.0'
}
Put compile 'com.melnykov:floatingactionbutton:1.1.0' in dependencies
You don't need to download the source code if just want to use the library.
Just add line compile 'com.melnykov:floatingactionbutton:1.1.0' to dependencies section in build.gradle