I am trying to implement the ActionBar in a Mono Android application. Could someone provide me steps to including the ActionBar project in my solution? I have seen the sample projected provided at this url
https://github.com/xamarin/monodroid-samples/tree/master/ActionBarSherlock
Do I have to simply add a reference of the ActionBarSherlock project in that sample? When I attempt to add a reference to that project I get many errors such as "Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Holo.Widget.ActionBar.Menu'." in file abs_styles.xml
Has anyone else successfully added ActionBarSherlock to a Mono Android Project? Could you please provide me steps to get a simple example working?
Ok, this is how I got it working...
Open up the sample project and build just the 'ActionBarSherlock' project on Release mode. Make sure that the minimum target android version is 4.0.3 (required)
Take the dll and reference it in your project. I have found that you can get it to compile fine if your project has a minimum android version of 2.2 - I found that if you used profile version 2.1 it doesn't work, but that just might of been my app. Maybe your minimum version is too low? I also set my 'target' android to be the latest... I don't know if this helps too.
The reason I say to reference the dll instead of the project is that you will get the correct intellisense. Otherwise as you can see in the example project it does not (Makes working on it a pain!).
Make sure you have a reference to the v4 support lib in your project (Mono.Android.Support.v4)
The final step is that need to change your default theme to use a Sherlock theme. (see xml below for example)
Use the ActionbarSherlock.* namespaces when adding Actionbars etc...
Example manifest after adding ActionbarSherlock:
<manifest ...>
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16" />
<application android:label="IDNT" android:theme="#style/Theme.Sherlock.Light.DarkActionBar" android:icon="#drawable/Icon">
</application>
</manifest>
BEWARE: There is a small issue with all this... If your project has a minimum version of under 3.0 (ie 2.2 as per my example) and you compile with linking (ie SDK assemblies only) you will get an error 'Mono.Cecil.ResolutionException: Failed to resolve Android.Database.IDatabaseErrorHandler'. I am currently sending support messages about this to Xamarin and will edit this post once I work out a fix.
EDIT: To fix the issue I have mentioned above make sure that the project options -> Application -> Minimum Android to target option is at LEAST 4.0.3. Your minSdkVersion can still be 7/8 or whatever so it will still run in older android versions. It also means you have to be careful you dont code in stuff that is for higher versions.
Related
I am utilizing the library BaseGameUtils and google-play-services_lib. In the project.properties file I could see the below mentioned line .
target=android-19.
What is the significance of this? Can I change this to "target=android-21". This is just to be in sync with the App's manifest file
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
Yes. You can change this, Depending target only, packages load for you in eclipse.
What is the significance of target=android-19?
target = android-X in project properties file means that Eclipse will not allow use methods or classes from SDK higher than X. It will show compiler errors.
How to change target:
Right click your project.
Then click "Properties".
Then select "Android" from the tree on the left.
You can then select the target version on the right.
NOTE: Before doing this make sure your project.properties and classpath are not in read-only mode otherwise it won't work. Also don't try to edit this file manually.
As a general rule I use the following guidelines
android:minSdkVersion="8"
Set this to the minimum level you want to support. Check which Android version that it actually relates to and make sure that you have compatibility with that version. For example, I think 8 = Android 2.2, which could be a problem if you are using google play services libraries. It is good practice to at least test that you app will work properly on this version using the emulator, because otherwise you will get a lot of errors and bad reviews.
android:targetSdkVersion="21" />
I usually set this to the maximum version that I have actually tested my app on. I thin 21 is Android 4.4, so you should be making sure that your app works correctly on this version of Android. At the least, you should test that it will run in an emulator that is configured with this version of Android.
Hope this helps.
Using Eclipse, I was using android:minSdkVersion="10", got the error message that this was too low, and updated it to 18. After cleaning the project, refreshing and building Android Environment, I still get the same error message!
In Properties -> Android -> Project Build Target, I have selected Android 4.4.2, with an API level of 19.
in AndroidManifest.xml:
<uses-sdk android:minSdkVersion="18" android:targetSdkVersion="19"/>
ERROR:
"Call requires API level 17(current min is10):android.app.AlertDialog.Builder#setOnDismissListener"
How do I make sure my update in AndroidManifest really works?
Thanks in advance.
It has been a while since I've used Eclipse for Android development. If you're new to Android, I'd highly recommend that you check out Android Studio, instead.
Anyway, this sounds like a build issue. I'm imagining that you're using the default ant build script so in that case the most likely culprit is your project properties file.
Look for a file called "project.properties"
and add/modify a line to contain the following:
# Project target
target=android-18
It sounds like it's currently pointing to android-10. You can find more information on this file and others here.
I have download this custom datepicker:
https://github.com/flavienlaurent/datetimepicker
I'm new to Eclipse and Android.
How should I use this?
When I import, I get an error at res folder.
http://i.stack.imgur.com/Dh7df.jpg
Please help me.
Sorry for asking a noob question.
Thanks
I've imported the datepicker to my Eclipse and I can to build it without any error.
Have you downloaded all the necessary Android SDK files using the Android SDK Manager? I see your 'MainActivity' is having compile error too.
Edit:
From the errors, seems like the attributes buttonBarStyle were only defined starting in API Level 11.
There are a few ways to solve this.
1) Set your app and the library project minSdkVersion in AndroidManifest.xml file to "11", this will make your app not be able to use on older Android versions though.
2) Move this particular layout file to res/layout-v11/ folder, and create another version of the same layout file in res/layout folder, but doesn't use the buttonBarStyle.
3) Seems like there's a way to create a attr.xml file in res/layout, and define the attributes manually. I have not tried it personally though you might want to try.. refer to error: Error: No resource found that matches the given name: attr 'buttonBarButtonStyle'
Good luck
Edit2:
Changing android:minSdkVersion="11" and android:targetSdkVersion="17" in your datetimepicker AndroidManifest.xml file should work!
From your screenshot, I saw that it doesn't recognize "HONEYCOMB", seems like your ADT version is not the latest, please try update it to the latest first.
After that right click your datetimepicker-library project in Eclipse, click 'Properties', then go to 'Android' tab, you should see API 15 or above checked, for mine I have API 17 checked as shown here http://i.imgur.com/Z3DkRY1.png
I think your eclipse is not configured properly
Just ran in the same problem. In order to use this library make sure that:
Datetimepicker-library references NineOld Androids
Project properties, Java build path, Libraries contains android-support-v4 and order and export has this jar checked
Project properties, Android, project target build is set to API 19 for example
The last one was causing most of the problems. If you set it to a higher target build, that does not mean that it will not run on lower API levels.
I am trying to modify my widget so that it supports being placed on 4.2 lockscreens. However I still want to support older SDK's.
I added
android:widgetCategory="keyguard|home_screen"
to my appwidget-provider in res/xml, but eclipse complains that there is "no resource identifier found for attribute widetCategory in package android'
If I raise the minSdkVerion to 17 everything works fine, but I want to still support older SDKs.
I have tried using resource qualifiers creating a separte res/xml-v17/mywidget.xml and only adding the tag there, but the error still appears.
Thanks for any help.
Edit:
I figured it out. using a res/xml-v17/ folder is the answer. I just had to change the build target for my project to 17 / 4.2.
I think that setting targetSdk to 17 is enough. XML elements that do not make sense on older SDKs are simply ignored.
No need to put mywidget.xml into res/xml-v17 folder
Put a copy of your mywidget.xml in res/xml-v17/ folder.
This targets Android 4.2 and all new "properties on the appwidget-provider element will be avaible. Also right click your project in eclipse and change build target to: API level 17/ Android 4.2
I saw your Edit. But i think this makes it more clear that this question have an answer.
UPDATE: I can confirm Tomáš Hubálek answer. the xml-v17 is not needed. Changing Build target is enough. Right click your project in eclipse and change build target to: API level 17/ Android 4.2
I have been trying to get ActionBarSherlock ( http://www.actionbarsherlock.com ) working with my eclipse projects. I added ABS into a new project with target version 3.2, and this created fine. When I try to add this as a library to my other project (min version 2.1, target 3.2), I get errors such as
G:\EclipseWorkspace\Android\ActionBarSherlock2\res\values-v11\abs__styles.xml:65: error: Error: No resource found that matches the given name: attr 'android:windowActionModeOverlay'
basically, none of the xml attributes found in 3.0 or higher are recognised. As a consequence, R.java does not generate.
Am I doing anything wrong?
You need to compile with Android 3.2 in addition to targeting at least API 11 both in your app and for the library.
In eclipse, right click on the project and go to "Properties". Under the "Android" tab you'll need to select Android 3.2.
Eclipse is giving me strange Errors too, when implementing external libraries. What always helped for me after some tries:
try multiple times:
*rightclick on your project => Source => Clean Up
*delete and readd the library project
*restart eclipse several
you might also try to delete the generated files to force it to regenerate, but do this on your own risk :)
have fun w/ the open source libraries :)
Try upgrading the version of the sdk and target version 2.1:
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15"/>
This will allow using last sdk features and the app will work on version 2.1.
Maybe, you'll see issues even after fixing this. Then you can clean the project.