Error:In <declare-styleable> ConstraintSet - android

I'm working in a project and I would like to use Constraint! If I use it, when i want build the gradle or intall the apk in a pohne, i've this error:
"Error:In ConstraintSet, unable to find attribute android:elevation"
This is my gradle configuration:
defaultConfig {
applicationId "application"
minSdkVersion 14
targetSdkVersion 17
versionCode 25
versionName "3.11"
}
Can i change sometigh? There is a way to use constraint without change the version?
Thanks

You can try to compile with compile'com.android.support.constraint:constraint-layout:1.0.1 in build.grade. Or check compileSdkVersion to newest version

The android:elevation attribute is pretty new.
It defines the lift of the view on which its applied. It's used in Material Design in the newest Android Versions.
You can use it on API Level 21, and here you targeted Level is 17 which is lower than this.
replace your targeted version to 21 or above
If you want to get some shadowing effect you can use this:
Shadow
Hope this helps.

Related

How to get "CompileSdkversion" programmatically in Android

I have an About box in my App that displays information about the App, the phone and the data it uses. It's very useful when a user has a problem. I can get the phone's SDK version using "android.os.Build.VERSION.SDK_INT". However, I haven't found a way to get the value of "CompileSdkversion" which indicates the SDK version the App was compiled with. This is the value that is set in the build.gradle file.
While the Android OS version varies by user, the compileSdkVersion does not. For version X.Y.Z of your app, the compileSdkVersion is whatever you said it was when you compiled that app version. So long as your about box contains the app version, you know what compileSdkVersion that you used, if you keep track of that (e.g., check what it was in your version control system).
But, if you really want to have it be available to you at runtime, you have two options.
If your minSdkVersion is 31 or higher, you can use compileSdkVersion on ApplicationInfo. However, most likely, if you are reading this before the year 2026, your minSdkVersion is lower than that.
For older devices than Android 12, you could add a BuildConfig field for it, at least with newer versions of the Android Gradle Plugin:
android {
compileSdk 31
defaultConfig {
applicationId "com.commonsware.android.myapplication"
minSdk 23
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField "int", "COMPILE_SDK_VERSION", "$compileSdk"
}
// other stuff goes here
}
This takes your defined value for compileSdk and hoists it into BuildConfig.COMPILE_SDK_VERSION, so you can reference it at runtime. This was tested using a scrap Arctic Fox project, using Gradle 7.0.2 and 7.0.3 of the Android Gradle Plugin.
Here is the relationship between the three values:
minSdkVersion (lowest possible) <=
targetSdkVersion == compileSdkVersion (latest SDK)
CompileSdkVersion has nothing to do with what devices can and cannot run your app. Usually, you set this to be the latest version of the Android SDK.
And the targetSdkVersion should be fully tested and less or equal to compileSdkVersion.(It depends on your app)
If you are using the features of API level of 26 then you need to use compileSdkVersion 26, the lower version will give you an error.
Android supports backward compatibility
(i.e. an app compiled on 26 can also run on a phone having API level 26 or lower).
Considering your use-case, wouldn't a better approach be just to show the current app version? If you know the version, you could look up how/when it was created (via git tags, for example) and then find out the SDK version it was compiled with.

Android Studio API level error for Android Wear

