Data binding cannot be added to my project - android

In my Android project, I have needed to enable the dataBinding library in module level build.gradle as below, but it gives me the error in the image. How can resolve it?
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.2"
defaultConfig {
applicationId "com.nasser.studio.multipledeletelistview"
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding{
enabled = true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.codesgood:justifiedtextview:1.0.2'
}
Edit 1.
I've changed the project level build.gradle to add support-v4 library, but now it throws the following error:
repositories {
google()
jcenter()
configurations.all {
resolutionStrategy.force "com.android.support:support-v4:27.0.2"
}
}

one of your 3rd party libraries or sdk you use rely on support version 21.0.3. Either remove it or have resolutionStrategy in your Gradle.
configurations.all {
resolutionStrategy {
force ....
}
}

Try upgrade your android gradle plugin.
Add compile "com.android.support:support-v4:27.0.2" manually to your gradle file.
That should solve your problem.

That's not a Databinding error, It's just saying that all your support-related libraries should use the same version. For example look at my gradle file:
implementation "com.android.support:recyclerview-v7:$libraries.googleSupportVersion"
implementation "com.android.support:appcompat-v7:$libraries.googleSupportVersion"
implementation "com.android.support:support-v13:$libraries.googleSupportVersion"
implementation "com.android.support:design:$libraries.googleSupportVersion"
implementation "com.android.support:cardview-v7:$libraries.googleSupportVersion"
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
My support library version being:
ext.libraries = [
...
googleSupportVersion : '27.1.1',
...
]
Your issue seems to be that compile 'com.codesgood:justifiedtextview:1.0.2' internally is using the support library with a version different than yours. However your version is totally updated I wouldn't downgrade it just to have it match with the other, in any case you could just add a:
allprojects {
configurations.all {
resolutionStrategy.force "com.android.support:support-v4:27.0.2"
}
}
In your project gradle. You could also run gradlew app:dependencies in the Android Studio console, do a Ctrl+F on the output, search for that com.android.support:support-v4:27.0.2 and figure out from where is coming. (You only have one dependency for what I see, so there's not much science from where IT should be coming)
Let me know if this works for you.

Related

Module inclusion: not intended for consumption by other components - gradle:3.0.0-alpha2

Upgraded to:
Android Studio 3.0 Canary 2
com.android.tools.build:gradle:3.0.0-alpha2
I have a multi-module project (main app + sub modules)
Inclusion inside the main app:
dependencies {
implementation project(path: ':testlib', configuration: 'default')
}
The testlib is defined as a simple android library project and works normally when included with gradle 2.3.0 and via compile project(path: ':testlib')
I get the following gradle error message:
Could not resolve all dependencies for configuration ':app:devDebug_signedCompileClasspath'.
Selected configuration 'default' on 'project :testlib'
but it can't be used as a project dependency because
it isn't intended for consumption by other components.
What does "isn't intended for consumption by other components" mean in this context? The module is defined as an android library.
Here is the build.gradle of the testlib:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha2'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
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'])
}
What am I missing?
I also got this error. Android Studio 3.0 Canary 4 just came out. I updated to it, which also updates gradle to 4.0rc1.
The problem went away on it's own.
alter your Top-level build file (aka root gradle)
classpath 'com.android.tools.build:gradle:3.0.0-alpha4'
still not working?
update dist-url (inside gradle-wrapper.properties)
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-rc-1-all.zip

Failed to resolve: com.android.support:appcompat-v7:23.4.0

I want to use MusicBobber library in my project, but this error showed up
Error:Failed to resolve: com.android.support:appcompat-v7:23.4.0
I have com.android.support:appcompat-v7:23.1.1
and this is complete gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.tabaneshahr.playaudiotest"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
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.cleveroad:audiowidget:0.9.2'
}
I'd searched stackoverflow but noting useful. what should I do? does minSDK must change? shall I download anything?
First, replace your appcompat compile line with the latest one like this:
compile 'com.android.support:appcompat-v7:24.2.0'
Update to the targetSdkVersion 24 as well.
and remove the compile line for the library:
compile 'com.cleveroad:audiowidget:0.9.2'
Second, clean/build and run the project, you should not get any errors. If this happened, then your problem is not with the appcompact at all, but it is with the library.
Thrid, try to add the library compile line and again and let the gradle sync. If you still getting a problem, then I recommend to save your self the hassle and integerate the library in your code manually by doing the following this link steps
Hope it helps!
Please update your build tool version :
buildToolsVersion "23.0.2"
to 25 or you can use
compile 'com.android.support:appcompat-v7:23.0.0'
Clean and rebuild your android project.
> create a new project and you will see exact version .
for example for me in project file was :
compile 'com.android.support:appcompat-v7:24.2.0'
but after created new project i saw it is like this :
compile 'com.android.support:appcompat-v7:24.0.0-alpha2'
so changed and sync and fixed .
I ran into this error while trying to run SQLite Android Bindings. It still uses a very old gradle configuration (included below).
TLDR
com.android.support:appcompat-v7:23.4.0 is very old and only available on https://maven.google.com (google() in build.gradle) as of this writing. Make sure your root build.gradle includes the google() repository in its allprojects.repositories section:
allprojects {
repositories {
jcenter()
google()
}
}
SQLite's woefully out of date gradle configuration:
$ROOT/build.gradle:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
// this was the problem. google() was missing!
}
}
$ROOT/sqlitetest/build.gradle:
android {
compileSdkVersion 25
defaultConfig {
minSdkVersion 16
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
...
}

Android Studio: How to see sources for android support v4 and v7?

In Android Studio support library appcompat (for ActionBar) is defined as Gradle dependency.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
That resolves to get v4 as well.
How to see source when clicking to into classes?
e.g. android.support.v4.widget.DrawerLayout
Currently Android Studio says
// IntelliJ API Decompiler stub source generated from a class file
// Implementation of methods is not available
For ADT it was How to add source + javadoc for android-support-v7?
Following from the above research done by Paul Verest...
IDE: Android studio 1.3.2
It is a 2-step process: Consider this sample build.gradle
1) Add the following to your build.gradle (Module:app) - search the 2 //Add comments below.
apply plugin: 'com.android.application'
apply plugin: 'idea' //Add
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.mycompany.android.myapp"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.0'
}
//Add
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
2) Rebuild project.
After this point if you want to see source in Android Studio, it will pull up the source *.java instead of decompiled *.class
Thanks to Setu for hint. As I already had all sources before, I just added in app/build.gradle
apply plugin: 'idea'
idea {
module{
sourceDirs += file("E:\\Android\\sdk\\extras\\android\\support\\v4\\src\\")
sourceDirs += file("E:\\Android\\sources\\platform_frameworks_support\\v7\\appcompat\\src")
}
}
below dependencies section and press "Sync project with Gradle Files"

