I'm trying to use downloadable fonts introduced in API 26 and apparently backward compatible with API 14 when the support library is used. How do I use it, though?
Using android:fontFamily causes Android Studio to show a warning and the fonts are not applied on API < 16:
android:fontFamily requires API level 16 (current min is 14)
When app: namespace is used as the documentation says, the build fails with
Error: No resource found that matches the given name: attr 'app:fontFamily'.
I know that only about 1% of devices are running API < 16, but I'd still like to know what I'm doing wrong.
Related
I know this has been asked before, but can not seem to find the answer in previous questions, so here goes.
I have created a project in Unity and exported it to Android Studio. I have set min API Level to 4.4 KitKat (API Level 19).
I have added: in the main manifest file. When building I get this error:
Manifest merger failed : uses-sdk:minSdkVersion 19 cannot be smaller than version 21 declared in library [:UniWebView:] /Users/myname/.gradle/caches/transforms-2/files-2.1/97563e885486a53e4f6658e98b58f094/jetified-UniWebView/AndroidManifest.xml as the library might be using APIs not available in 19
Suggestion: use a compatible library with a minSdk of at most 19,
or increase this project's minSdk version to at least 21,
or use tools:overrideLibrary="com.onevcat.uniwebview" to force usage (may lead to runtime failures)
How do i set the compatible library to minSdk 19? It needs to be 19 and not 21 due to the fact that if I release the update with 21 almost 20% of my users will be unable to play the game :-/
Units not compatible with API level 21+ = 2054 (19%)
Actually... A side question... Should I be afraid of upgrading API in term of loosing users? I have a version using API level 21 which is ready to be released.
If I should be carefull with this, how do I solve initial issue?
hoping for help and thanks in advance :-)
You basically have 4 options:
Increase you project's minSdk to 21 and lose users
Add tools:overrideLibrary="com.onevcat.uniwebview" to your manifests's application tag, which will probably lead to runtime crashes for your API 19 users (please test the whole thing heavily if you choose this option!!!)
Throw away the library and find another one. Or write your own solution
Fork the library (in case it's open sourced) and try to decrease its minSdk to 19
If I were you, I'd go with option 3
Android studio give me message that i can use try with automatic resource management.
But the docs says
If you’re working on an app with minSdkVersion >= 19 and Java >= 7,
then you can use try-with-resources:
My project have minSdkVersion 15 and Java 1.8.
Do i need to ignore this message or to use try-with-resources?
You can use it.
Docs say the following:
In addition to the Java 8 language features and APIs above, Android Studio 3.0 and later extends support for try-with-resources to all Android API levels.
Sidenote, please drop support for anything below api 19.
I research material design project for 4.x API, It seem too many problems in style values, always style.... (in v-21) not found. I think v-21 is only build with api 21. But I want to build for 4.x API, do anyone know problem?
Here is some project in Github i found:
https://github.com/wasabeef/awesome-android-ui
https://github.com/rey5137/material
I use eclipse too. Change ANdroid API 21,22,23 but it still not work
The Log say : no resource found that matches the given name "TextAppearance.Appcompat.Body1"
Here is my picture:
OTHER QUESTION:
The Author say this material project can run on API 2.x -> 4.x , but why it need to build with API 21 -> 23? So can lower device can run it?
Set compileSdkVersion 23 or 21 or above in your build.gradle file.
The Log say : no resource found that matches the given name
"TextAppearance.Appcompat.Body1"
This is because you might not have imported AppCompat Library to your Eclipse Project.
The Author say this material project can run on API 2.x -> 4.x , but
why it need to build with API 21 -> 23? So can lower device can run
it?
Yes, Its always a good practice to build your App with the latest API version as this will include all the updated resources which might be not available in previous versions of Android. However, this will not affect your APK size in anyways.
I have a question about minSDK. I took a project example in here: Contacts Providers.
This project has a minSDK = 5. And in styles.xml some attribute which require higher sdk version like:
android:textAllCaps --> min 14
android:fontFamily --> min 16
But that project so no any error and run fine.
When I copy some style into my styles.xml in my project. It causes an error:
android:textAllCaps requires API level 14 (current min is 11)
...
Can someone help me with the compile error?
You can use those styles in the respective minSDK version by using resource qualifiers. In your resource directory: there is base styles, add folders to res/styles-v14 (for use in ice-cream sandwich and greater, where minSDK is 14) and styles-v16 (so on so forth if you need the styles to be applied when available)
Now when the style needs a higher SDK version, place it in respective style resource directory. textAllCaps goes into styles-v14, android:fontFamily goes into styles-v16.
More can be found here on resource qualifiers ;)
http://developer.android.com/guide/topics/resources/providing-resources.html
Hope this helps buddy, happy coding!
EDIT: previously misunderstood the question/scenario. Sorry!
I think the problem is your Target API level. Make sure that the target api level is at least the level in which the APIs were introduced. In this case, 14.
If you build from command line you would just do
android update project -p -t
(I think what the command does is just update project.properties and sets target=android-14)
The android doc here states that I can target Api Level 8+ devices and still specify that I want to use the Holo theme for devices that are API Level 11+. I should be able to do this using two themes.xml files :
One would go in /Resources/values for devices of API Level 8, 9 and 10
One would go in /Resources/values-v11 for devices with API Levels 11+
In a Xamarin.Android project, using Xamarin Studio it doesn't look like it's working, I get a compile time error :
Error retrieving parent for item: No resource found that matches the given name '#android:style/Theme.Holo'.
Am I doing something wrong here ? Is there a workaround ?
Theme.Holo is only available on API 11 and above.
If your project target is set to automatic, the system will build against the minimum level required (I think).
Try explicitly setting it to a higher API version.