Android Studio ViewPager class could not be found (Rendering Problems) - android

Im following the steps in the android docs here https://developer.android.com/training/implementing-navigation/lateral.html#horizontal-paging
I use Android studio 1.2.1.1
As soon as i add their code to my XML
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
i get
-Rendering problems the following classes could not be found:
android.support.v4.view.ViewPager (Fix Build Path, Create Class)
Tip: Try to build the project.
Ive tried:
Switching between API 21 and 22
Trying Holo Themes
Adding support libraries 4 and 13
heres gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "ian.marxbrothers"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:support-v4:22.0.0'
compile 'com.android.support:support-v13:22.0.0'
}

There actually is no answer. The Viewpager will not show anything but you can still adjust its size within a layout and then add its contents in xml

Related

CoordinatorLayout not working in Android Studio 2.1.2?

My Android Studio is unable to find the CoordinatorLayout class.
Screenshot :
It says:
The following classes could not be found: -android.support.design.widget.CoordinatorLayout.
This is my xml code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.musical_box.musicbox.MainActivity">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/player_Control_container">
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
I know this question has been asked a lot of times but i have tried most of the solutions, and none worked for me. One thing I noticed that Android Studio is not suggesting CoordinatorLayout while writing code. I am guessing that there are some missing libraries. Here is the code for my gradle build:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.musical_box.musicbox"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:support-v4:24.0.0'
}
I have build tools 24.0.0 installed on my system. Can anyone help as I am unable to figure out the problem and new to Android dev.
Any help is much appreciated.
Add
compile 'com.android.support:design:24.1.1'
to your gradle file. It should work. Its part of design library. So you need to add this one to access CoordinatorLayout.

android.support.v7.internal.app.WindowsDecorActionBar Rendering Problems

Hello developers friends!
I am studying development for Android in recent months.
But just this last week came the question . How can I solve the problem of the image below ?
ActionBar is deprecated in the latest android api... If you need to use it make sure your theme read as follow:
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
you can find this in:
res > values > styles.xml
I was also getting these errors.
Solved by setting similar versions to the fields in gradle file as below
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.intplus.hijackid"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.0'
}
Observe the versions compileSdkVersion, buildToolsVersion, targetSdkVersion also the support v7 version.
I was having appcompat-v7:21.0.3. Changes as shown above fixed the issues!

Android Studio - Rendering Problems for XML files using support libraries

I get rendering problems for XML files that uses support libraries, while I don't have the same for normal XML files. These are the errors I get for separate XML files
Error
*The following classes cannot be found:
android.support.v7.widget.RecyclerView
android.support.v4.widget.DrawerLayout
android.support.v7.widget.Toolbar*
a) Android Studio version: 1.2.1.1
b) Build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.piserve.geejo.mskv4"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'org.lucasr.dspec:dspec:0.1.1'
compile 'com.mcxiaoke.volley:library:1.0.+'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:recyclerview-v7:22.1.1'
}
c) Layout XML file (one of them)
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/color_primary"
app:popupTheme="#style/ThemeOverlay.AppCompat.Dark"
app:theme="#style/MyCustomToolbarTheme"
>
d) SDK Manager Screenshot
Here's what I tried:
a) Changing the theme in the editor window to Material and Holo themes
b) Switching between Android v21 and v22
c) Tried different emulators from Nexus 4-10
I had the exact same problem. None of the solutions worked for me so I had to revert back to Android Studio 1.1.0: http://tools.android.com/download/studio/canary/1-1-0

SwipeRefreshLayout/ListFragment Loading style issues

I learned from Android SDK sample SwipeRefreshListFragment
and tried SwipeRefreshLayout/ListFragment in new test app by using support-v4
I found a difference:
in offical sample, SwipeRefreshListFragment Loading style is a rotating circle, but in my test app, loading style is a colorful line on top of the fragment
i tried to change gradle config both minSdkVersion and targetSdkVersion to 21 (set to 14 before), but still the old style.
Is there any version config caused this diff?
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.weibo.biz.tongji"
minSdkVersion 21 targetSdkVersion 21
} buildTypes {
release {
minifyEnabled false proguardFiles
getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile files('libs/android-support-v4.jar')
compile 'com.mcxiaoke.volley:library:1.0.11'
}
remove
compile files('libs/android-support-v4.jar')
and add
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:support-v4:+'
and you should get the rounded style

Can't render layout in Android Studio 0.8.6 with android-times-square v1.3.0

I'm struggling with the embedded renderer in Android Studio of a calendar-picker plugin android-times-square.
https://github.com/square/android-times-square
My layout declaration:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.squareup.timessquare.CalendarPickerView
android:id="#+id/calendar_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingBottom="16dp"
android:scrollbarStyle="outsideOverlay"
android:clipToPadding="false"
android:background="#FFFFFF"
/>
The relevant exception stack trace being shown by the IDE:
java.lang.IllegalArgumentException: Illegal pattern character 'L'
at java.text.SimpleDateFormat.compile(SimpleDateFormat.java:845)
at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:659)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:585)
at com.squareup.timessquare.CalendarPickerView.<init>(CalendarPickerView.java:121)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
Now, I'm aware of changes in valid character patterns beginning from API version 9 (addition of 'L' and 'C') but I have my SDK's managed by build.gradle in the following way:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'joda-time:joda-time:2.3'
compile 'com.squareup.retrofit:retrofit:1.5.1'
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.squareup:android-times-square:1.3.0#aar'
}
Therefore there shouldn't be any problem with resolving proper versions and SDK sources with the troublesome 'L' for that matter. Here's the screenshot to the Preview settings:
http://i.imgur.com/aqauFHq.jpg?1
Any help is greatly appreciated.
At this time it's a bug in the layout library that the preview renderer uses -- it's calling the JDK version of the SimpleDateFormat class instead of the Android version. You can tell this because the Android version doesn't have a compile() method at all.
You can track the bug at
https://code.google.com/p/android/issues/detail?id=75940

Categories

Resources