How to set the compatible library in Android Studio - android

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

Related

How can I add foregroundServiceType to a library manifest while maintaining backwards compatibility?

My library project has a location service, and per Android Q requirements it sets the android:foregroundServiceType="location" attribute in the manifest. When an app module uses my library and compiles against API level 28, it fails with the following error:
AndroidManifest.xml:57: AAPT: error: attribute android:foregroundServiceType not found.
How can my library maintain compatibility with older versions, while making sure the functionality works on Android Q?
I had same error and after migrating to Androidx and updating compileSdkVersion from 28 to 29 my issue was resolved. So please do these changes and you can get your solution
My goal is to avoid breaking anyone's build when the library version is updated, and at the same time avoid forcing the developer to compile against API 29. It seems I have two choices:
Provide a separate library so that developers compiling against API 28 and lower don't get impacted;
warn developers targeting the new version to replace the service definition in the manifest using tools:node="replace".
The problem with the first approach is that I will need to maintain two libraries for some time. The problem with the second is that developers must remember to revert the change once they update the SDK version.
In my case, I will go with the second approach. By passing an explicit foreground service type to the startForeground method when targeting Android Q, I can cause a crash if the type is not set in the manifest. The developer can therefore catch this when targeting Android Q and revert the manifest change to fix it.

Realm using try-with-resources

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.

Rendering Problems Exception raised during rendering in API Level 24

I have recently updated my API Level now its 24 and I noticed my layout previews weren't working, if I change API level 24 to 23 it works but on 24 its not working. anyone please help me.
Error:
Rendering Problems Exception raised during rendering: com/android/util/PropertiesMap**
I believe you've changed the API lvl this way.
This only changes the API lvl that Android Studio uses to render a preview, not the actual API lvl used in building your project. That means what you did here won't affect the actual build. So, don't worry about it, and there is nothing you can really do about it.
To actually change the API lvl, change the build.gradle file.

import project for low api, stylev21 not found

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.

Suppress AndroidManifest.xml minSdkVersion related warning

As recomended here http://developer.android.com/guide/practices/screens_support.html for compatibility reasons my AndroidManifest.xml contains this:
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4"/>
This generates warning in eclipse:
Attribute minSdkVersion (3) is lower
than the project target API level (4)
Are there any means to suppress this warning or get rid of it any other way? It is really annoying.
In short, there is no built-in way to do this that I know of.
Here's a discussion from last August.
And here is a Xavier Durochet's response.
It looks like you can manually remove it according to Mark Murphy's response in the first thread:
Or, you can modify SetupTask.java, eliminate this test (lines 297-308 in
the code indexed by Google Code Search), and build it into a custom
version of the Android Ant extension
There is a feature request that may deal with this, but who knows when it will be implemented.
The answer from 2011 is no longer accurate. It was fixed in ADT 17 according to this bug.
This warning is an usual one. I am using minSdkVersion to support Android 1.5 and I am building for Android 1.6 to support small screens. You can build your application with the latest Android 2.3 library, but still support a lower version.

Categories

Resources