I heard of something about Data Binding early today. Since I wanted to have a try of it and know about it, I created a test project.
Data Binding is is a support repository available on API 7+. with dataBinder, we are capable of saying goodbye to findViewById (which is complained about a lot by developers) when binding application logics and layouts.
Here are information about my project:
Android Studio:
Current version: Android Studio 1.3
Build number: AI-141.2071668
Android SDK Tools: 24.3.3
Android Platform Version: MNC revision 2
Project build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0-beta4'
classpath 'com.android.databinding:dataBinder:1.0-rc0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Module build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
android {
compileSdkVersion 'android-MNC'
buildToolsVersion "23.0.0 rc3"
defaultConfig {
applicationId "me.danielpan.databindingsample"
minSdkVersion 9
targetSdkVersion 'MNC'
versionCode 1
versionName '1.0.0'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.2.0'
}
And when I run this project on a Genymotion Emulator(which is Nexus 5 in Android 5.1.0), errors happened:
Installing me.danielpan.databindingsample
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/me.danielpan.databindingsample"
pkg: /data/local/tmp/me.danielpan.databindingsample
Failure [INSTALL_FAILED_OLDER_SDK]
DEVICE SHELL COMMAND: pm uninstall me.danielpan.databindingsample
DELETE_FAILED_INTERNAL_ERROR
So, I have some questions:
1, DELETE_FAILED_INTERNAL_ERROR happened many times. It seems that this error happens when I set
compileSdkVersion 'android-MNC'
buildToolsVersion "23.0.0 rc3"
So, it's the problem of Android Build Tools of this version?
2, I followed Data Binding Guide, but I think it's old. Because Gradle Plugin has been 1.3.0-beta4, version of dataBinder should have evolved since released. So, what's is the latest version of Data Binding Plugin?
Any tips will be appreciated. Thanks in advance.
P.S.:
When I set version of Gradle Plugin 1.2.3, buildToolsVersion "22.0.1" compileSdkVersion 22, and targetSdkVersion 22, DELETE_FAILED_INTERNAL_ERROR doesn't happen again, Could somebody tell me why?
I can answer the second question. RC1 was just released, though the documentation has not been updated yet. It will read:
dependencies {
classpath "com.android.tools.build:gradle:1.3.0-beta4"
classpath "com.android.databinding:dataBinder:1.0-rc1"
}
Related
Is Android Studio backward compatible with older API?
More specifically,
I need to target API 27 with Android Studio 3.6.3.
I am unable to do so. Why?
Note: I am aware that I would not be able to publish to Play Store. This is not a problem for me.
As stated here - https://developer.android.com/studio/releases/gradle-plugin
Although the Android plugin is typically updated in lock-step with
Android Studio, the plugin (and the rest of the Gradle system) can run
independent of Android Studio and be updated separately.
And in Upgrade Gradle section, in the table
Plugin Version 3.2.0 - 3.2.1 works with Gradle version 4.6+
My set up:
Settings.gradle
distributionUrl=https://services.gradle.org/distributions/gradle-4.9-bin.zip
In apps build.grade:
SDKs/Build tools are set as:
compileSdkVersion 27 buildToolsVersion "27.0.2"
minSdkVersion 27 targetSdkVersion 27
And Dependencies:
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'com.android.support:appcompat-v7:27.1.0' i
implementation 'com.android.support:design:27.1.0'
Build.gradle (project)
buildscript {
ext.kotlin_version = '1.3.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
But I get the following:
The specified Android SDK Build Tools version (27.0.2) is ignored, as
it is below the minimum supported version (28.0.3) for Android Gradle
Plugin 3.2.1.
Why is that? Surely I was able to target 27 with that plug in version in older versions of AS.
And when I build:
error: failed linking references. (No additional detail in logs)
Note: Trying with even lower versions of Build Tools and Android Gradle Plug Ins (and targeting lower api) gives the same error. Downgrading the gradle version doesn't work either (tried with 4.6)
Note 2: Trying with the latest versions (accepting what AS 3.6.3 gives you by default, which is gradle-5.6.4, buildToolsVersion "29.0.2") gives the below error.
This is easy to reproduce - just create a new project (choose empty activity to reduce dependencies), use legacy support libraries, and change compile and target SDK to 27
.../appcompat-v7-28.0.0/res/values-v28/values-v28.xml:5:5-8:13: AAPT:
error: resource android:attr/dialogCornerRadius not found.
Does it mean you just cannot target anything below 28 with AS 3.6.3? What role would AS play here if the building blocks here are Build Tools and Android Gradle Plug in (as stated above), which I can choose as I please, and yet to no effect?
And just want to note: no, I don't want to update to api 28. I need specifically below 28, and my current version of AS is 3.6.3.
Is there no way out and have to use an older AS? And if the latter, what would then be the role of AS in this?
Tool versions are largely independent of your targetSdkVersion, you don't need buildToolsVersion "27.0.2" for a target sdk of 27
Edit your app's build.gradle to use modern versions of the build tools, and then set targetSdkVersion 27
Note that you will not be able to deploy to the Play Store with this as the minimum target is now 28 (current as of 5/13/2020) source: https://developer.android.com/distribute/best-practices/develop/target-sdk
The following is a portion of a valid app module build.gradle targeting sdk 27
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.mikedg.dekudeals"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
The following is a portion of the buildscript from the project build.gradle that works with it
buildscript {
ext.kotlin_version = '1.3.71'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
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
}
If the above does not work, I recommend looking into migrating to the androidx libraries instead of the old support libraries. https://developer.android.com/jetpack/androidx/migrate#additional_resources
I don't think this should cause problems, but can't confidently say that it wouldn't
I have installed Android Studio 3.1.13 with gradle 4.8.1 and java 1.8.0_171, previously installed. I have installed also the SDK API 22 because I need to test an app in Android 5.1.1
The problem is that the default configuration has compileSdkVersion 28 and I had changed it to 22. I have tried many settings but there are always errors due to the version of android API
My current module build.gradle is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.company.test"
minSdkVersion 22
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.0.0'
}
and the proyect build.gradle is
buildscript {
repositories {
google()
jcenter()
}
dependencies {
//classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
When I tried to build, the IDE now says
The SDK Build Tools revision (22.0.1) is too low for project ':app'. Minimum required is 25.0.0
Don't know how can I build and test and app for API 22. I'm newbie in Android develpoment. Thanks in advance
As far as I understand your question, the app needs to be tested running on android api level 22 right?
Based on this assumption I would say the most straight forward solution would be to keep every value on default (as long as this worked for you before). Just lower the minSdkVersion to 22.
Short explanation of most important values:
compileSdkVersion 22 : API Level the app is compiled against
buildToolsVersion '22.0.1' : Buildtools Version to compile code (has to match compileSdkVersion)
minSdkVersion 22 : This is the minimum api you want the app running on.
targetSdkVersion 22 : Simply says, you tested your app running on specified API. Google now uses this to determine if your app is up to date to be published in Playstore or not
As emandt already mentioned BUILDTOOLS and gradle should be up to date, as well as targetSdkVersion and compileVersion.
TESTING APP ON API Level:
As long as you compiled your app for a target higher than minSdk you can simply build and install the apk to a device running the requested API level.
The "buildToolsVersion" string should be compatible with the "classpath 'com.android.tools.build:gradle:x:x:x" setting.
You have to lower the second setting until it is accepted.
However I suggest to use latest BUILD TOOLS and latest GRADLE and not revert back to an old ones. Those Tools affect only the Build procedure, not the App itself.
This question already has an answer here:
When using compile 'com.google.android.support:wearable:2.0.4' I get the error below, but I am not using 26.0.0
(1 answer)
Closed 5 years ago.
I'm developing a music application for both mobile & wear. I've completed building the base of the application on mobile, and now I want to start the wearable (2.0) part. I tried following the tutorial on the Android Developer site, but even following the base directions gives me a Gradle sync error. I tried adjusting the compileSdkVersion and targetSdkVersion both to 24, which I use for my mobile gradle scrip. It didn't make a difference however.
This is the instruction mentioned:
In the build.gradle file for the Wear module:
>> In the android section, confirm that the compileSdkVersion is set to 25.
>> In the android section, confirm that the targetSdkVersion is set to 25.
Update the dependencies section as follows (requires the latest version of the Google Repository):
compile 'com.android.support:wear:26.0.0'
compile 'com.google.android.support:wearable:2.0.3'
provided 'com.google.android.wearable:wearable:2.0.3'
.
Clicking on "install repository and sync project" has no effect.
This is the build.gradle file for the Wear module.
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "be.ehb.dt.finalwork_lievenluyckx_v001"
minSdkVersion 21
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:wear:24.0.0'
compile 'com.google.android.support:wearable:2.0.3'
provided 'com.google.android.wearable:wearable:2.0.3'
}
I'm really new to Android, and I don't really understand what is going wrong here. Any help is appreciated, even if it isn't a direct solution to the issue!
Edited: After trial-error,solution finally was found:
In build.gradle file -> allprojects, within repositories,code below should be added...
1) For the Android Gradle plugin revision 2.3.3 with Gradle 3.3 (Android Studio 2.3.3)
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
2) For the Android Gradle plugin revision 3.0.0 with Gradle 4.1(Android Studio 3.0.0)
allprojects {
repositories {
jcenter()
google()
}
}
For more here: When using compile 'com.google.android.support:wearable:2.0.4' I get the error below, but I am not using 26.0.0
Change your gradle to:
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "be.ehb.dt.finalwork_lievenluyckx_v001"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:wear:26.0.0'
compile 'com.google.android.support:wearable:2.0.3'
provided 'com.google.android.wearable:wearable:2.0.3'
}
I updated android studio from version 1.0 to 1.2.1 and when I started my first application the this appears.
Error:Execution failed for task ':app:compileDebugAidl'.
aidl is missing
I have made sure that all sdk are up to date. This is my gradle build code.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc1"
defaultConfig {
applicationId "com.example.william.myapplication"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
compileSdkVersion 21
}
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:22.2.0'
}
It seems that AndroidStudio-1.3-Preview is using an unexpected version of the gradle plugin. (at least when you create a fresh new project)
Similarly, if you open an existing project using:
an older version of the plugin. (<1.3.0-beta1)
latest build tools (23.0.0-rc1)
compileSDK 22
---> you will probably have this strange error : "aidl is missing" (even in projects not using aidl !)
Solution:
Be sure to use the latest android-gradle-plugin (in the root build.gradle) :
classpath 'com.android.tools.build:gradle:1.3.0-beta1'
under buildscript-->dependencies.
Example :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0-beta1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
and the latest build tools (in module build.gradle):
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc1"
... }
BE AWARE that with this config you are using the latest build tools -not released yet- and the preview of Android-M ---> things can be unstable
I had the same error. I changed the build tools version in the gradle script to my actual sdk build tool version found in sdk manager and that did the trick.
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
...
I'm trying to create a google glass app(immersion based) on Android Studio 1.1.0 and this error throws up.
Error:Could not normalize path for file 'C:\Users\admin\AndroidStudioProjects\Sampleapp\app\build\intermediates\mockable-Google Inc.:Glass Development Kit Preview:19.jar'.
The filename, directory name, or volume label syntax is incorrect
I previously tried on eclipse and it all worked fine but in Android Studio it's a little weird.
Update
Project: build.gradle
apply plugin: 'com.android.application'
repositories {
jcenter()
flatDir {
dirs 'prebuilt-libs'
}
}
android {
compileSdkVersion "Google Inc.:Glass Development Kit Preview:19"
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "example.com.Sampleapp"
minSdkVersion 19
targetSdkVersion 19
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(include: ['*.jar'], dir: 'libs')
}
This error appears if you use
classpath 'com.android.tools.build:gradle:1.1.0'
The highest level of Gradle build tools supported for Glass development is
classpath 'com.android.tools.build:gradle:1.0.1'
You could use a classpath of 1.1.+ instead. Either way, it probably has something to do with the inability of Gradle to escape the dot after Google Inc. in the path.
Let me know if that works for you.