When i try to create a new Master/Detail flow activity in Android Studio i am told "The activity Master/Detail Flow has a minimum SDK level of 11.". I understand why this is, but I don't understand why i am being prevented from creating this activity as the min SDK as defined by my AndroidManifest.xml is 11.
I created with a lower minimum but have since changed to 11. When i create a new project with a miniumum of 11, and then change the manifest to use 7 as min SDK I can create a new Master/Detail flow activity. This makes me think there is a project property i need to change, but I cannot find it!
I have tried so far:
downloading all SDKs from 11 upwards
Rebuilding project
Invalidating cache and restarting
setting Min, Target and Max SDK to 18
creating a new activity with "Power save mode" on
This may be late answer but i found same problem.
Here is solution. On your build.gradle there will be following line
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 16
}
}
just change minSdkVersion to 11 and click "Sync Project with Gradel File" icon, then try to create Activity again.
Problem occurred with minimum required sdk, I guess, you have API 18: Android 2.2 (Froyo). Just change it to API 11.
Related
I am trying to understand how Android Studio determines if a code is available in a certain API. When using MediaStore.setRequireOriginal, Android Studio warns me that "this call requires API level 29". Does Android Studio check that this code is available in previous Android version sources?
photoContentUri = MediaStore.setRequireOriginal(photoContentUri)
I am trying to understand how it knows this.
The linter just knows all the APIs in all the versions. You don't need to download all the previous Android version sources (I was wondering how Android Studio's Linter knew about older versions when I only had API level 29 and 30 sources downloaded on my machine).
As you can see, lint now has a database of the full Android API such that it knows precisely which version each API call was introduced in.
Lint API Check page
The Short Answer:
It's set by the developer, And Android Studio just compares your minSdkVersion set in build.gradle file with the required api level.
The Longer Answer:
When you get this warning on a method, just CTRL+click on it to go to the source class, and there you will find it annotated #RequiresApi or/and #TargetApi, for example :
class MediaStore{
#RequiresApi(api = 29)
#TargetApi(29)
void setRequiredOriginal(...){}
}
Your build.gradle file:
defaultConfig {
minSdkVersion 23
...
}
Android Studio compares minSdkVersion to #RequiresApi or/and #TargetApi at the time you call the method MediaStore.setRequiredOriginal(...); and warn you if minSdkVersion is less that the recommended api.
Please note that there are differences between #RequiresApi and #TargetApi, sometimes you find them used along with each other but sometimes just one of them.
For more about difference between the two see: https://stackoverflow.com/a/50578783/10005752
There is something in build.gradle of application module like:
defaultConfig {
minSdkVersion 23
targetSdkVersion 30
}
So you can change the "minSdkVersion" to 29, and the warning message disappear ...
And if not:
With android OS version >= 29: your code works normally
With android OS version <29: might be an exception occurs
I cant drag and drop items either on activity_main.xml file or content_main.xml file. From my research, I learned that I have to downgrade from android API 24 to android API 23, but when I click on API 24 image to downgrade I can't find API 23.
Check the image and download API 23, then restart Android Studio and you will see API 23 too there.
You will see this window, then start the download:
I think you are confusing rendering API level to application API level. You see, the icon above will render according to the API level you chose. That makes seance because some APIs have different overall design.
If you want to downgrade the application API you can change in the manifest (if you are using eclipse) OR change in the gradle settings(if you are using Android Studio) like so:
In the build.gradle(Module app):
defaultConfig {
applicationId "com.shlomi.alarm"
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
Insert your API level in minSdkVersion.
Simply go to your res directory through your windows explorer there you may find folders like 1)drawable 2)drawable-v24 3)layouts and so on.....
cut all the content from drawable-v24 and paste it into drawable folder.
This solution worked for me.
cheers.
Hello there are some answer on this topic, but none which worked for me so far.
My build.gradle looks like this
compileSdkVersion 23
buildToolsVersion "23.0.3"
minSdkVersion 21
targetSdkVersion 23
Somewhere in my Fragments I called the method getContext() and that crashed the app on a Lollipop 5.0 device. It works fine on Marshmallow 6.0.
The Fragment is imported from the non support library package.
import android.app.Fragment;
and since I have compileSDK on 23 I can call the method getContext() withing the Fragment to get the Context.
This will lead to a crash on Lollipop 5.0 and 5.1 since that method was added with API 23 and not API 21,22.
My Question is, how can I find such high level calls in Android Studio when the min SDK is below that?
how can I find such high level calls in Android Studio when the min
SDK is below that?
AFAIK Android studio normally warn the developer whenever they are using any methods which is not completely backward compatible till minSDKVersion defined by the application. So, At that point of time, you can check out current version of device and call relevant other method accordingly.
However, for some reason its not showing any lint warning while calling getContext() method. So, It seems we have to deal with it now.
Go to
-> Analyze -> Inspect Code -> run code inspection
Then in the result view there is
"Project Name"
- Android > Lint > Correctness
- calling new methods in older versions
Under (calling new methods in older versions) all unavailable calls should be listed
Now that we're in 2022, I found a more appropriate solution.
Run the gradlew lint command in Terminal and waiting for it to finish will generate a report file.
Wrote HTML report to file:///C:/Users/Administrator/path/to/project/module/build/reports/lint-results-$flavorName$buildType.html
open this file in browser, find InlinedApi and NewApi and you will find all of it.
I am developing app in API level 23 (Marshmallow) but some methods and libraries are deprecated in API 23 i need to downgrade project to API 21 or API 22. But when i change my API level and build my project it gives error
I have tried all methods all things that are mentioned on this forum but none could helped me..
is give error for some value-23.xml file.. i have changed the name of that file from value-23.xml to value-22.xml but android studio said "FILE usder the build folder are generated and should not be edited"
You have changed your compileSdkVersion below 23, but you are still trying to use a version-23 edition of appcompat-v7. Change your appcompat-v7 statement in the dependencies of your build.gradle file, choosing a version that matches your compileSdkVersion. Or, move your compileSdkVersion back to 23 and address your deprecation issues in some other fashion.
I have an app that works fine on API 19. However, I want it to work well in other API's as well. I'm targeting API 10 and above.
My gradle build looks like this:
android {
compileSdkVersion 18
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 10
targetSdkVersion 18
}
}
But when I run the app on API 10 the AVD manager says compatible: no
How should I change my build so that it is compatible for API 10 and above?
Your gradle config looks correct. Be sure to check your virtual device settings and compare to what you have defined in your manifest file. Also be sure to check any other modules you may have added to the project and their respective gradle and manifest files.