How to Change Target API Version in Visual Studio Xamarin - android

My VS worked well before I synchronized my project with my friend's using GitHub. After that, somehow I notice Visual Studio targets different location to android.jar file. So, whenever I compile my code, I receive the following error.
Could not find android.jar for API Level 24. This means the Android
SDK platform for API Level 24 is not installed. Either install it in
the Android SDK Manager (Tools > Open Android SDK Manager...), or
change your Xamarin.Android project to target an API version that is
installed.
(C:\Users\Joshua\AppData\Local\Xamarin\MonoForAndroid\AndroidSDK\platforms\android-24\android.jar
missing.)
C:\Users\Joshua\AppData\Local\Xamarin\MonoForAndroid\AndroidSDK\platforms\android-24\android.jar is a directory location in my friend's drive.
How to change the target location of that android.jar file in VS 2015?

Looks like your app is trying to use Android N tools to compile or targeting API level 23
Under your Android project properties -> Application, set the Target Android Version and Compile using Android Version to API Level 23 to fix it

Go to android project then right click -> Properties -> Android Manifest (scroll down) then you will see Minimun android version and Target android version.

in vs project -> your application properties -> change target framework to your api version. that's it

Related

Android NDK - Add more Target API Level in Visual Studio

I am using Visual Studio 2017 and creating an Android App in C++.
I have one Android Packaging Project and a Android Library Project.
If I select the Android Packaging Project and go to:
Configuration Properties => General => Target API Level
The lowest I can select is KitKat 4.4, but I need to go down to 4.0.3.
But if I select an Android Library Project and go to:
Configuration Properties => General => Project Defaults => Target API Level
I can select down to Gingerbread 2.3.
So the question is, how can I select lower API level in a Android Packaging Project?
I have tried to install lowest API from Android SDK Manager and have tried to search on Google but not found anything helpful.
Before you can select a Target or Minimum API level in Xamarin.Android, you must install the Android SDK platform version that corresponds to that API level. The range of available choices for Target Framework, Minimum Android version, and Target Android version is limited to the range of Android SDK versions that you have installed.
For more detail you can refer to here

Could not find android.jar for API Level 26 in Visual Studio 2017

Could not find android.jar for API Level 26. This means the Android
SDK platform for API Level 26 is not installed. Either install it in
the Android SDK Manager (Tools > Open Android SDK Manager...), or
change your Xamarin.Android project to target an API version that is
installed. (C:\Program Files
(x86)\Android\android-sdk\platforms\android-O\android.jar missing.)
As you can see from below that I have the correct api sdk platforms installed but as you will notice on the error message, it is searching for an android-O directory.
Here is my directory which you will notice has everything in it but doesn't contain android-O
I looked in my visual studio project settings and here is what it shows for target framework
Does this mean that Visual Studio 2017 doesn't support Android SDK 26+?
I discovered that you can fix this issue with 2 steps:
Download and install Visual Studio 2017 Preview by going to https://www.visualstudio.com/vs/preview/
Download and install the Xamarin update extension on both versions of Visual Studio 2017 installed by going to https://developer.xamarin.com/recipes/cross-platform/ide/change_updates_channel/extension-gallery/ and follow the steps
If you're building for a Xamarin project, you may need to rename the folder in the SDK folder from "android-{alphabetOSVersion}" to "android-{numericOSVersion}" (IE change the folder "android-o" to "android-27").
This should be done in the C:\Program Files (x86)\Android\android-sdk\platforms folder.
I was getting a similar issue.
Severity Code Description Project File Line Suppression State
Error Could not find android.jar for API level 29. This means the
Android SDK platform for API level 29 is not installed. Either install
it in the Android SDK Manager (Tools > Android > Android SDK
Manager...), or change the Xamarin.Android project to target an API
version that is installed. (C:\Program Files
(x86)\Android\android-sdk\platforms\android-29\android.jar missing.)
The easy fix was to follow the steps mentioned in the error itself from your Visual Studio (I was using Visual Studio 2019).
Click on the Apply Changes button and then reload the project.
MVS 2017 does support Android SDK 26+,
Im using it with v15.3.3.
If you have MVS 2017 installed on your machine,make sure it's up to date
then download and install the Xamarin update extension.
Check out this guide
https://developer.xamarin.com/recipes/cross-platform/ide/change_updates_channel/extension-gallery/
And as a rule of thumb,whenever you get the error "Resolve the “Could not find android.jar for API Level XX” in Xamarin Studio" this are steps to follow to solve such an error
This happens when you target your project to a non-installed Android SDK platform, to fix this you have to install the right components.
Step 1:Target another Android Framework
On the project you have created right-click the project > Options
Go to the Xamarin project configurations
Then go to Build > General > Target framework, and select other Android target framework.
Xamarin project Android target framework
Step 2:Install the Android SDK you need
As the second option you can install the missing components needed to debug on the SDK Android platform; for this you have to go to:
Tools > Open Android SDK Manager
Android SDK Manager Option
Then look at the API Level number on the error or look at the version of the target framework as stated at the previous steps; then select to install the “SDK Platform” and press the “Install 1 package” button.
Choose the right Android SDK Platform
Accept license agreements
license agreements
With this you are ready, press F5 and you can debug now.

