How do you get compile time SDK compatibility warnings from Gradle? - android

Was recently doing a project and mid-way we had to lower the minimum supported SDK supported in the Android manifest. Some Android API's we use are not compatible the new lower minimum SDK. We only discovered these as run time crashes. Why wouldn't the Gradle and/or the Android IDE pick up these as warnings ? Normally, I see the warnings as I code it, but for code already written, I am not warned during compilation.
I would like to be able to re-compile my project, and get all the API warnings about the minimum supported SDK. I had done some research on Lint, and it testing with it, has not yielded any results beyond warning me about XML style incompatibilities. So, I can't seem to find it for Gradle, and Android IDE is not running through the existing code already written, and raising warnings. Is this possible ? If it is, can someone provide a solution.

Related

Should the Android compile version be same as the target version in Eclipse?

I need to set the target SDK version of an Android project to API 14. But I do not have the same version available to compile the project. I know that the project can be compiled with a different version but I need to know whether it will cause any issue.
I received the error "Android manifest file is missing" even though it exists. When I cleaned and then built the project it was compiled but the application crashed. What am I doing wrong here?
These were my settings.
There should be no issues introduced when compiling with a higher version, it is even encouraged to do so. You can find more on that topic in this Medium article.
I would also like to bring your attention to the following blog, which contains some important information regarding SDK targeting in the near future.
Unfortunately I do not use Eclipse so I fear cannot provide any verified insight on that matter. However the suggestions I have found so far include:
Cleaning the project
Getting rid of characters such as ö,ë, etc.
Deleting the file and recreating it
The manifest issue was probably due to creating a project with the same name over and over again. However clean -> build the project helped me get rid of it.
Yeah. Android compile version can be higher than the target version.
Android compile version and target version do not have to be the same.
compileSdkVersion
The 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 (as well as all previous versions, obviously). If you try and use API 16 features but set compileSdkVersion to 15, you will get a compilation error. If you set compileSdkVersion to 16 you can still run the app on a API 15 device as long as your app's execution paths do not attempt to invoke any APIs specific to API 16.
targetSdkVersion
The targetSdkVersion has nothing to do with how your app is compiled or what APIs you can utilize. The targetSdkVersion is supposed to indicate that you have tested your app on (presumably up to and including) the version you specify. This is more like a certification or sign off you are giving the Android OS as a hint to how it should handle your app in terms of OS features.
As for the manifest error, you could try (if you are using android studio) clicking File > Invalidate Caches / Restart or force a gradle sync
Thank you for your answers.
I think the manifest issue was due to creating a project with the same name over and over again. However clean -> build the project helped me get rid of it.
Yeah. Android compile version can be higher than the target version. Those two do not have to be the same.

How to fix Android SDK buid tools version too low with terminal?

My english is not very good, thx for your reading :)
"The SDK Build Tools revision (23.0.1) is too low for project",this error always show when I reinstall some modules. I know this error is caused by gradle version.
Usually, I just click Android Studio error tip to fix this problem, just like the blow picture shows.
The error tip
And I know AS modify my modules code to the recommended version, but i don't know the inner process.
I know another way is using the highest sdk build tool verison to config the main project's gradle setting and make sub project to read the main project's instead of own. just like this way
But, I worry about this way may cause some compatibility problem in the future.
I think the best way is what AS do
So, I really want to know what Android Studio do, can I use some AS command and gradle command to fix this error automatically?
Or my worry about compatibility is wrong?

Eclipse: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl

A similar question has been asked for Android Studio. But I am an eclipse user.
I am including the Facebook SDK in my project. After adding the SDK, when I run the program, I get the error
Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl
I tried cleaning and the error persists. Any ideas how to solve this issue? Again, I am using eclipse.
This really should be just a warning that won't stop your compilation. I believe by default it will use the most recent version of the file in the path of your project. Since the facebook API might be a version behind the recent released version included in your project, you can either remove your version in the project and rely on theirs, ignore the warning or update them so they both have the same version of the compatibility library.

How to find actual min API level supported by android project?

The minSdkVersion is manually set by the developer. But you can easily use a function at a higher level and not find out about it until runtime on a device that doesn't support it.
Is there a tool or compiler option that will warn you when you use a function that isn't supported by your minSdkVersion?
I'm using SBT, Scala language, and IntelliJ IDEA. Also using android-sdk-plugin for SBT.
EDIT: I see a difference between my project (written mostly in Scala) and a default Java android app. In the Java code, I get errors when trying to use functions that exceed the minSdkVersion. But in the Scala project the IDE and SBT build system both don't seem to care at all. I suspect I'm missing a setting in my build.sbt file via android-sdk-plugin.
The API level check is performed by a lint tool which is part of the Android SDK. The lint tool works on a Java AST and cannot do anything about code which is written in a different language. To have these checks work for Scala code, someone would need to write an equivalent tool for Scala, but I'm not aware of the existence of any such tool.

Eclipse content assist missing Android API tools proposals

I updated my Eclipse to have the newer version with latest Android ADT. I decided to update it by doing a "simple" install of the whole package provided by google. The package version is adt-bundle-mac-x86_64-20130219. Now, I still have a code assist for java but not for Android API. I spent a long time searching google and Stackoverflow and none of it solved the problem. When I go to menu ADT> Preference> JAVA> Editor> Content Assist> Advanced, I see that the choice "API Tools Proposals" is missing from the choices. I believe this is why I do have code assit for regular JAVA stuff but nothing for Android API. I tried to create a new workspace and import the project in it. I made sure the Android libraries are in the compile path. The are because the compiler reports some error messages related to Android API when compiling telling me I should implement some methods when extending a "BaseAdaptor" so, the compiler knows where to find the libraries.
I tried the trick where you add the "-clean" in the "eclipse.ini" file. I don't have years of experience in Android programming so Code assist for Anbdroid API is very important for me. Any Idea how to bring it back?

Categories

Resources