Running My First App On Android Studio - android

I created a project with API level 8 (Android 2.2) and downloaded the 2.2 SDK in the SDK manager. When I run my android project this error was shown:
Error:(47, 21) No resource found that matches the given name: attr 'android:borderlessButtonStyle'.
I searched and found out that the borderless style is available on API level 11 and above so why did the Google Developers Hello World tutorial say to choose Android 2.2 so that all devices can run the app?
I changed the API level to 15 which solved the problem.
My question is why does the Android tutorial say to select 2.2 and then run application?
What should I do to run my first app on Android 2.2?

Download sdk for api level 15 on your sdk manager and then run the app in your emulator. Or even you could have set the target sdk version as 8 in your application. So please change it and then try running your app
Happy coding..

You misunderstood something. You should differentiate between android minimum SDK and the compile and target SDK you can see this link to know the difference.
You should target the latest version in the compile and target SDKs and set your min SDK as you like.
You are now getting this error because your are compiling with an old SDK and you are referring to some of the new APIs that are introduced after this API, they won't be used if you are using an older version, but they will use it in the later versions of the OS because it makes the process easier or getting the look and feel of the new versions of android.
This is happening in one of your libraries and I think it's the appcompat v7 library.

Related

New Android App ( Xamarin) targeting Android 9.0 api not compiling because missing Android X assemblies (but they need Android 11.0 version)

I am trying to build an Android app to make a simple prototype. Using Microsoft Visual Studio 2022 (v17.2.4), I create an Android App (Xamarin), blank app. And I target Android 9.0 version.
But, I have compilation errors :
Could not find 2 Android X assemblies, make sure to install the following NuGet packages:
Xamarin.AndroidX.Lifecycle.LiveData
Xamarin.AndroidX.Browser
Problem is that I can't install these NuGet packages because they need Android 12.0 version or greater :
Package Xamarin.AndroidX.Lifecycle.LiveData 2.5.1 is not compatible with monoandroid90 (MonoAndroid,Version=v9.0). Package Xamarin.AndroidX.Lifecycle.LiveData 2.5.1 supports:
monoandroid12.0 (MonoAndroid,Version=v12.0)
net6.0-android31.0 (.NETCoreApp,Version=v6.0)
So I don't know how to solve this. I don't want to target Android 12 version, I need this app to launch on an Android 9.0 device.
What are these libraries the app need to compile? Can I do without them? I don't find any references to them.
Note : I have a warning too on the same way, but not sure if it has to deal with my compilation issue. I Put it anyway, if it can help :
Warning Google Play requires that new applications and updates must use a TargetFrameworkVersion of v11.0 (API level 30) or above. You are currently targeting v9.0 (API level 28).
Please, any idea to solve my issue?
I just want to compile and launch an Android (Xamarin) blank app targeting Android 9.0.
Thank you and have a good day,
I'm finding this a problem too. Just deployed an app (Dec 2022) that targeted 28 / 12 and has min version 10 as appears enforced by Google?
Prob is I've got a lot of people wanting to use the app that can't see it because they have ancient phones (9 or earlier - is that 5 years or more). Seems a bit tough? Is there a way to overcome this.
I assume that the today's Xamarin Android project templates are designed to compile with Android 12. I don't think there is a way to build them with Android 9.
I guess we just have to find another older template?
For my part I had finally took an older project I had instead of creating a new project.

Android studio 3 not showing Android 2.3 sdk API 10 for a new project altought sdk is installed