Error : Failed to find: com.android.support:support-v4:20.0.+

I have imported a project in Android Studio that was built in it. I require v4 and v7 library in the project. This is how my build.gradle looks like
build.gradle
apply plugin: 'android-library'
android {
compileSdkVersion 19
buildToolsVersion '20'
defaultConfig {
applicationId 'com.example.sdk'
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:20.0.+'
compile 'com.android.support:support-v4:20.0.+'
}
When I sync with gradle then it always gives error message
Failed to find: com.android.support:support-v4:20.0.+ & Failed to find: com.android.support:appcompat-v7:20.0.+
Please support & thanks in advance.
The Android support repository was missing,So go to Android SDK, install the Android Support Repository and Android Support Library.
Also you can use the following
compile 'com.android.support:support-v4:20.0.0'
compile 'com.android.support:appcompat-v7:20.0.0'
instead of
compile 'com.android.support:appcompat-v7:20.0.+'
compile 'com.android.support:support-v4:20.0.+'
Note: If you're developing with Android Studio, select and install the Android Support Repository item instead.
see here.
From Android Studio go to: Tools >> Android >> SDK Manager
Select and install "Extras|Android Support Repository"
add maven to your gradle file (project)
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
}
and use this gradle wrapper:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
and downgrade to gradle plugin to be 2.3.1
classpath 'com.android.tools.build:gradle:2.3.1'

"provided" scope not working - android studio with gradle

I need to prevent gradle from exporting a certain shared library.
I´ve read that using the provided scope should do the trick, but it seems that it was only working with older gradle versions.
Is there any other way to exclude dependencies from the build process to not get them into the final apk?
I have found solution here: https://stackoverflow.com/a/10406184/310760
But for Gradle 2.0 it has small changes:
configurations{
provided
}
sourceSets {
main {
compileClasspath += configurations.provided
}
test {
compileClasspath += configurations.provided
}
}
sourceSets.main.compileClasspath += configurations.provided
idea {
module{
scopes.PROVIDED.plus += [configurations.provided] // for Gradle 2.0
}
}
I have the same problem, and I found some solutions.But I don't understand.
http://www.sinking.in/blog/provided-scope-in-gradle/
Solved thie problem by using the android-apt gradle plugin.
see https://bitbucket.org/hvisser/android-apt/overview
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "org.ligboy.test.card.module1"
minSdkVersion 14
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
configurations {
apt
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
apt 'com.android.support:support-v4:21.+'
apt 'com.google.code.gson:gson:2.2.+'
apt 'com.android.support:cardview-v7:+'
apt 'com.android.support:recyclerview-v7:+'
}
Fought with this for a while and found:
"provided" is part of gradle 1.3.0, but doesn't work properly.
"provided" works properly in gradle 1.5.0!
FYI: I had to delete my build directory after upgrading to 1.5.0 to remove the lib file from the .aar.

Categories

Resources