Unable to update to java 8 in android studio - android

Below is my app.gradle apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.crayond.vlearning"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
jackOptions {
enabled true
}
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
incremental false
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile project(':recyclerview')
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'
compile 'com.github.Kunzisoft:Android-SwitchDateTimePicker:1.5'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.yalantis:phoenix:1.2.3'
testCompile 'junit:junit:4.12'
/* compile 'com.google.dagger:dagger:2.0'
annotationProcessor 'com.google.dagger:dagger-compiler:2.0'*/
annotationProcessor 'org.androidannotations:androidannotations:4.1.0'
compile 'org.androidannotations:androidannotations-api:4.1.0'
}
I get the following error while syncing gradle:
Error:Could not get unknown property 'classpath' for task ':app:transformJackWithJackForDebug' of type com.android.build.gradle.internal.pipeline.TransformTask.

To update your android project jdk version to 1.8 use retrolambda library.
In your app level build.gradle file add:
1.
apply plugin: 'me.tatarka.retrolambda' in the top of the file.
2.
android{
//Other stuff
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
3. And then add new dependency to your project level build.gradle file.
dependencies {
//Other dependencies
classpath 'me.tatarka:gradle-retrolambda:3.4.0'
}
Voila! Now you are able to use java 1.8 features in your android project.

Related

Could not get unknown property 'javaVersion' for object of type com.android.build.gradle.internal.CompileOptions

i am getting this error when i run my project.
i am getting error in these two lines
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility javaVersion.VERSION_1_8
and i am changing these lines into
sourceCompatibility JavaVersion.VERSION_1_2
targetCompatibility javaVersion.VERSION_1_2
but facing same error.
i have android studio 2.2.3
this is my Gradle file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.fcih.gp.furniturego"
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
debuggable true
}
}
compileOptions{
sourceCompatibility JavaVersion.VERSION_1_2
targetCompatibility javaVersion.VERSION_1_2
}
// compileOptions {
// sourceCompatibility JavaVersion.VERSION_1_8
// targetCompatibility JavaVersion.VERSION_1_8
// }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile(name: 'wikitudesdk', ext: 'aar')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.4.0'
compile 'com.android.support:exifinterface:25.4.0'
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:customtabs:25.4.0'
compile 'com.android.support:support-v4:25.4.0'
compile 'com.android.support:recyclerview-v7:25.4.0'
compile 'com.android.support:cardview-v7:25.4.0'
compile 'com.google.firebase:firebase-database:11.0.1'
compile 'com.google.firebase:firebase-auth:11.0.1'
compile 'com.google.firebase:firebase-storage:11.0.1'
compile 'com.firebaseui:firebase-ui-database:2.0.1'
compile 'com.google.android.gms:play-services-auth:11.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.23.0'
compile 'com.twitter.sdk.android:twitter:3.0.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.makeramen:roundedimageview:2.3.0'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.7'
compile 'me.grantland:autofittextview:0.2.1'
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.6'
compile 'com.koushikdutta.ion:ion:2.2.1'
}
repositories {
jcenter()
flatDir { dirs 'libs' }
}
apply plugin: 'com.google.gms.google-services'
change JavaVersion.VERSION_1_8 to 1.8
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}

My application is not working (not launching) with Kitkat or lower versions

i complied it with sdk 23 and tried to compile it with sdk 16 but errors pops up.. i cant build it with sdk 16.
i also tried changing target sdk and minimum sdk.
application works well with Lollipop and marshmallow.
but lower versions like kitkat gingerbread not opening. always force quitting.
my Build.gradle(app) File:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.braveheartcreations.wifiexplorer"
minSdkVersion 16
targetSdkVersion 17
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
lintOptions {
disable 'MissingTranslation'
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services:9.8.00'
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'net.vrallev.android:cat:1.0.2'
provided 'org.projectlombok:lombok:1.16.6'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:support-v13:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:cardview-v7:23.2.0'
compile 'me.dm7.barcodescanner:zxing:1.9'
compile 'com.karumi:dexter:2.3.1'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.getbase:floatingactionbutton:1.9.0'
compile files('libs/ftp4j-1.7.2.jar')
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.2.1'
}
}
repositories {
mavenCentral()
}
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
You can't install this application into Android 4.0.4 and lower versions devices because the minSdkVersion is 16.For the kitkat device, you must paste the log here.
By the way,when you use compatibility with JavaVersion.VERSION_1_8, you must enable the jack.
defaultConfig {
...
jackOptions {
enabled true
}
}

How to use Android Annotations and its annotation processor with jack?