I need to develop a test application for an old Samsung smartphone that has Android 2.3.6
I'm using Android Studio 3.1 and I've installed needed several old SDK from 2.1 to 2.3.3 including google api (that are showed as obsolete in sdk manager)
The problem is that when I create a new project, in the list where I can choose the SDK the lowest API available is 14; it seems that android studio is not showing me obsolete api and I cannot find where to set that I want to see all installed SDK.
Newer versions of Android Studio have minimum API level set to 14. I would suggest you look for android studio 2.3.3 which allows lower level APIs. Download link below:
https://developer.android.com/studio/archive
I face the same error while developing for the API 11. That was minimum of 14. But yes android studio never shows minimum then API 14. This is due to some Appcompat library.
Because when I dug out deeper then I found out that This Library was using minimum of 14 SDK. and due to manifest merging problem I think android studio is not showing minimum then that. At that time I was using 25.+ version of Appcompat library and I was using android studio 3.0.
You can find out more by selecting API 14 and then go into build.gradle file. now here you can change minSdkVersion to 11 or at any api level you want.
Then you can notice that while building you will get manifestMerger error with following proposed solutions
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 11 cannot be smaller than version 14 declared in library [com.android.support:appcompat-v7:26.1.0] \9fe0f18d3439e3d6185e96eddd3ec321\AndroidManifest.xml as the library might be using APIs not available in 11
Suggestion: use a compatible library with a minSdk of at most 11,
or increase this project's minSdk version to at least 14,
or use tools:overrideLibrary="android.support.v7.appcompat" to force usage (may lead to runtime failures)
So here is the problem and here you got the reason. May be some one can help you in bypassing it. I just thought to share my findings.
I am currently using Android Studio 3.0.1 and I have also experienced not being able to select api versions below 14 in the new project window, however I am unsure how to fix this issue directly. I have been successful as changing minSdkVersion (or using a project which had it already set) and haven't had a build issue. The same build issue appears to have solutions here, if you are experiencing this: Manifest merger failed : uses-sdk:minSdkVersion 14
I had a issue running the application on the emulator, as it was constantly waiting for the emulation to finish starting and this was fixed by updating the gradle as suggested by some notifications.
Otherwise I can only suggest trying the older ide version, especially if you are natively debugging using 32-bit windows, as it appears to not be supported in Android Studio 3. However after reading the release log it doesn't appear to mention excluding api below 14.
Native debugging with Android Studio no longer supports 32-bit Windows. We've chosen to focus on other platforms because very few developers are using this platform. If you are using 32-bit Windows and you plan to debug native code, you should keep using Android Studio 2.3.
[Source: https://developer.android.com/studio/releases/index.html]
Link to older ide version from the same source: https://developer.android.com/studio/archive.html#android-studio-2-3-3

Xamarin Targetframeworkversion

I am trying to make a basic Xamarin.forms (pcl) application (in Visual studio 2017) and i want to Target Lolipop (5.0.0, api level 21).
So i made a basic Xamarin solution and i adjusted the Android properties all to Android 5.0 lollipop
Compile using Android version "Android 5.0 (Lollipop)"
Minimum Android to target "Android 5.0 (API Level 21 - Lollipop)"
Target Android Version "Android 5.0 (API Level 21 - Lollipop)"
Unfortunately in my warning list i get the following
Severity Code Description Project File Line Suppression State
Warning The $(TargetFrameworkVersion) for Xamarin.Forms.Platform.dll (v7.0) is greater than the $(TargetFrameworkVersion) for your project (v5.0). You need to increase the $(TargetFrameworkVersion) for your project. Prolang.Android C:\Projects\Prolang\Prolang\Prolang.Android\Prolang.Android.csproj
If i google for this error most people say to indeed update your android project to use the latest Targetframework version. But in my case i really want to only be able to call Api calls that are available to level 21 aka Android 5.0 Lollipop. As in i want the compile time safety net that i only use Api Calls from Api level 21.
To me it seems like i have to downgrade my xamarin.Forms dll to a version that is made specifically for android lollipop since the one i use right now targets a higher version.
So should i downgrade my xamarin.forms dll to achieve this and get rid of the error? And if i downgrade to what version do i need to downgrade so i target Android 5.0 Lollipop? This information is all pretty unclear to me.
Xamarin.Forms is designed using the Android's support libraries so it will run on a wide range of APIs without any additional actions from the developer.
If you are using native APIs via Xamarin.Android (assumably via Forms' Dependency Service) then yes you would have to be aware of the API level of the method calls.
That said, since Xamarin.Forms uses the com.android.support.* libraries and you would have to have to a Forms versions that uses com.android.support:design:21.x.x and the associated Android build tools for API 21.
Now you can review the package dependancies and you will see that your choices are Forms' is 1.4
`1.4.0.6336-pre1` to `1.4.4.6449`
Note: v1.5.x moved to version 22 of the Android support libraries
IMHO using Forms's 1.4 would a bad mistake due to its age and the mountain of improvements and bugs fixes since 2015, you are so much better off:
Using the latest Forms version
Set the Framework version to latest (7.1)
Set the Target Android version to Android 5.0 (API Level 21)
Set the Minimum Android version to whatever you need...
Forgo the compile time API checks
Check runtime API issues via API-21 devices and emulators

Android Error: This template requires a build target API version of at least 14, and the current version is 7

I installed the SDK and I like work with API 7 but when I want to create a new Activity Main I have this problem and I can't create a new Activity, thanks.
This template requires a build target API version of at least 14, and the current version is 7
In the log, I can read this:
Not targeting the latest versions of Android; compatibility modes apply. Consider testing
and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details.
I recently faced the same problem when creating the activity or while setting the new android application project and able to solve this problem in this manner.
I checked the system image folder which is in sdk/system-images,build tools folder-sdk/build-tools and found that these folder does not have the API's that i am using at Minimum required sdk,target sdk,compile with. In each of these you need to provide the API no. or Android version.
So check that the API's that you are using for(Minimum required sdk,target sdk,compile with) are installed and also check the system-images and build-tools folder should have these API's
if you have done this your problem must be solved.
You probably set Build SDK to API 7. Normally, you should set Build SDK to the highest possible API level and set the other SDK, it's called Run SDK or don't rememeber how to the minimum API version you want your application to run on.
I ran into this same issue even though I had set in my AndroidManifest.xml minSdkVerion to 13 and targetSdkVersion to 19. What fixed it for me was in Eclipse going to Project > Properties > Android then checking the highest API level in Project Build Target box (API 19 for me).

android - admob implmetation confusion

I have implemented admob code as given in google site (http://code.google.com/mobile/ads/docs/android/fundamentals.html) as described in google site we should target android 3.2 (api-13) in eclipse IDE to work properly. now my problem is my application targeting the android version 1.6 and above, since i made build target as andoird 3.2 it expects app should run on either 3.2 emulator or any of 3.2 device. i tried even installing on my 2.2 device but it didnt work.
Please help.
Thanks
The only thing you need to do is follow their instruction:
Requirements
The Google AdMob Ads SDK for Android requires Android 1.5 or later. Make sure you have the latest copy of the Android SDK and that you're compiling against at least Android v3.2 (set target in default.properties to android-13).
Using Android SDK Tool download android-13 SDK and modify your default.properties, do not change anything else like android:minSdkVersion in AndroidManifest.xml. Yes, you will get a little yellow warning message says version not match in Eclipse, just ignore it and build your application, you should be fine.

Categories

Resources