No ConstraintLayout in Android Studio - android

I learning on how to build a Responsive UI with ConstraintLayout by following this article. But I can't see ConstraintLayout options in my Android Project.
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.tony.chatapp"
minSdkVersion 15
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'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
repositories {
maven {
url 'https://maven.google.com'
}
}
What did I miss here ?

You need to update your Android Studio to 2.2 or above. Constraint layout was introduced in Android Studio 2.2. It is always recommended to use latest version of Android Studio.

ConstraintLayout is available in an API library that's compatible with Android 2.3 (API level 9) and higher. This page provides a guide to building a layout with ConstraintLayout in Android Studio 2.3 or higher.
Build responsive UI with ContraintLayout
As you are using an older version of android studio first upgrade your Android-studio version.

Related

Error on Android app Azure dependency gradle build

I am getting the following error on Android Studio 2.3.3 at Gradle sync.:
"`Error:Module 'com.microsoft.azure:azure-mobile-android:3.3.0' depends on one or more Android Libraries but is a jar."
The error disappears if I use
compile 'com.microsoft.azure:azure-mobile-android:3.1.0'
instead of
compile 'com.microsoft.azure:azure-mobile-android:3.3.0'
but i don't want to use an outdated version.
build.gradle file is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.my_software.myapp"
minSdkVersion 14
targetSdkVersion 25
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:25.3.1'
compile 'com.google.android.gms:play-services-drive:11.0.1'
compile 'com.google.android.gms:play-services-plus:11.0.1'
//FOR microsoft Azure
compile 'com.microsoft.azure:azure-mobile-android:3.3.0'
}
TEMPORARY SOLUTION:
compile('com.microsoft.azure:azure-mobile-android:3.3.0#aar'‌​)
(add #aar at the end).
I reviewed the source code of azure-mobile-apps-android-client on GitHub, and the difference of the build.gradle between 3.1.0 and 3.3.0 is that the version 3.3.0 required the dependency com.android.support:customtabs:23.0.1, but version 3.1.0 not. So you need to downgrade the compileSdkVersion & targetSdkVersion value from 25 to 23 to support the required Android library to resolve it, due to com.android.support:customtabs:23.0.1 is belong to Android API 23.

Android Studio Build.Gradle Sync Error

I am experiencing a problem building my application in Android Studio. I am using Android Studio 2.2 Preview 7. When I start up my Android Studio it gives an error:
The plugin is too old, please update to a more recent version, or set
ANDROID_DAILY_OVERRIDE environment variable to xxxxxxx.
It requests I fix plugin version and sync project. I have made all the required updates but the error remains. I have read similar questions on the issue but they don't seem to apply to my case.
Could you please assist in providing me with a working solution?
Here is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.mobileappdev.novarttech.sunshine"
minSdkVersion 10
targetSdkVersion 23
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:23.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha4'
compile 'com.android.support:design:23.3.0'
testCompile 'junit:junit:4.12'
}
As per my observation it seems like you haven't updated Android SDK platform to version 25. First of all download and install android sdk platform and build tools from SDK Manager and use the following lines in your build.gradle(module app)
compileSdkVersion 25
buildToolsVersion "25.0.0"
Also update dependencies according to that. It should work then
As #claudio-redi says, you need to upgrade your build gradle tools.
Use build tools 2.2.2 to your root build.gradle:
classpath 'com.android.tools.build:gradle:2.2.2'
And change the gradle distribution to 2.14.1 in gradle/wrapper/gradle-wrapper.properties file with:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
Or if you already have download the gradle distribution and place it in a directory, you can set it in your Android Studio from menu File->Setting->Gradle and set it as the following image:
Please be noted when you want to use API Level 25 you need to make sure that compileSdkVersion, buildToolsVersion, targetSdkVersion, and Support Library using the same API Level 25.

What is Android N and why does it think I'm building with it? (Android Studio 2.1.2, Windows 7)

I started a new generic Android project and I'm getting an error in the Design View saying "Android N requires the IDE to be running with Java 1.8 or later".
But earlier Gradle complained: Error:(3, 22) compileSdkVersion android-23 requires compiling with JDK 7 so I installed JDK 7 - 1.7.0_79 and that fixed the Gradle problems. I don't really want to go to JDK 8.
So what is Android N ? My understanding is that it's the "next" or "latest" version of Android, but I don't need that for my work. I just need to support CalendarView and NestedScrollView. Where am I telling it that I need "Android N", and how do I change that?
My Build.Gradle says:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.ags.mycalendarviewapp"
minSdkVersion 15
targetSdkVersion 19
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:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
}
...
So what is Android N ?
It is the next version of Android, API Level 24. The tasty treat is Nougat.
(no, really, that's the name)
Where am I telling it that I need "Android N", and how do I change that?
If you are getting that in the design view, that's the version of Android that is being used for the preview. It defaults to the latest version whose SDK bits you have installed.
To change it, switch it in the bugdroid drop-down on the right side of the design view toolbar:

Is it possible to add older version com.android.support:appcompat-v7 in android studio?

How can I add the com.android.support:appcompat-v7 for android version 7.
Android studio forces me to set the compile version to 22.1.1,
but when the project doesn't compile.
I have to set the compile version and the target version to 7,
cause otherwise some functionality doesn't work.
My build-gradle look like this:
apply plugin: `'com.android.application'`
android {
compileSdkVersion 7
buildToolsVersion "23.0.0 rc2"
defaultConfig {
applicationId "com.example.ella.pulltorefreshexample"
minSdkVersion 7
targetSdkVersion 7
versionCode 1
versionName "1.0"
}
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.1.1'
}
Thanks!
How can I add the com.android.support:appcompat-v7 for android version 7
There was no version 7. The oldest is 18.0.0, and the 21+ editions are significantly different than the ones prior to that.
I have to set the compile version and the target version to 7, cause otherwise some functionality doesn't work.
Then you need to fix the functionality in your app (so that you can use a higher compileSdkVersion and a realistic targetSdkVersion), or not use appcompat-v7.

Android missing layout_alignParentStart after upgrade

I upgraded from Android Studio 0.5 to 0.8
now I have heaps of issues, I resolved most of them but now I get this error
Error:(12) No resource identifier found for attribute 'layout_alignParentStart' in package 'android'
I dont know why it does not have layout_alignParentStart anymore?!
am I missing something here?
I had the same issue, my problem was the compileSdkVersion, I changed from 16 to 20 and it works.
I give you my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "mypackage"
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:20.+'
// You must install or update the Support Repository through the SDK manager to use this dependency.
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile 'com.android.support:support-v4:20.+'
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile 'com.android.support:support-v13:20.+'
}
Since API level 17, android has some new attributes for RTL layout such as:
layout_alignParentStart
layout_alignParentEnd
layout_alignStart
layout_alignEnd
layout_marginStart
layout_marginEnd
however some devices has special ROM which may not support these attributes and leads exception
Remove all these *Start /*End attributes can fix the issue

Categories

Resources