How can I change the defined API version of an Android app?

I am absolutly new in Android development and I have the following problem trying to build a sample project that I have downloaded from Internet.
When I try to build it I obtain the following error message:
Error:Cause: failed to find target with hash string 'android-18' in: C:\Users\Andrea\AppData\Local\Android\sdk
Install missing platform(s) and sync project
So I search online and I found this SO link: Android studio - Failed to find target android-18
Ok so I go into Tools > Android > SDK Manager and infact I have installed Android 6 corrisponding to the API level 23 but not Android 4.3 corrisponding to API level 18.
So what it means? It means that I have installed a different version o the Android framework ?(is it the SDK considerable as a framework or what?)
So, on Android Studio can I install different version of the SDK?
I think that the API level have to be defined in some way into the dowloaded application. How can I specify to this application to don't use the API level 18 but instead it use the installed API level 23 ? I think that it is not a problem because I have installed a newest version that have to support all the stuff of the oldest one, is it?
I will explain the problem a bit for you and then provide you with the solution.
You are facing this problem, because your project is targeting API level 18 to compile the project. So you MUST have API 18 SDK installed to compile the project.
This is why the IDE is complaining that,
Install missing platform(s) and sync project
The SDK is not the framework. The Android framework is same all over, but with different API levels new updates are pushed to the SDK, the latest being API 23, Marshmallow.
You should not download an older SDK to compile the project.
Always try to use the latest SDK available to work with. So, just head over to your build.gradle file or AndroidManifest.xml file and change the compileSdkVersion to 23.
You can either change the compileSdkVersion version in build.gradle to 23 or whatever version you have in your local machine
You can obtain the API Level 18 from the SDK Manager.
I go into Tools > Android > SDK Manager and infact I have installed Android 6 corrisponding to the API level 23 but not Android 4.3 corrisponding to API level 18.
So what it means? It means that I have installed a different version of the Android framework ?
Yes, you have a newer version of the SDK.
on Android Studio can I install different version of the SDK?
Yes, that is what the SDK Manager is designed for
I think that the API level have to be defined in some way into the dowloaded application. How can I specify to this application to don't use the API level 18 but instead it use the installed API level 23 ?
It is defined. Check either the AndroidManifest.xml or the build.gradle file in the module for the app (not in the project root). You should see some combination of minSdk, targetSdk, and/or compileSdk with a number after it. Since you are getting an error about missing SDK 18, then that number will be 18.
I think that it is not a problem because I have installed a newest version that have to support all the stuff of the oldest one, is it?
The support libraries are separate from the core SDK. You cannot run SDK 23 specific code on devices that have a version less than 23, therefore, to be safe, it is recommended that you start with downloading SDK 18, then run it, then try updating the compileSdkVersion number.

Unity requires Android SDK to be minimum API level 21

So I've been trying to build a Unity 4.6.1 project in Android, but the problem is that my Android SDK is outdated. However, I believe Google discontinued support of the traditional ADT to switch to Android Studio. Android Studio doesn't have an easy to find SDK folder in version 1.0.1. This is the error I get: "Error building Player: UnityException: Minimum platform required is Android 5.0 (API level 21)" How do I build my Unity project for Android, if the ADT doesn't have support for API level 21?
Click on the SDK manager button (on the top) and in a grayed out text on top of the window (which looks like it did in ADT) it should show you the location of your SDK(e.g. C:\users\admin\appdata...) . And you can change that location in the settings. Just remember to move the files.
1) Download SDK Tools (v25.2.5) from http://dl-ssl.google.com/android/repository/tools_r25.2.5-windows.zip
2) Extract in a folder and navigate inside.
3) run android.bat which would open SDK Manager.exe. Update the packages from this tool (must done step). You can also install any specific API if required in your unity project.
4) In Unity, Go to Edit -> Preferences -> External tools and update path for JDK and the path of the folder where you extracted SDK Tools.
Now Unity would build for android without any issues.

Cannot compile with API 18

I have installed Android Studio 0.2.4 and the SDK for API 18 from http://dl.google.com/android/installer_r18-windows.exe.
Now, when I start a new project, I can choose target SDK : API 18, but I can only compile with API 17. What to I have to do in order to compile with API 18?
In my case I was previously using intelliJ 13 EAP and switched to Android Studio for better Gradle support. Android Studio was pointing to a different Android SDK than I was updating. Android Studio bundles an Android SDK and places it in "\(relevant Program Files)\Android\android-studio\sdk" for all users or "\Users\(username)\AppData\Local\Android\android-studio\sdk" for just me user. So in your case I don't think you needed to download the SDK separately and it would have defaulted to the bundled SDK. To check or switch Android SDKs in Android Studio:
From the initial start screen choose "Configure/Project Defaults/Project Structure".
Click on "Project Settings/SDKs" on the left.
Check "Android SDK home path" points to the Android SDK you are using
and update if necessary using "Apply" or "OK".
Restart Android Studio and try create a new project.
After updating, make sure you have android-18 in your android-stuidio/sdk/platforms folder. I had to copy mine from my Android folder where sdk manager downloads them on my pc. After I did that, it made the dropdown with api-18 available.

Categories

Resources