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
Related
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.
I am trying to build an app which is composed out of separate library projects.
To do this, I'm trying to make a proof of concept which is supposed to be as following:
I tried to keep the project as simple as possible. The projects contents do not matter!
All that matters is the dependencies between the projects!
The result should be that MainProject will print out Something Another String!
I have tried all from .JAR files to .AAR files, but the best I got was
with the dependency in red. I added the StringExtender.aar file to StringReturner, and then the StringReturner.aar file to the MainProject.
When I do this I get the following Exception:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/example/erik/stringextender/StringExtender;
What is the right way to setup a simple proof of concept like this? I can't seem to find anything related to a library project having a dependency. It's all 1 level deep!
Any help is welcome!
EDIT SHOWING GRADLE BUILD FILES
StringReturner:
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile project(':StringExtender-lib-debug')
}
MainProject:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.erik.erikpoc10"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile project(':StringReturnerLib-debug')
}
Use the following tutorial - Creating libraries for Android applications
See a working example project on my Github
The most important steps taken were:
8.3. Create library module.
8.6. Define dependency to the library project.
Do not forget to import the library class you want to use, for example:
In MainProject: import com.example.stringreturner.StringReturner.
In StringReturner: import com.example.stringreturner.StringExtender.
The info below is based on the image you provided:
The library methods are not static so don't forget to make an actual object.
So StringReturner should make a StringExtender object, And MainProject should make a StringReturner object first!
And finally, I think it's a typo but both libraries have the class StringReturner. This will not work in the StringReturner library for obvious reasons.
I should also note that I used Android Studio 2.0 and I did not touch .JAR files nor .AAR files. I merely created two library modules and one app. Then configured the Project Structure -> Dependencies by adding Module Dependencies.
I am using CircularImageView library to show rounded images in my app.
In my xml file,
<GridLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<com.pkmmte.view.CircularImageView
android:layout_width="250dp"
android:layout_height="250dp"
android:src="#drawable/image"
app:border_color="#EEEEEE"
app:border_width="4dp"
/>
<ImageView
android:layout_width="250dp"
android:layout_height="250dp"
android:src="#drawable/image2"/>
</GridLayout>
Android Studio isnt showing #drawable/image. 'image.jpg' exists in my drawable folder. When I hit CTRL+SPACE after drawable/, I get no suggestions.
The weird part is the code android:src="#drawable/image2" in next ImageView works perfectly, gives suggestions,etc.
I've also tried adding those images in CircularImageView's drawable folder.
I've tried cleaning and rebuilding project, doesn't work.
app - > build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.appquest.fitterfox"
minSdkVersion 14
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 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:support-v4:22.2.1'
compile project(':libraries:loadtoast')
compile project(':libraries:circleimageview')
}
Instead of adding your dependencies manually, it's better to fetch them using gradle
compile 'com.pkmmte.view:circularimageview:1.1'
will automatically fetch and add circularimageview to your project
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
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