here is my project:
animated_path.xml:
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:drawable="#drawable/triangle"
tools:targetApi="21">
<target
android:name="t"
android:animation="#animator/path"/>
</animated-vector>
path.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
android:duration="3000"
android:propertyName="pathData"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:valueFrom="M 100 100 L 300 100 L 300 300 L 100 300z"
android:valueTo="M 100 100 L 300 100 L 200 300 L 200 300z"
android:valueType="pathType"/>
</set>
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kycq.reader">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".LoadingActivity"
android:theme="#style/ActivityTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:theme="#style/ActivityTheme">
</activity>
</application>
</manifest>
LoadingActivity.java:
public class LoadingActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_loading);
}
}
activity_loading.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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.kycq.reader.LoadingActivity">
</RelativeLayout>
styles.xml:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.kycq.reader"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
// enable vectorDrawable
vectorDrawables.setUseSupportLibrary(true)
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
// use 23.2.0
compile 'com.android.support:appcompat-v7:23.2.0'
}
why i receive the error when use 'animated-vector' at android studio 2.0 beta?
the unbelievable is when i delete 'res/animator' and 'animated_path.xml',then rebuild project,it works.
it make me crazy, i don't know why,and how to solve the problem,anyone can help me ?
the terrible is,sometime it throw the error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kycq.reader/com.kycq.reader.LoadingActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
but i had set the style 'ActivityTheme' to the LoadingActivity.
now i post the project to the web:https://drive.google.com/open?id=0B7cSTEJuaMZBLW9VYWM5X0szVlk
also try "clean project"
this occurred to me even if no changes made to build version or manifest.
"Android Studio: menu> Build -> Clean Project"
did it.
if this doesn't solve your problem, also try
"Android Studio: menu> File -> Invalidate Caches / Restart"
Had a similar issue this morning. How I fix it:
Remove application level attribute from your android manifest file android:theme="#style/AppTheme".
Add activity level attribute instead like so:
[Activity(MainLauncher = true, Theme = "#style/AppTheme")]
'Rebuild Project' solved the problem for my project on Android Studio 2020.3.1.
This issue occurs when your buildToolsVersion is not updated to match the version of playservices and other dependencies
Check here for the latest version:
https://developer.android.com/studio/releases/build-tools.html.
In my case, I did these steps, and after them it worked:
Reinstall Android Studio
Build -> Clean Project
File -> Invalidate Caches
And Updating gradle (there was a popup bottom right)
Related
here is my project:
animated_path.xml:
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:drawable="#drawable/triangle"
tools:targetApi="21">
<target
android:name="t"
android:animation="#animator/path"/>
</animated-vector>
path.xml:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
android:duration="3000"
android:propertyName="pathData"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:valueFrom="M 100 100 L 300 100 L 300 300 L 100 300z"
android:valueTo="M 100 100 L 300 100 L 200 300 L 200 300z"
android:valueType="pathType"/>
</set>
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kycq.reader">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".LoadingActivity"
android:theme="#style/ActivityTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:theme="#style/ActivityTheme">
</activity>
</application>
</manifest>
LoadingActivity.java:
public class LoadingActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_loading);
}
}
activity_loading.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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.kycq.reader.LoadingActivity">
</RelativeLayout>
styles.xml:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.kycq.reader"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
// enable vectorDrawable
vectorDrawables.setUseSupportLibrary(true)
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
// use 23.2.0
compile 'com.android.support:appcompat-v7:23.2.0'
}
why i receive the error when use 'animated-vector' at android studio 2.0 beta?
the unbelievable is when i delete 'res/animator' and 'animated_path.xml',then rebuild project,it works.
it make me crazy, i don't know why,and how to solve the problem,anyone can help me ?
the terrible is,sometime it throw the error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kycq.reader/com.kycq.reader.LoadingActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
but i had set the style 'ActivityTheme' to the LoadingActivity.
now i post the project to the web:https://drive.google.com/open?id=0B7cSTEJuaMZBLW9VYWM5X0szVlk
also try "clean project"
this occurred to me even if no changes made to build version or manifest.
"Android Studio: menu> Build -> Clean Project"
did it.
if this doesn't solve your problem, also try
"Android Studio: menu> File -> Invalidate Caches / Restart"
Had a similar issue this morning. How I fix it:
Remove application level attribute from your android manifest file android:theme="#style/AppTheme".
Add activity level attribute instead like so:
[Activity(MainLauncher = true, Theme = "#style/AppTheme")]
'Rebuild Project' solved the problem for my project on Android Studio 2020.3.1.
This issue occurs when your buildToolsVersion is not updated to match the version of playservices and other dependencies
Check here for the latest version:
https://developer.android.com/studio/releases/build-tools.html.
In my case, I did these steps, and after them it worked:
Reinstall Android Studio
Build -> Clean Project
File -> Invalidate Caches
And Updating gradle (there was a popup bottom right)
I'm new to android studio and I have a new version installed (version 1.5.1).
For some reason I keep getting an error message (every time I use an app theme) saying that there were rendering problems: styles missing.
I looked online for solutions, but most of them are outdated or just do not work.
Thanks for any help.
Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.easycodingplus.myapplication">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Build gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.easycodingplus.myapplication"
minSdkVersion 8
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.1.1'
compile 'com.android.support:design:23.1.1'
}
just change your style.xml file like this
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
and then, go to
File > Project Structure > app >
and set (both should be same with latest version )
source compatibility : 1.7
Target compatibility : 1.7
you have to include the dependencies for design which is like this, this will be added under the dependencies block of the app module of the build.gradle
compile 'com.android.support:design:23.1.1'
it should be something like this ..
you need this support library as CoordinatorLayout, AppBarLayout and FloatingActionButton part of it
make a style in the style file
<style name="AppTheme" parent="Base.Theme.AppCompat.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
and reference that in your AndroidManifest file
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="#style/AppTheme">// like this
Please ensure you have the lateset AppCompat library listed as a dependency in your build.gradle file:
com.android.support:appcompat-v7:23.1.0
Can you post which style the error is referring to? You may need to add a style to your res > values > styles folder. Something in your code is probably referencing a style that does not exists in that folder.
try this way:
keep your internet connection
go to "file" in android studio toolbar click on "invalidate caches/Restart" and choose "invalidate and restart"
3 options
1.Select low-level API version
2.Add Base on styles.xml
3.Install previous SDK (if you want)
I also faced the same problem so what I did...go to sdk manager -->tick android 5.1.1 api level 22 and installed it....
then go to Preview window and select other version
I faced the same problem and these steps helped me solve it:
1. File > Other settings > Default Settings > Appearances & Behaviour > File encoding.
2. Change project encoding to windows-1252. Then:
3. File > Invalidate Chaches/Restart.
OR WORST CASE
Change the theme to Material light or something else, one of them should work.
I hope this helps.
I am currently trying to create an Android app using the Android L SDK version.
However, when trying to build my project using Gradle, I run into the following error:
"Error: Found item Style/AppTheme more than one time"
Which points to my res/values-v21/styles.xml
I know that in res/values/styles.xml there is a style "AppTheme" already defined, but as far as I know I was following the Android developers guide on using Android L. Perhaps someone can help me:
Here is my:
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-L'
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "com.mayuonline.ribbit"
minSdkVersion 'L'
targetSdkVersion 'L'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:20.+'
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="resume.kelseyhrubes" >
<uses-sdk android:minSdkVersion="L" android:targetSdkVersion="L"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
values/styles.xml
<resources>
<!-- inherit from the material theme -->
<style name="AppTheme" parent="android:Theme.Material">
<!-- Main theme colors -->
<!-- your app branding color for the app bar -->
<item name="android:colorPrimary">#color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="android:colorPrimaryDark">#color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="android:colorAccent">#color/primary_light</item>
</style>
</resources>
values-v21/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Material.Light">
</style>
<style name="AppTheme">#color/primary
#color/primary_dark
#color/primary_light
</style>
</resources>
I apologize for the bad formatting, I hope everything is readable.
If anyone knows what I am doing wrong, please let me know. I just want to make an app with that sweet material design.
I'm using android studio 0.8.4
when I extend #style/Theme.AppCompat.Light, android studio says can't resolove symbol 'Theme' with red font colored Theme. but when I run this project, it runs well. I can't know how to solve this problem. belows are my codes.
styles.xml
<resources>
<!-- the theme applied to the application or activity -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
</style>
</resources>
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "kr.co.hiworks.office"
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
disable 'InvalidPackage'
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:19.+'
compile 'com.android.support:appcompat-v7:19.+'
compile 'com.jakewharton:butterknife:5.1.1'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.mcxiaoke.volley:library:1.0.6'
compile 'com.github.satyan:sugar:1.3'
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="kr.co.hiworks.office" >
<application
android:name=".BaseApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data android:name="DATABASE" android:value="hiworks_office.db" />
<meta-data android:name="VERSION" android:value="1" />
<meta-data android:name="QUERY_LOG" android:value="true" />
<meta-data android:name="DOMAIN_PACKAGE_NAME" android:value="kr.hiworks.office.models" />
<activity
android:name=".activities.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
https://code.google.com/p/android/issues/detail?id=64649
This bug is because of gradle 0.12.2
So I changed gradle version from 0.12.+ to 0.12.1 and It works well.
The problem is not with the way the application is built (i.e. merging styles from external libraries). The problem is that the Android Studio XML editor is not aware of the resources in the external libraries.
This problem is already being answered by many please have a look at it
IDE "Cannot Resolve #style/Theme.Appcompat" when using v7 compatibility support theme
This is bug because of low gradle you could download gradle from this reference
and replace it with old gradle.
Second solution is update your android studio to newer version.
third Solution is Invalidate / Cache restart.
Hope it help.
I'm starting out with Android development and trying to play around with a test app on Android L.
I want to be able to load the material design theme on the Android L emulator, and standard holo theme on my Android 4.4 emulator. I just really can't get it running.
When I try and run the app I'm getting this error:
Error:Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material'.
My gradle file is like this:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
buildToolsVersion '20.0.0'
defaultConfig {
applicationId 'com.blitzcomputerservices.equinehealth'
versionCode 1
versionName '1.0'
}
productFlavors {
l {
minSdkVersion 'android-L'
targetSdkVersion 'L'
compileSdkVersion 'android-L'
}
old {
minSdkVersion 16
targetSdkVersion 20
//TODO comment second line if build is not compiles for "L"
compileSdkVersion 20
}
}
}
dependencies {
compile 'com.koushikdutta.ion:ion:1.1.5'
compile 'com.soundcloud.android:android-crop:0.9.9#aar'
/*lCompile 'com.android.support:appcompat-v7:21.+'
oldCompile 'com.android.support:appcompat-v7:19.1.0'*/
}
And the manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.blitzcomputerservices.equinehealth">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.blitzcomputerservices.equinehealth.EquineHealthActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.blitzcomputerservices.equinehealth.HorseDetails"
android:parentActivityName="com.blitzcomputerservices.equinehealth.EquineHealthActivity"
android:label="#string/title_activity_horse_details" >
</activity>
<activity android:name="com.soundcloud.android.crop.CropImageActivity" />
</application>
I have two styles.xml files:
One in values with:
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
</resources>
and another in values-v21 with:
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material">
<!-- Customize your theme here. -->
</style>
What am I doing wrong?
and another in values-v21 with:
The L preview is API 20, not v21