Xamarin.Android Material Design Theming with Appcompat - android

I am facing some bug with custom material theme with AppCompat
I already set the the target to android 5.0
I already download the android support repository through the android sdk manager
and I add the AppCompat packege already
I will provide you some screenschot so you might help me figure out what's going wrong with it. Thank you in advance
Error Log
here is my style xml for the color
<?xml version="1.0" encoding="UTF-8" ?>
</style>
<style name="Theme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#9E9E9E</item>
<item name="colorPrimaryDark">#616161</item>
<item name="colorAccent">#FF5252</item>
<item name="colorControlHighLight">#F5F5F5</item>
</style>

You are most likely running into an issue with the Support library Caches. We wrote a troubleshooting document on this topic that should help you resolve this:
https://developer.xamarin.com/guides/android/troubleshooting/resolving-library-installation-errors/
(Gist - https://gist.github.com/JonDouglas/f6291eacd4da5f6aa4cd)

Goto C:\Users\Geeksan\AppData\Local\Xamarin folder & Delete all folders corresponding to Android packages. Also delete zip files from the zips folder.
Then from your solution, add the required packages from nuget again & build the solution. The build process will take some time to download the zip files & unpack them. So wait for build to complete. Do not cancel the build process.

Related

Intellij Idea 2018.2.5 CE Android development issue, android sdk v28 is unstable/rendering issue

First of all, I researched alot and this question is not a duplicate of Rendering Issue in Android Studio its answer doesn't fix my problem (i already have the same configuration that is in its answer). Secondly I tried cleaning project, rebuilding project, running gradle sync too. Issue still persist.
After starting a new project, i used to load a template basic activity but the layout xml files are actually not rendering.
Error:
It says Failed to instantiate one or more classes inside that i see
The following classes could not be instantiated:
- android.support.design.widget.CoordinatorLayout (Open Class, Show Exception, Clear Cache)
- android.support.design.widget.AppBarLayout (Open Class, Show Exception, Clear Cache)
Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.
If this is an unexpected error you can also try to build the project, then manually refresh the layout.
Exception Details
java.lang.ClassNotFoundException: android.view.View$OnUnhandledKeyEventListener
Copy stack to clipboard
my styles.xml file is:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="coordinatorLayoutStyle">#style/Widget.Support.CoordinatorLayout</item>
<item name="floatingActionButtonStyle">#style/Widget.Design.FloatingActionButton</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
</resources>
My gradle is using this dependency: and compilation and target sdk version is 28
implementation 'com.android.support:appcompat-v7:28.0.0'
Right now it looks like:
EDIT 1:
So now at this point, i tried many things and found myself that the rendering issue is only in SdkVersion 28. When I use
android {
compileSdkVersion 27
defaultConfig {
targetSdkVersion 27
...
}
...
}
dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
...
}
It doesn't appear to be, so I want to investigate what's wrong with sdk version 28? I mean like whenever you make a project you get default config for version 28 and when i try this above snippet i still get warning that v27 is older, why? if v28 not stable enough then why is it default? I don't understand I want some useful answer for why this is!
Thanks everyone who used time to read my question.
Before proceeding with the answer, make sure you have the latest Android Studio. It handles API v28 in a much better way. This update on its own might solve your problem, but if it doesn't, read below:
AndroidX
Try migrating to AndroidX. In the latest Android Studio 3.2 there is a feature called 'Refactor to AndroidX' under the 'Refactor' menu, which makes the whole process easier.
AndroidX is basically google renaming all of the packages to make the naming clearer. More information on that can be found here and here.
I know this is not a direct answer to your question, but I am confident it will solve it. There are many bugs and other irritating errors that Android Studio produces, that I don't see any other IDE makes - I am referring to those that are unclear about what went wrong.
I believe by making AndroidX google addresses this issue in some way. It does definitely make some things clearer and easier, and I recommend migrating to it, in order to solve your problem, and for good practice.

Use Theme.AppCompat in a xamarin.android app

I'm trying to make an Android app through Xamarin. I work on Windows 10 with VS2015.
I have to implement a side bar menu. After some research I found a solution to do it : use a DrawerLayout and others tools. That's why I use Theme.AppCompat in my application.
But when I'm trying to make a style which herits from Theme.Appcompat.light.NoActionBar, I got compile issue. The message is :
Error retrieving parent for item: No resource found that matches the given name '#android:style/Theme.AppCompat.Light.NoActionBar'.
I've added Xamarin.Android.Support.v4 and Xamarin.Android.Support.v7.AppCompat references to my project as bellow :
Project References
Edit: I also tried to add them by xamarin Component and nuget package manager.
But nothing compile.
Here is the code which produce this error:
<resources>
<style name="DailyCoin.HomeTheme" parent="#android:style/Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#219653</item>
<item name="drawerArrowStyle">#style/MyDrawerArrowStyle</item>
</style>
<style name="MyDrawerArrowStyle" parent="#android:style/Widget.AppCompat.DrawerArrowToggle">
<item name="color">#F5F5F5</item>
<item name="spinBars">true</item>
</style>
</resources>
minSdkVersion is 17 and compile using version is 23
Ok, I found the solution.
My problem was that xamarin was corrupted and the component adding module had some troubles when i added components. So i removed all references/components i've added to my projet, reinstalled xamarin.
Just for people impatient like me:
Then i had a new issue : "Unzipping failed. Please download https://dl-ssl.google.com/android/repository/android_m2repository_r28.zip" because when generated the solution, it took a lot of time and i stoped this.
The solution was to delete all zips in "%localappdata%/xamarin/zips" and wait for the generation.
Thank for your help !
Julien
Did you try this?
parent="Theme.AppCompat.Light.NoActionBar"
Check this out (its working for me): Navigation Drawer using material design
Leave out #android:style/ so just:
parent="Theme.AppCompat.Light.NoActionBar"

