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 :).
Related
In Java Android we use MyActivity.class to start a new activity. I was playing with Android Studio 3 beta1 and tried to convert it to kotlin. It gets converted to MyActivity::class.java but this doesn't compile. It gives me Unresolved reference: java. What would be the correct equivalent?
Project Build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
App Build.gradle:
apply plugin: 'com.android.application'
android {
signingConfigs {
}
compileSdkVersion 25
buildToolsVersion "25.0.2"
lintOptions {
abortOnError false
}
defaultConfig {
vectorDrawables.useSupportLibrary = true
applicationId "app"
minSdkVersion 15
targetSdkVersion 25
versionCode 104
versionName "4.0.11"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
}
}
flavorDimensions "mode"
productFlavors {
free {
dimension "mode"
}
paid {
dimension "mode"
applicationId "app.paid"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.google.android.gms:play-services-ads:10.2.6'
releaseCompile 'ch.acra:acra:4.9.1'
// compile 'ch.acra:acra:4.9.1'
compile 'com.google.firebase:firebase-core:10.2.6'
compile 'com.google.firebase:firebase-database:10.2.6'
compile 'com.google.firebase:firebase-auth:10.2.6'
compile 'com.google.android.gms:play-services-auth:10.2.6'
compile 'com.github.frangsierra:rx2firebase:1.1.3'
}
apply plugin: 'com.google.gms.google-services'
Try adding following changes in your gradle file.
Add classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.3-2" in your project build.gradle file.
build.gradle(:project)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.3-2" // New
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
...
...
And add
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
two lines in app build.gradle file.
build.gradle(:app)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions' // New
apply plugin: 'kotlin-android' // New
android {
...
...
...
...
}
dependencies {
...
...
}
apply plugin: 'com.google.gms.google-services'
This must solve your problem as i have updated My Android Studio to 3.0 beta 1 and having so issues.
I Hope this helps.
I think this was an bug. I just updated to beta2 an the problem was solved.
i'm trying to use the Jgrapht library but it needs lambdas...
Here's my code:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
jcenter()
}
dependencies {
classpath "gradle.plugin.me.tatarka:gradle-retrolambda:3.3.0"
classpath 'com.android.tools.build:gradle:2.2.1'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And the :app
apply plugin: "me.tatarka.retrolambda" version "3.3.0"
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.3"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "it.univpm.gruppoids.iotforemergencyandnavigation"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.journeyapps:zxing-android-embedded:3.2.0#aar'
compile 'com.google.zxing:core:3.2.1'
compile 'org.jgrapht:jgrapht-core:1.0.0'
}
The error is: Error:(1, 0) Cannot invoke method version() on null object
Open File
Where and what is the error? thanks
You're mixing two kinds of syntaxes. Use either
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "gradle.plugin.me.tatarka:gradle-retrolambda:3.3.0"
}
}
apply plugin: 'me.tatarka.retrolambda'
or
plugins {
id "me.tatarka.retrolambda" version "3.3.0"
}
(gradle-retrolambda README), see also the gradle documentation.
I have the same issue.
You'll need to update a few things:
android/build.gradle:
i) classpath 'com.google.gms:google-services:4.0.1'
ii) Make sure google() appears above jcenter() in both buildscripts and allprojects
android/app/build.gradle:
Update Android libs to the latest specified here:
https://firebase.google.com/support/release-notes/android#20180523
if you have other libraries (for me, it's firebase) make sure to check build.gradle of the libraries, too.
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.
I'm trying to import an android project from bitbucket at my work, as the former android developer quit and I'm to continue his work.
Gradle sync never returns ok. It got the error:
Error:Could not find
com.google.android.gms:play-services-measurement:9.0.0. Required by:
frontend:app:unspecified
funny thing is, I grabbed every occourence of the string "measurement" at the whole git folder and found only one, at module app, build.gradle, and it was commented and not even the version gradle is complaining about:
dependencies {
...
// compile 'com.google.android.gms:play-services-measurement:8.3.0'
...
}
Can someone please help? I would really appriciate it as I'm struggling here for a couple of hours already.
Thx in advance!
the project (named "frontend") build.gradle:
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'me.tatarka:gradle-retrolambda:3+'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
the module (named "app") build.gradle:
apply plugin: 'com.android.application' apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.smartbus"
minSdkVersion 17
targetSdkVersion 23
versionCode 29
versionName "2.1.5"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
useLibrary 'org.apache.http.legacy'
dexOptions {
preDexLibraries = false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
abortOnError false
}
}
retrolambda {
jdk "C:\\ProgramData\\Oracle\\Java\\javapath\\java.exe"
jvmArgs '-noverify' }
dependencies {
apply plugin: 'android-apt'
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
provided "org.projectlombok:lombok:1.16.8"
apt "org.projectlombok:lombok:1.16.8"
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:24.0.0-alpha2'
compile 'com.android.support:design:24.0.0-alpha2'
compile 'com.android.support:cardview-v7:24.0.0-alpha2'
compile 'com.google.guava:guava:18.0'
compile 'org.reflections:reflections:0.9.10'
compile 'com.annimon:stream:1.0.5'
compile 'com.squareup.okhttp3:logging-interceptor:3.0.0-RC1'
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta3'
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta3'
compile 'com.github.rey5137:material:1.2.2'
compile 'com.getbase:floatingactionbutton:1.10.1'
compile 'com.prolificinteractive:material-calendarview:1.1.0'
compile 'com.google.code.gson:gson:2.5'
// compile 'com.google.android.gms:play-services-measurement:8.3.0'
retrolambdaConfig 'net.orfjackal.retrolambda:retrolambda:+'
compile 'com.google.android.gms:play-services-analytics:9.0.0'
// compile 'com.google.android.gms:play-services-location:9.0.0'
}
apply plugin: 'com.google.gms.google-services'
the whole-error:
Error:A problem occurred configuring project ':app'. Could not resolve
all dependencies for configuration ':app:_debugCompile'. Could not
find com.google.android.gms:play-services-measurement:9.0.0.
Searched in the following locations:
https://jcenter.bintray.com/com/google/android/gms/play-services-measurement/9.0.0/play-services-measurement-9.0.0.pom
https://jcenter.bintray.com/com/google/android/gms/play-services-measurement/9.0.0/play-services-measurement-9.0.0.jar
https://repo1.maven.org/maven2/com/google/android/gms/play-services-measurement/9.0.0/play-services-measurement-9.0.0.pom
https://repo1.maven.org/maven2/com/google/android/gms/play-services-measurement/9.0.0/play-services-measurement-9.0.0.jar
https://oss.sonatype.org/content/repositories/snapshots/com/google/android/gms/play-services-measurement/9.0.0/play-services-measurement-9.0.0.pom
https://oss.sonatype.org/content/repositories/snapshots/com/google/android/gms/play-services-measurement/9.0.0/play-services-measurement-9.0.0.jar
file:/C:/Users/Re'em/AppData/Local/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-measurement/9.0.0/play-services-measurement-9.0.0.pom
file:/C:/Users/Re'em/AppData/Local/Android/sdk/extras/android/m2repository/com/google/android/gms/play-services-measurement/9.0.0/play-services-measurement-9.0.0.jar
file:/C:/Users/Re'em/AppData/Local/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-measurement/9.0.0/play-services-measurement-9.0.0.pom
file:/C:/Users/Re'em/AppData/Local/Android/sdk/extras/google/m2repository/com/google/android/gms/play-services-measurement/9.0.0/play-services-measurement-9.0.0.jar
Required by:
frontend:app:unspecified
Can you change
classpath 'com.google.gms:google-services:2.0.0-alpha3' to the latest version say
classpath 'com.google.gms:google-services:3.0.0'
and check
courtesy user3330522 answer
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".