AndroidStudio/Kotlin - Unresolved reference: ReadWriteProperty - Kotlin version 1.0.0-beta-1038 - android

I have a working Android project using Kotlin version 1.0.0-beta-1038 in Android Studio.
I can run it using Kotlin in different parts, it compiles and works in the emulator but when I tried to use ReadWriteProperty it gives this error message:
Unresolved reference: ReadWriteProperty
Class called PreferenceUtils.kt:
build.grade (Module: app)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.droidcba.oculto"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.squareup.retrofit:retrofit:2.0.0-beta1'
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta1'
compile 'io.reactivex:rxandroid:1.0.1'
compile 'io.reactivex:rxjava:1.0.14'
}
buildscript {
ext.kotlin_version = '1.0.0-beta-1038'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
}
}
repositories {
mavenCentral()
}
build.grade (Module: myProject)
// 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:1.3.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
}
Please let me know if you need more info. Thanks!

Solved! I have to upgrade the Kotlin Plugin
from Android Studio. It started to recognise "ReadWriteProperty".

Related

Kotlin in android studio

I am using from kotlin but when I sync it in my project get me bellow error :
Error:Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-3.
Searched in the following locations:
file:/D:/android-studio/gradle/m2repository/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1.2-3/kotlin-gradle-plugin-1.1.2-3.pom
file:/D:/android-studio/gradle/m2repository/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1.2-3/kotlin-gradle-plugin-1.1.2-3.jar
https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1.2-3/kotlin-gradle-plugin-1.1.2-3.pom
https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1.2-3/kotlin-gradle-plugin-1.1.2-3.jar
Required by:
project :
Here is my build.gradle(Module) :
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "ir.baslam.kotlinme"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
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:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
repositories {
mavenCentral()
}
And here is my build.gradle(project) :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.2-3'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// 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
}
ext.kotlin_version = '1.1.2-3'
'1.1.2-3' version is not available in jcenter repo neither it is available in your file system.
As I check the latest version 1.1.2-2 is available in jcenter that is last update on Apr 28, 2017 so use 1.1.2-2 version instead of 1.1.2-3.
ext.kotlin_version = '1.1.2-2'
The Kotlin Gradle plugin version which you set is not still available on repository.
Try setting to any other version like:
ext.kotlin_version = '1.1.1'

Adding apply plugin: 'org.robolectric' in (app)gradle file shows project refresh failed Error:The Android Gradle plugin 2.1.2 is not supported

Hi Am trying to configure Jenkins in android studio. I followed this link
and i installed Jenkins in MAC system and verified with my localhost to check its running perfectly or not(as mentioned in the above link).
I have added following line in my project(root) dependency.
classpath 'org.robolectric:robolectric-gradle-plugin:1.0.1'
My updated project .gradle file is
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'org.robolectric:robolectric-gradle-plugin:1.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
No issues while sync project .gradle file.
But the problem starts after updating(adding robolectric) app .gradle file
apply plugin: 'com.android.application'
apply plugin: 'org.robolectric'
this gives me the following error message
Gradle 'CreatrixAndApp' project refresh failed
Error:The Android Gradle plugin 2.1.2 is not supported.
this is my project root .gradle file
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'org.robolectric:robolectric-gradle-plugin:1.0.1'
}
}
allprojects {
repositories {
jcenter()
}
}
this is my app .gradle file
apply plugin: 'com.android.application'
apply plugin: 'org.robolectric'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
repositories {
mavenCentral()
maven {
url "${System.env.HOME}/.m2/repository"
}
flatDir {
dirs 'libs'
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId 'com.creatrixhrm'
minSdkVersion 16
targetSdkVersion 23
versionCode 20160615
versionName "1.6.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':photoViewerLibrary')
compile project(':multipleImagePick')
compile(name: 'creatrixone1_1', ext: 'aar')
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-vector-drawable:23.3.0'
compile 'com.android.support:animated-vector-drawable:23.3.0'
compile 'com.koushikdutta.ion:ion:2.1.7'
compile 'mbanje.kurt:fabbutton:1.2.2#aar'
compile 'com.google.code.gson:gson:2.4'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'io.jsonwebtoken:jjwt:0.6.0'
}
I tried following this suggestion, but no use
can anyone tell me where i am making mistake

gradle is not resolving any new dependencies in android studio

I am making an Intro for my app.So after some research i had got an github project which is used to make cool intros.It requires following dependencies :
compile 'com.github.paolorotolo:appintro:4.0.0'
when I compile it with gradle it gives me following errors:
Failed to resolve: com.github.paolorotolo:appintro:4.0.0
I have done some research on internet but anything didn't worked out.
here is my build.gradle(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.example.adarsh.testapp"
minSdkVersion 16
targetSdkVersion 24
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:24.2.0'
compile 'com.android.support:support-v4:24.2.0'
compile 'com.github.paolorotolo:appintro:4.0.0'
}
and here is my build.gradle(project:testapp)
// 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.3'
// 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
}
I solved my issue by just adding mavenCentral() in repositories in build.gradle.

Android Studio 2.0 : Gradle DSL method not found: 'classpath()' error(27,0)

First of all, I've read all other solution posts and So far, none has worked.
and I'm using Android Studio 2.0
Error:
Error:(27, 0) Gradle DSL method not found: 'classpath()'
Possible causes:The project 'Sailu'sFood' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper fileThe build file may be missing a Gradle plugin.
Apply Gradle plugin
here is build.gradle(app) :
apply plugin: 'com.android.application'
android
{
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.kandarp.food"
minSdkVersion 21
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'
classpath 'com.google.gms:google-services:2.0.0-alpha6'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
}
apply plugin: 'com.google.gms.google-services'
here is build.gradle(top level) :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'project-report'
apply plugin: 'application'
It'd really great if someone could point out what's the mistake
Remove this line from app/build.gradle from the dependencies block.
classpath 'com.google.gms:google-services:2.0.0-alpha6'
Then you have to move the line in the buildscript block (in the top-level file or in the module file):
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.google.gms:google-services:2.0.0-alpha6'
}
}

Error:(3, 0) Cause: org/apache/commons/lang3/StringUtils

I get the following error
Error:(3, 0) Cause: org/apache/commons/lang3/StringUtils
when I try to add data binding in my Android project.
My dependencies include :
// 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-alpha7'
classpath 'me.tatarka:gradle-retrolambda:3.2.2'
classpath 'com.android.databinding:dataBinder:1.0-rc1'
// 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
}
My gradle wrapper is : distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip
My gradle file :
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'com.android.databinding'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.quizviz.workbook.myworkbook"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
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'
compile 'io.reactivex:rxandroid:1.1.0'
compile 'io.reactivex:rxjava:1.1.0'
compile 'com.jakewharton.rxbinding:rxbinding:0.2.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta3'
compile 'com.squareup.retrofit2:converter-jackson:2.0.0-beta3'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0-beta3'
compile 'com.squareup.okhttp3:okhttp:3.0.1'
compile 'com.squareup.okhttp3:okhttp-urlconnection:3.0.1'
}
It took me a while to notice this problem is caused by google updating the way to use data binding library. You can see more information from here:
http://developer.android.com/tools/data-binding/guide.html.
You can just remove these two lines of code:
apply plugin: 'com.android.databinding'
And this one in buildscript's dependencies:
classpath 'com.android.databinding:dataBinder:1.0-rc1'
Then add the dataBinding section to your build.gradle like this.
buildscript {
...
}
android {
...
dataBinding {
enabled = true
}
...
}
dependencies {
...
}
Here you go. This works for me :).

Categories

Resources