Does anybody know how to use Android Annotations with the jack compiler ?
Here my app/build.gradle and here my project build.gradle
With this configuration, I have this error message when I build my project :
Error:Could not get unknown property 'classpath' for task ':app:transformJackWithJackForDebug' of type com.android.build.gradle.internal.pipeline.TransformTask.
You should remove the android-apt plugin and the apt block completely, because it does not work with Jack annotation processing. Also, you have to declare processsors in the annotationProcessor configuration. Lastly, you have to add the annotation processing parameters to jack (which has no public API per-variant, yet).
Here is your modified build.gradle:
repositories {
jcenter()
mavenCentral()
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.frlgrd.streamzone"
minSdkVersion 21
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
// Android Annotations
def AAVersion = '4.0.0'
dependencies {
// Google
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
// Android Annotations
annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
// RX
compile 'com.tbruyelle.rxpermissions:rxpermissions:0.7.1#aar'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.6'
}
// add annotation processing options to jack
android.applicationVariants.all { variant ->
variant.variantData.variantConfiguration.javaCompileOptions.annotationProcessorOptions
.arguments = ['androidManifestFile': variant.outputs[0]?.processResources?.manifestFile?.absolutePath]
}

Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

I have this error when I try to run my application.
Build is ok. Run makes errors.I tried to set multiDexEnable to true also butI still get the error..
This is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "it.prova.mine"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_7
sourceCompatibility JavaVersion.VERSION_1_7
}
}
repositories {
//mavenLocal()
mavenCentral()
}
dependencies {
//compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
//bug cardview
//vedi -> http://stackoverflow.com/questions/24455867/error-when- adding-cardview-to-layout
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:support-v4:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.android.support:recyclerview-v7:23.2.1'
//Custom ProgressDialog
compile 'com.github.d-max:spots-dialog:0.4#aar'
//Url Encoder
compile 'org.droidparts:droidparts:2.9.1'
//SearchView
compile 'com.miguelcatalan:materialsearchview:1.3.1'
//Retrofit
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta3'
//jackson-jsog extension
compile 'com.voodoodyne.jackson.jsog:jackson-jsog:1.1'
//
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.2'
compile 'com.google.code.gson:gson:2.6.2'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
//java.time backport
compile 'org.threeten:threetenbp:1.3.1'
//java.ws.rs.core
compile 'javax.ws.rs:jsr311-api:0.11'
//javax.xml.bind
compile 'javax.xml.bind:jaxb-api:2.1'
//javax.persistence
compile 'javax.persistence:persistence-api:1.0.2'
compile 'commons-codec:commons-codec:1.2'
//javax.json
compile 'org.glassfish:javax.json:1.0.4'
//jackson jsr310 plugin backport java7
compile 'com.github.joschi.jackson:jackson-datatype-threetenbp:2.4.4'
}
And this is the error:
Error
How can I do?
Thanks in advance

Update gradle to experimental version - Error

I'm following the guide http://tools.android.com/tech-docs/new-build-system/gradle-experimental to update my gradle configuration in order to use ndk.
Pluggin version: 0.6.0-alpha5
Gradle version: 2.10
After the changes, I get the error:
Gradle sync failed: Cause: com.android.build.gradle.managed.AndroidConfig$Impl
Here is my build.gradle. Did I forgot something or made a mistake ?
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.appid"
minSdkVersion.apiLevel 19
targetSdkVersion.apiLevel 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles.add(file('proguard-android.txt'))
proguardFiles.add(file('proguard-rules.pro'))
}
}
ndk {
moduleName "ImageProc"
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
}
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'
// JSON serialization
compile 'com.google.code.gson:gson:2.4'
// Network
compile 'com.squareup.retrofit:retrofit:2.0.0-beta3'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.okhttp3:okhttp:3.0.0-RC1'
// Junit
testCompile 'org.robolectric:robolectric:3.0'
}
I believe that buildTypes should be outside the "android" block. Also, possibly replace "defaultConfig" with "defaultConfig.with" I followed build.gradle structure in this answer. Then Gradle finally was able to build.
Maybe this will help.
My working file for:
Android Studio: 3.0.1
with:
classpath 'com.android.tools.build:gradle-experimental:0.11.1'
looks like this:
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.niedved.xxx"
minSdkVersion.apiLevel 19
targetSdkVersion.apiLevel 22
ndk {
moduleName "mupdf"
}
multiDexEnabled true
jackOptions {
enabled true
}
}
buildTypes {
release {
jackOptions {
enabled true
}
minifyEnabled false
proguardFiles.add(file("proguard-rules.pro"))
}
}
productFlavors {
}
compileOptions.with {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
}
dependencies {
compile project(':main')
compile 'com.android.support:multidex:1.0.2'
compile 'com.google.http-client:google-http-client-android:+'
compile 'com.google.api-client:google-api-client-android:+'
compile 'com.google.api-client:google-api-client-gson:+'
compile 'com.google.code.gson:gson:2.6'
compile files('libs/devsmartlib.jar')
compile files('libs/ormlite-core-4.48.jar')
compile files('libs/ormlite-android-4.48.jar')
compile files('libs/retrofit-1.7.1.jar')
compile 'it.sephiroth.android.library.horizontallistview:hlistview:1.2.2'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.google.android.gms:play-services-maps:11.6.2'
compile 'com.google.android.gms:play-services:11.6.2'
}

Categories

Resources