I am trying to run and test a simple android application using android studio(version 3.0.1) on a smartwatch, I am getting the below error with respect to the gradle sync. (I am creating an new project by selecting the wear with the API level of 22 which is same as smartwatch API level).
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 22 cannot be smaller than version 23 declared in library [com.android.support:wear:26.1.0] C:\Users\Sai.gradle\caches\transforms-1\files-1.1\wear-26.1.0.aar\5b2a40104c2cc0843c9e44597771b49a\AndroidManifest.xml as the library might be using APIs not available in 22
Suggestion: use a compatible library with a minSdk of at most 22,
or increase this project's minSdk version to at least 23,
or use tools:overrideLibrary="android.support.wear" to force usage (may lead to runtime failures)
I have looked up for this error in most of the stackoverflow post's and they suggested to change the minimum SDK version in the build.GRADLE (app module) file in the defaultConfig section to 23, and the error doesn’t appear when I change the version to 23 as below.
defaultConfig {
applicationId "com.example.sai.wearexample"
minSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
But, if I change the minSdkVersion version to 23 then there is the below error while I want to run the application on the smartwatch.
I have looked into many of the answers in the stackoverflow but I am not able to get any of the specific resolutions for this question. I am stuck in between these two errors, any help would be appreciated.
You should not use com.android.support:wear for api <23.
For the views you can add:
provided 'com.google.android.wearable:wearable:2.3.0'
compile 'com.google.android.support:wearable:2.3.0'
And change in your java and xml the code for use the tools of
com.google.android.wearable
instead
com.google.android.support:wearable
For example, use android.support.wearable.view.BoxInsetLayout instead of android.support.wear.widget.BoxInsetLayout.
I hope I have helped.

Android support compat errors

My project worked fine last time.
Now I can't build this, I see a lot of problems in com.android.support/apcompat-v7/22.0.0/res/values-v21/values.xml
Error:(47, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
I need to build my application for minSdkVersion 16 and targetVersion 16.
My project is compiling only if I set minSdkVersion, targetVersion and compilingVersion to 21.
I'm using Android Studio 1.2.2.
Please help me to fix this problem.
I see a lot of problems in com.android.support/apcompat-v7/22.0.0/res/values-v21/values.xml
Your compileSdkVersion should be 22, if you are going to use a 22.x.y version of a support library.
I need to build my application for minSdkVersion 16 and targetVersion 16.
Set minSdkVersion to 16, targetSdkVersion to 16, and compileSdkVersion to 22. Changing minSdkVersion nor targetSdkVersion values will not result in errors like the one that you cite.
To fix this problem you need to use:
compileSdkVersion 21
I didn't known before about:
compileSdkVersion - is the version of the API the app is compiled against. This means you can use Android API features included in that version of the API.
minSdkVersion - controls the lowest level you say your application can run on.
targetSdkVersion - ontrols any automatically applied backward compatibility features

Android Lollipop & appcompat v7

I'm I only one who has this issue: in build.gradle of the application I define these:
android {
compileSdkVersion 21
buildToolsVersion "21.0.1"
defaultConfig {
applicationId "my.package.name"
minSdkVersion 8
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
}
dependencies {
// ...
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'
}
And in the end (after syncing project in android studio 0.8.9, updating to 0.8.13) I'm getting error that some resources aren't found though I've downloaded ALL SDK updates?
I'm not using any kind of google play services or etc. Currently the only thing I want is to get "materialized" ActionBar in my Nexus 5 with Lollipop image flashed.
Thanks a lot
I had this issue in Eclipse where my compile target was not set to api 21. As you have set this I can imagine that your gradle setup does not include the resources.
Maybe that helps:
How do I add a library (android-support-v7-appcompat) in IntelliJ IDEA
Yeah I had the same issue in eclipse and what I had to do was:
1. change the android appcompat-v7 project.properties property "target=android-21"
2. change your project project.properties property "target=android-21" too.
I was facing the same issue.
There are 2 things you have to do make sure you are using build tool 21.1.1
and please check your build.gradle file and change the gradle dependency to
classpath 'com.android.tools.build:gradle:0.12.1'
from
classpath 'com.android.tools.build:gradle:0.12.+'
Make sure your sdk is updated to version 21 and in your gradle compileSdkVersion is 21
I hope this will work for you.

Trouble on android linux in Jenkins

meet face to face with trouble that :
java.lang.UnsupportedOperationException: Robolectric does not support API level 1, sorry!
properties in my build gradle :
android {
compileSdkVersion 19
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
What it can be?
versionCode in your code example is 1, the exception says API level 1 is not supported...I have the impression that "versionCode" represents the API level. What happens if you increase the versionCode - Value?
am not sure about your environment or tool setup, just make sure that your jenkins build is configued to build using gradle/gradle based build tool (only they will parse build.gradle file and generate a Manifest with proper fields) or if u r using some other build tool update the AndroidManifest with appropriate api level values

Categories

Resources