error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.NoActionBar'

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:textColorPrimary">#color/colorTextPrimary</item>
<item name="android:textColorSecondary">#color/colorTextSecondary</item>
</style>
This is the styles.xml file. The following code results in this error - i have put all the necessary libraries and jar files and i have also tried changing the syntax little bit and many stuff but I am not able to solve the problem. It is very important. Please help me. Thank you.
I have tried the following :
You need to reference this AppCompat library in your Android project.
Import the library into Eclipse.
Right click on your Android project.
Select properties.
Click 'add...' at the bottom to add a library.
Select the support library
Clean and rebuild your project.
It still doesn't work.
Edit now :
I have installed android sdk 5.0 (API 21) but it still doesn't work. The line with the error is
There were 3 other errors before installing android sdk 5.0 (API 21) in this file (styles.xml) but now they are gone. Please help me to remove the remaining error.
If you are using material in the manifest, you will get this error if your min version isn't API 21

Android material design in Eclipse

Is there any way to create an app with Material design in Eclipse? Hamburger to arrow animation, full screen height navigation drawer...
Yes you can create an app with material design using eclipse.
Please follow each steps below carefully without any error.
Steps:
Create a new Android Project with Target SDK version 21. If your project already exists then just change the Target SDK version.
Add Appcompat v7 lib to your workspace and add this lib to build path of your project. You can find this lib at sdk\extras\android\support\v7.
Set Project build target to version 21.
There should be only 2 values folder in res folder.
values
values-v21
values/styles.xml should be as below.
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
....
// Your style here
</style>
values-v21/style.xml should be as below.
<style name="AppBaseTheme" parent="#android:style/Theme.Material.Light.DarkActionBar">
....
// Your style here
</style>
You can find different style attributes here https://developer.android.com/training/material/theme.html
After following above steps, your app will be ready with material design theme.
Now your second question regarding navigation drawer you can use following link for simple and step by step implementation.
Part 1 http://www.android4devs.com/2014/12/how-to-make-material-design-navigation-drawer.html4
Part 2 http://www.android4devs.com/2015/01/recycler-view-handling-onitemtouch-for.html
This implementation uses recycler view. For that you need to add recycler view lib (location - sdk\extras\android\support\v7) to your project and add it to build path.
You can develop apps with Material Design in Eclipse by using the libraries provided by google. You need to follow the below steps to do that.
Properties> Android> Add...>appcompat_v7
Add...> Android Design Support Library(You can import it from android-sdk\extras\android\support\)
Add...> RecycleViewLibrary & CardViewLibrary libraries for RecycleView and cardView, better material look and feel. (You can import it from android-sdk\extras\android\support\v7\)
Add/Edit values\styles.xml
<style name="MyMaterialTheme.Base" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
Change theme in AndroidManifest.xml file. android:theme="#style/MyMaterialTheme"
extend your Activity by AppCompatActivity.
Hope you can develop Material Designed apps in Eclipse throgh these steps.
Important: Support for the Android Developer Tools (ADT) in Eclipse is ending. You should migrate your app development projects to Android Studio as soon as possible.

Error while building android chrome cast video example

Hi I trying chrome cast device with Google's https://github.com/googlecast/CastVideos-android this sample. I have imported appcompat and mediarouter from V7 lib. I also imported google play service lib and CastCompanionLibrary-android. All libs are proper and without any error. But when I tried to build video sample it gives me some resources error in styles-castvideo.xml. It gives error for following resources
<style name="ShowcaseView">
<item name="sv_titleTextAppearance">#style/TextAppearance.ShowcaseView.Title</item>
<item name="sv_detailTextAppearance">#style/TextAppearance.ShowcaseView.Detail</item>
<item name="sv_backgroundColor">#CC000000</item>
<item name="sv_buttonText">#string/ok</item>
<item name="sv_showcaseColor">#color/yellow</item>
</style>
Am I missing something. Need some help. Thank you.
ShowcaseView should be added as library.
https://github.com/naddaf/ShowcaseView
Dependencies
CastCompanionLibrary-android: can be downloaded here at https://github.com/googlecast/CastCompanionLibrary-android
ShowcaseView (see change list 1.1 -> 1.2 for details)

Categories

Resources