I looked at other SO posts and configured accordingly. But I still see this issue on some Android devices (4.3.1). It works 75% of time.
You need to use a Theme.AppCompat theme (or descendant) with this activity.
What is wrong with code below?
BaseActivity extends android.support.v7.appAppCompatActivity
<application
android:allowBackup="true"
android:theme="#style/AppTheme" >
All activities (crashed acitivity as well) use AppTheme from application tag. One activity uses:
<activity
android:name=".Activities.EntryActivity"
android:noHistory="true"
android:theme="#style/SplashTheme" >
I don't have any other style.xml.
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
</style>
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">#drawable/background_splash</item>
</style>
From Android:
<style name="Theme.AppCompat.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
java.lang.RuntimeException: Unable to start activity
ComponentInfo{Activities.MyAcitivity}:
java.lang.IllegalStateException: You need to use a Theme.AppCompat
theme (or descendant) with this activity. 1 at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
2 at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
3 at android.app.ActivityThread.access$600(ActivityThread.java:141)
4 at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
5 at android.os.Handler.dispatchMessage(Handler.java:99) 6 at
android.os.Looper.loop(Looper.java:137) 7 at
android.app.ActivityThread.main(ActivityThread.java:5103) 8 at
java.lang.reflect.Method.invokeNative(Native Method) 9 at
java.lang.reflect.Method.invoke(Method.java:525) 10 at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
11 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12 at com.android.internal.os.ZygoteInit.main(Native Method) 13 at
dalvik.system.NativeStart.main(Native Method) 14 Caused by:
java.lang.IllegalStateException: You need to use a Theme.AppCompat
theme (or descendant) with this activity. 15 at
android.support.v7.app.AppCompatDelegateImplV7.i(SourceFile:340) 16 at
android.support.v7.app.AppCompatDelegateImplV7.h(SourceFile:309) 17 at
android.support.v7.app.AppCompatDelegateImplV7.setContentView(SourceFile:273)
18 at
android.support.v7.app.AppCompatActivity.setContentView(SourceFile:136)
19 at .Commons.BaseActivity.onCreate(SourceFile:236) 20 at
.MyActivity.onCreate(SourceFile:24) 21 at
android.app.Activity.performCreate(Activity.java:5133) 22 at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
23 at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
24 ... 12 more 25 java.lang.IllegalStateException: You need to use a
Theme.AppCompat theme (or descendant) with this activity. 26 at
android.support.v7.app.AppCompatDelegateImplV7.i(SourceFile:340) 27 at
android.support.v7.app.AppCompatDelegateImplV7.h(SourceFile:309) 28 at
android.support.v7.app.AppCompatDelegateImplV7.setContentView(SourceFile:273)
29 at
android.support.v7.app.AppCompatActivity.setContentView(SourceFile:136)
30 at Activities.Commons.BaseActivity.onCreate(SourceFile:236) 31 at
Activities.Accounts.AppLaunchActivity.onCreate(SourceFile:24) 32 at
android.app.Activity.performCreate(Activity.java:5133) 33 at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
34 at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
35 at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
36 at android.app.ActivityThread.access$600(ActivityThread.java:141)
37 at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
38 at android.os.Handler.dispatchMessage(Handler.java:99) 39 at
android.os.Looper.loop(Looper.java:137) 40 at
android.app.ActivityThread.main(ActivityThread.java:5103) 41 at
java.lang.reflect.Method.invokeNative(Native Method) 42 at
java.lang.reflect.Method.invoke(Method.java:525) 43 at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
44 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
45 at com.android.internal.os.ZygoteInit.main(Native Method) 46 at
dalvik.system.NativeStart.main(Native Method)
try this:
in res/values/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>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Now in your manifest:
<application
android:theme="#style/AppTheme"> //base Application theme
<activity
android:name=".Activities.EntryActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar"> //Activity Theme
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
After solving a JDK zero value error, now I'm facing this one. I did a little research, but it seems I can't get to the point. Here is the log error:
FATAL EXCEPTION: main
E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{.MainActivity}: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020013
E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2204)
E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2254)
E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:141)
E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5069)
E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime: Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020013
E/AndroidRuntime: at android.content.res.Resources.loadDrawable(Resources.java:1953)
E/AndroidRuntime: at android.content.res.Resources.getDrawable(Resources.java:660)
E/AndroidRuntime: at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:354)
E/AndroidRuntime: at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193)
E/AndroidRuntime: at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:181)
E/AndroidRuntime: at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:689)
E/AndroidRuntime: at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
E/AndroidRuntime: at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77)
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:83)
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV7.<init>(AppCompatDelegateImplV7.java:146)
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:28)
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:41)
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:193)
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:173)
E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:511)
E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
E/AndroidRuntime: at .MainActivity.onCreate(MainActivity.java:29)
E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5104)
E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1092)
E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2254)
E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:141)
E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5069)
E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime: Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector
E/AndroidRuntime: at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:881)
E/AndroidRuntime: at android.graphics.drawable.Drawable.createFromXml(Drawable.java:822)
E/AndroidRuntime: at android.content.res.Resources.loadDrawable(Resources.java:1950)
E/AndroidRuntime: at android.content.res.Resources.getDrawable(Resources.java:660)
E/AndroidRuntime: at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:354)
E/AndroidRuntime: at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193)
E/AndroidRuntime: at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:181)
E/AndroidRuntime: at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:689)
E/AndroidRuntime: at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
E/AndroidRuntime: at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77)
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:83)
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV7.<init>(AppCompatDelegateImplV7.java:146)
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:28)
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:41)
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:193)
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:173)
E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:511)
E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
E/AndroidRuntime: at .MainActivity.onCreate(MainActivity.java:29)
E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5104)
E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1092)
E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2254)
E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:141)
E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5069)
E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
I'm really confused about what it can be, I read and can't get to the error:
My app:gradle is this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "me.me2.com.myapp"
minSdkVersion 15
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.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.google.firebase:firebase-storage:9.4.0'
compile 'com.google.firebase:firebase-database:9.4.0'
compile 'com.google.firebase:firebase-auth:9.4.0'
compile 'com.firebaseui:firebase-ui-database:0.4.4'
compile 'com.squareup.picasso:picasso:2.5.2'
}
apply plugin: 'com.google.gms.google-services'
Here is my style folder:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<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" />
<style name="Divider">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">1dp</item>
<item name="android:background">?android:attr/listDivider</item>
</style>
</resources>
And my mainactivity.class if needed:
public class MainActivity extends AppCompatActivity {
VideoView videoView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// VideoView
videoView = (VideoView) findViewById(R.id.videoview);
videoView.setVideoURI(Uri.parse("android.resource://"+getPackageName() + "/" +R.raw.video));
videoView.requestFocus();
/**
* Loop
*/
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
videoView.start();
mp.setLooping(true);
}
});
}
public void Login(View view) {
Intent intent = new Intent(this, FragmentMain.class);
startActivity(intent);
// finish();
}
public void Registro(View view) {
Intent intent = new Intent(this, Registro.class);
startActivity(intent);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Thanks.
IF you're using Gradle Plugin 2.0, you need to make changes in your gradle:
// Gradle Plugin 2.0+
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
If you are using Gradle 1.5 you’ll use instead of previus:
// Gradle Plugin 1.5
android {
defaultConfig {
// Stops the Gradle plugin's automatic rasterization of vectors
generatedDensities = []
}
// Flag to tell aapt to keep the attribute ids around
// This is handled for you by the 2.0+ Gradle Plugin
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
Check also: Update Android Support Library to 23.2.0 cause error: XmlPullParserException Binary XML file line #17<vector> tag requires viewportWidth > 0.
Android Support Library Ref.: Support Vector Drawables and Animated Vector Drawables.
Also update Android Support dependencies from
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
to
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'
as you're already using build-tools in version of 24.0.2.
If any of the other solutions does not work, you can add this line in your Activity
static {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
and of course, update your gradle and appcompat to the latest versions. This worked in my case.
None of these worked for me. But this did:
Change
android:src="#drawable/your_drawable"
to
app:srcCompat="#drawable/your_drawable"
I ran into this issue in Xamarin.Android with Xamarin.Android.Support.Design 24.0.2. Here is how I solved it:
Added the following line to my Application class OnCreate:
AppCompatDelegate.CompatVectorFromResourcesEnabled = true;
Replaced:
var upArrow = ContextCompat.GetDrawable(this, Resource.Drawable.abc_ic_ab_back_material);
With:
var upArrow = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.abc_ic_ab_back_material, null);
Since this page is the first result of google android.content.res.Resources$NotFoundException: File res/drawable/, I want to share that this exception might caused by your foo.xml contains improper code.
e.g. foo.xml:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#android:id/background">
<shape>
<size android:height="#android:style/Widget.ProgressBar.Horizontal" />
<corners android:radius="5dip" />
<gradient
android:startColor="#000000"
android:centerY="0.75"
android:angle="270"
/>
</shape>
</item>
</layer-list>
This xml contains <size android:height="#android:style/Widget.ProgressBar.Horizontal" /> which compiled successfully but throws exception at Runtime, vary in different app.
use like this in your Activity:
public class MainActivity extends AppCompatActivity {
static {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
...
}
and this in your build.gradle :
android {
...
defaultConfig {
....
vectorDrawables.useSupportLibrary = true
}
}
and in your xml:
app:srcCompat="#drawable/your_icon"
For me the issue was while running the app on Kitkat version I got this runtime crash.
Issue:
android {
compileSdkVersion 28
defaultConfig {
//Change this to true to enable multidex support for Kitkat
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
Solution:
//comment the line of vector support
android {
//Change this to true to enable multidex support for Kitkat
multiDexEnabled true
//vectorDrawables.useSupportLibrary = true
}
Ok, i just solved my problem, the problem was my gradle outdated and my sdk , so if anyone is running with this problem just do this steps
1.- Make sure your libs are updated as piotrek1543 says above
2.- Update your sdk if is necesary
3.- Update your gradle files (VERY IMPORTANT)
just go to the project gradle and add this
classpath 'com.android.tools.build:gradle:2.1.0'
then go to your app project > app > graddle > graddlewrapper.properties and add
distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip
4.- change your compile compileSdkVersion to 24
and your buildToolsVersion "24.0.2" (MAKE SURE YOUR DEPENDENCES ARE UP TO DATE WITH THE SDK)
Have fun
I have tried all solutions mentioned above. Nothing worked for me. The only thing worked for me is very simple is to update all support libraries to latest version as this bug has been fixed in it. So i simple did the below thing in gradle file; updated SDK and support to 25.
android {
compileSdkVersion 25
buildToolsVersion "25"
defaultConfig {
targetSdkVersion 25
}
}
In dependencies
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:recyclerview-v7:25.1.0'
Not specifically related to your question, but maybe can solve this problem for all that find themselves here while searching for that error.
For me was the problem with SVG file that I have imported into my project. One of the paths in XML has empty pathData and that was causing the crash on some devices like Pixel XL, Samsung Galaxy S7,...
So double check imported XML for an image if you are using SVG as your image source.
I had this problem.
In your Application class, in the onCreate() method, add:
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
... and also use AppCompatImageView instead of ImageView.
Ex :
BaseApplication.class :
public class BaseApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
//Your other code here...
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
}
XML :
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/yourIvId"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
In my case, the issue was about using vector drawable.
The spec of the test device was Huawei EVA-L19, Android: Marshmallow
Using srcCompat instead of src resolved my problem.
In my case, the problem was wrong super-type. I added image view dynamically, and used ImageView instead of AppCompatImageView. Choosing the right super class solved the issue.
I tried all the answers above but no success because of clarity most of the time.
Just do this:
In the launch_background.xml file, replace mipmap with drawable
Copy the icon image that should be your app icon and paste it in the drawable folder
At the end the launch_background.xml file should look like below.
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#color/blue" />
<!-- You can insert your own image assets here -->
<item>
<bitmap android:gravity="center" android:src="#drawable/ic_launcher" />
</item>
</layer-list>
Changing the kotlin-stdlib dependency from:
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:1.2.0"
to
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.2.0"
fixed the error.
in my case the XML contained android:endX that supports from 24 and up.
If you are using ?attr inside your drawable, this could be the reason of error.
consider replacing it with Vector Drawable so it can be used in all android versions:
Replace
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="?attr/navigationIconColor" />
</shape>
</item>
</selector>
With:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="37dp"
android:height="5dp"
android:viewportWidth="37"
android:viewportHeight="5">
<path
android:pathData="M2.5,0h32C35.9,0 37,1.1 37,2.5l0,0C37,3.9 35.9,5 34.5,5h-32C1.1,5 0,3.9 0,2.5l0,0C0,1.1 1.1,0 2.5,0z"
android:fillColor="?attr/navigationIconColor"/>
</vector>
The above methods didn’t work for me. I solved it by adding image of every size and used android:src as well it worked.
See the answer here https://stackoverflow.com/a/64537207/11669081
for running the app on Kitkat version make use of VectorDrawableCompat like below
ivBg.setImageDrawable(VectorDrawableCompat.create(resources, R.drawable.ic_bg_minicash_single,context?.theme))
No need to change ImageView into AppCompatImageView explicitly AppCompatActivity will automatically convert it.
I have a release Android App that goes smooth on a Nexus 5X running Android 6.0.1. and on a Samsung 5 running Android 5.0.
However, on other devices weird exceptions rise when double clicking or long clicking any EditText.
This is the track on an Alcatel OneTouch (Android 5.1):
E/AndroidRuntime: FATAL EXCEPTION: main
Process: es.solbyte.ociohoteles, PID: 18176
android.view.InflateException: Binary XML file line #17: Error inflating class TextView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.widget.Editor$ActionPopupWindow.initContentView(Editor.java:3047)
at android.widget.Editor$PinnedPopupWindow.<init>(Editor.java:2302)
at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:3019)
at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:3019)
at android.widget.Editor$HandleView.showActionPopupWindow(Editor.java:3422)
at android.widget.Editor$InsertionHandleView.showWithActionPopup(Editor.java:3672)
at android.widget.Editor$InsertionPointCursorController.showWithActionPopup(Editor.java:3929)
at android.widget.Editor.performLongClick(Editor.java:900)
at android.widget.TextView.performLongClick(TextView.java:9104)
at android.view.View$CheckForLongPress.run(View.java:20236)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5631)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=15; index=1570
at android.content.res.StringBlock.get(StringBlock.java:65)
at android.content.res.XmlBlock$Parser.getPooledString(XmlBlock.java:458)
at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:1003)
at android.content.res.TypedArray.getString(TypedArray.java:188)
at android.widget.TextView.<init>(TextView.java:1042)
at android.widget.TextView.<init>(TextView.java:660)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:60)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:56)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:980)
at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:1039)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:725)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.widget.Editor$ActionPopupWindow.initContentView(Editor.java:3047)
at android.widget.Editor$PinnedPopupWindow.<init>(Editor.java:2302)
at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:3019)
at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:3019)
at android.widget.Editor$HandleView.showActionPopupWindow(Editor.java:3422)
at android.widget.Editor$InsertionHandleView.showWithActionPopup(Editor.java:3672)
at android.widget.Editor$InsertionPointCursorController.showWithActionPopup(Editor.java:3929)
at android.widget.Editor.performLongClick(Editor.java:900)
at android.widget.TextView.performLongClick(TextView.java:9104)
at android.view.View$CheckForLongPress.run(View.java:20236)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5631)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
And this is the track on an ZTE Kis II Max (Android 4.4.2):
06-29 16:37:44.361 12852-12852/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: es.solbyte.ociohoteles, PID: 12852
android.view.InflateException: Binary XML file line #17: Error inflating class TextView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.widget.Editor$ActionPopupWindow.initContentView(Editor.java:2973)
at android.widget.Editor$PinnedPopupWindow.<init>(Editor.java:2268)
at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:2946)
at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:2946)
at android.widget.Editor$HandleView.showActionPopupWindow(Editor.java:3166)
at android.widget.Editor$SelectionModifierCursorController.initHandles(Editor.java:3690)
at android.widget.Editor$SelectionModifierCursorController.show(Editor.java:3661)
at android.widget.Editor$SelectionActionModeCallback.onCreateActionMode(Editor.java:2896)
at com.android.internal.policy.impl.PhoneWindow$DecorView$ActionModeCallbackWrapper.onCreateActionMode(PhoneWindow.java:2811)
at android.support.v7.view.SupportActionModeWrapper$CallbackWrapper.onCreateActionMode(SupportActionModeWrapper.java:155)
at android.support.v7.app.AppCompatDelegateImplV7$ActionModeCallbackWrapperV7.onCreateActionMode(AppCompatDelegateImplV7.java:1742)
at android.support.v7.app.AppCompatDelegateImplV7.startSupportActionModeFromWindow(AppCompatDelegateImplV7.java:802)
at android.support.v7.app.AppCompatDelegateImplV7.startSupportActionMode(AppCompatDelegateImplV7.java:696)
at android.support.v7.app.AppCompatDelegateImplV14$AppCompatWindowCallbackV14.startAsSupportActionMode(AppCompatDelegateImplV14.java:187)
at android.support.v7.app.AppCompatDelegateImplV14$AppCompatWindowCallbackV14.onWindowStartingActionMode(AppCompatDelegateImplV14.java:171)
at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionMode(PhoneWindow.java:2432)
at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionModeForChild(PhoneWindow.java:2419)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:689)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:689)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:689)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:689)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:689)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:689)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:689)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:689)
at android.view.View.startActionMode(View.java:4561)
at android.widget.Editor.startSelectionActionMode(Editor.java:1584)
at android.widget.Editor.performLongClick(Editor.java:877)
at android.widget.TextView.performLongClick(TextView.java:8585)
at android.view.View$CheckForLongPress.run(View.java:18768)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5299)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=15; index=1570
at android.content.res.StringBlock.get(StringBlock.java:65)
at android.content.res.XmlBlock$Parser.getPooledString(XmlBlock.java:458)
at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:721)
at android.content.res.TypedArray.getString(TypedArray.java:125)
at android.widget.TextView.<init>(TextView.java:1002)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:60)
at android.support.v7.
Is someone able to explain what is this happening? Is it somehow related with the hardware/distribution?
EDIT 1:
Please take into account that this is a big app so I cannot post all places where it is crashing. This is an extract of the very first EditText where the app is crashing.
// LoginActivity.java
public class LoginActivity extends ApiActivity implements
onLoginSuccessListener {
#Bind(R.id.login_field_email)
protected EditText user;
/* OnCreate and other methods... */
#OnTextChanged({R.id.login_field_email, R.id.login_field_password})
public void onAnyFieldChanged() {
loginButton.setEnabled(areFieldFilled());
}
This is the content layout XML file:
<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:padding="16dp"
tools:context=".activity.LoginActivity"
tools:showIn="#layout/activity_login">
<LinearLayout
android:id="#+id/login_forms"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/login_brand"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="#android:color/white">
<EditText
android:id="#+id/login_field_email"
style="#style/EditTextLogin"
android:hint="#string/registration_email"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout>
...
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<Button
...
/>
</RelativeLayout>
The styles.xml:
<style name="EditTextLogin" parent="android:Widget.EditText">
<item name="android:fontFamily">sans</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:singleLine">true</item>
<item name="android:maxLines">1</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">44dp</item>
</style>
The build.gradle files:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "..."
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
signingConfigs {
config {
keyAlias '...'
keyPassword '...'
storeFile file('...')
storePassword '...'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
debuggable true
useProguard false
applicationIdSuffix ".debug"
}
}
}
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
maven { url 'https://maven.fabric.io/public' }
maven { url "https://clojars.org/repo/" }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.crashlytics.sdk.android:crashlytics:2.5.2#aar') {
transitive = true;
}
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.android.gms:play-services-gcm:9.0.2'
compile 'com.google.android.gms:play-services-location:9.0.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton:butterknife:7.0.1'
}
And the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="es.solbyte.ociohoteles">
<!-- All needed permissions here -->
<application
android:name=".MyApplication"
android:allowBackup="true"
android:fullBackupContent="false"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="false"
android:theme="#style/Base.AppTheme">
<!-- Login -->
<activity
android:name=".activity.LoginActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="#style/Base.AppTheme.Login"/>
</application>
<manifest>
And just in case the BaseApp theme:
<!-- Base -->
<style name="Base.AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Colours -->
<item name="colorPrimary">#color/primaryColor</item>
<item name="colorPrimaryDark">#color/primaryColor_dark</item>
<item name="colorAccent">#color/accentColor</item>
<item name="android:windowBackground">#color/background_activity</item>
<!-- Fonts -->
<item name="android:fontFamily">sans-serif</item>
</style>
I have same problem with editText
the problem in my case was in my style
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="android:fontFamily" tools:targetApi="jelly_bean">sans-serif</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
my problem solved by removing this line of code
<item name="android:fontFamily" tools:targetApi="jelly_bean">sans-serif</item>
I have been attempting to run this application from this repository
https://github.com/tekinarslan/AndroidMaterialDesignToolbar
But each time it crashes with the following message
07-26 11:36:39.864 4405-4405/com.tekinarslan.material.sample E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tekinarslan.material.sample/com.tekinarslan.material.sample.SampleActivity}: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:360)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:246)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:106)
at com.tekinarslan.material.sample.SampleActivity.onCreate(SampleActivity.java:36)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
The following is the build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.tekinarslan.material.sample"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.2"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:22.1.1'
compile 'com.android.support:appcompat-v7:22.1.1'
}
And this is the styles.xml file
<resources>
<style name="AppTheme" parent="AppTheme.Base"/>
<style name="AppTheme.Base" parent="Theme.AppCompat">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">#android:color/white</item>
</style>
</resources>
It shows the same message even after I replace ActionBarActivity with AppCompatActivity in the SampleActivity.java file..Please help
Replacing android:windowNoTitle with just windowNoTitle fixes the issue.
Had similar problem and
https://blog.xamarin.com/android-tips-hello-material-design-v7-appcompat/
fixed using suggestion given in this link.
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
If your intention is to not use actionbar at all and use only toolbar, you can use Theme.AppCompat.NoActionBar as parent. (This I have tried on your git code and it works).
I'm trying to implement the new v7 Support Library ActionBar. However, I can't get it to run properly.
Here's the exception
07-25 09:30:01.704: E/AndroidRuntime(9175): FATAL EXCEPTION: main
07-25 09:30:01.704: E/AndroidRuntime(9175): java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable
07-25 09:30:01.704: E/AndroidRuntime(9175): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:98)
07-25 09:30:01.704: E/AndroidRuntime(9175): at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:58)
07-25 09:30:01.704: E/AndroidRuntime(9175): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98)
07-25 09:30:01.704: E/AndroidRuntime(9175): at com.cidaut.termoweb.MainActivity.onCreate(MainActivity.java:23)
07-25 09:30:01.704: E/AndroidRuntime(9175): at android.app.Activity.performCreate(Activity.java:5133)
07-25 09:30:01.704: E/AndroidRuntime(9175): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-25 09:30:01.704: E/AndroidRuntime(9175): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
07-25 09:30:01.704: E/AndroidRuntime(9175): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
07-25 09:30:01.704: E/AndroidRuntime(9175): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-25 09:30:01.704: E/AndroidRuntime(9175): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
07-25 09:30:01.704: E/AndroidRuntime(9175): at android.os.Handler.dispatchMessage(Handler.java:99)
07-25 09:30:01.704: E/AndroidRuntime(9175): at android.os.Looper.loop(Looper.java:137)
07-25 09:30:01.704: E/AndroidRuntime(9175): at android.app.ActivityThread.main(ActivityThread.java:5103)
07-25 09:30:01.704: E/AndroidRuntime(9175): at java.lang.reflect.Method.invokeNative(Native Method)
07-25 09:30:01.704: E/AndroidRuntime(9175): at java.lang.reflect.Method.invoke(Method.java:525)
07-25 09:30:01.704: E/AndroidRuntime(9175): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
07-25 09:30:01.704: E/AndroidRuntime(9175): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-25 09:30:01.704: E/AndroidRuntime(9175): at dalvik.system.NativeStart.main(Native Method)
The problem happens at the super.onCreate(bundle) call at onCreate().
Here's all my theming related XML:
styled.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Termoweb" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarItemBackground">#drawable/selectable_background_termoweb</item>
<item name="popupMenuStyle">#style/PopupMenu.Termoweb</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Termoweb</item>
<item name="actionBarTabStyle">#style/ActionBarTabStyle.Termoweb</item>
<item name="actionDropDownStyle">#style/DropDownNav.Termoweb</item>
<item name="actionBarStyle">#style/ActionBar.Solid.Termoweb</item>
<item name="actionModeBackground">#drawable/cab_background_top_termoweb</item>
<item name="actionModeSplitBackground">#drawable/cab_background_bottom_termoweb</item>
<item name="actionModeCloseButtonStyle">#style/ActionButton.CloseMode.Termoweb</item>
<!-- Light.DarkActionBar specific -->
<item name="actionBarWidgetTheme">#style/Theme.Termoweb.Widget</item>
</style>
<style name="ActionBar.Solid.Termoweb" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#drawable/ab_solid_termoweb</item>
<item name="backgroundStacked">#drawable/ab_stacked_solid_termoweb</item>
<item name="backgroundSplit">#drawable/ab_bottom_solid_termoweb</item>
<item name="progressBarStyle">#style/ProgressBar.Termoweb</item>
</style>
<style name="ActionBar.Transparent.Termoweb" parent="#style/Widget.AppCompat.ActionBar">
<item name="background">#drawable/ab_transparent_termoweb</item>
<item name="progressBarStyle">#style/ProgressBar.Termoweb</item>
</style>
<style name="PopupMenu.Termoweb" parent="#style/Widget.AppCompat.ListView.Menu">
<item name="popupBackground">#drawable/menu_dropdown_panel_termoweb</item>
</style>
<style name="DropDownListView.Termoweb" parent="#style/Widget.AppCompat.ListView.DropDown">
<item name="listSelector">#drawable/selectable_background_termoweb</item>
</style>
<style name="ActionBarTabStyle.Termoweb" parent="#style/Widget.AppCompat.ActionBar.TabView">
<item name="background">#drawable/tab_indicator_ab_termoweb</item>
</style>
<style name="DropDownNav.Termoweb" parent="#style/Widget.AppCompat.Spinner">
<item name="background">#drawable/spinner_background_ab_termoweb</item>
<item name="popupBackground">#drawable/menu_dropdown_panel_termoweb</item>
<item name="dropDownSelector">#drawable/selectable_background_termoweb</item>
</style>
<style name="ProgressBar.Termoweb" parent="#style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="progressDrawable">#drawable/progress_horizontal_termoweb</item>
</style>
<style name="ActionButton.CloseMode.Termoweb" parent="#style/Widget.AppCompat.ActionButton.CloseMode">
<item name="background">#drawable/btn_cab_done_termoweb</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Termoweb.Widget" parent="#style/Theme.AppCompat">
<item name="popupMenuStyle">#style/PopupMenu.Termoweb</item>
<item name="dropDownListViewStyle">#style/DropDownListView.Termoweb</item>
</style>
</resources>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cidaut.termoweb"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.Termoweb" >
<activity
android:name="com.cidaut.termoweb.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>
So, how I solved this problem:
Import support library as a project from "sdk/extras/android/support/v7/appcompat".
Reference library in your project (for Eclipse, "Properties - Android - Add").
Build projects (for Eclipse, "Projects - Build All"). Make sure, you have "android.support.v7.appcompat" in your main project gen folder.
If it doesn't worked - clean and rebuild project.
I have done the following and worked for me.
Delete the jar from the libs folder.
Import the sdk\extras\android\support\v7\appcompat\ project in your eclipse workspace.
Ensure that the android-support-v4.jar is the same in your project.
Add the appcompat as a library to your project.
Ensure that your in yout Manifest.xml your activity has the correct theme
<activity
android:name="***.*****.******"
android:label="#string/app_name"
android:theme="#style/Theme.AppCompat.Light"
>
Good Luck ;)
In addition to BoredT's answer I added this line to res/values/styles.xml
<style name="AppTheme" parent="#style/Theme.AppCompat.Light">
Follow steps from Adding libraries with resources -> Eclipse http://developer.android.com/tools/support-library/setup.html :
follow all the steps (use copy project in workspace)
add android.library.reference.1=../android-support-v7-appcompat to your project.properties
use android:theme="#style/Theme.AppCompat" I used it in application tag you can apply to individual activities as well
Rebuild all!
I think you should change your target version to 18 in the manifest.
android:targetSdkVersion="18"
This is how I solve the problem: rebuild the adroid-support-v7-appcompat library project in your eclipse workspace. Then build your own project again.
How to import a project as a library in android studio? Follow the tips blog as a reference:
http://showlabor.blogspot.com.br/2013/05/actionbarsherlock-in-android-studio-01.html
The next question, also helped a lot:
Error implementing Support Library Action Bar
The following image shows the structure of the imported project. That is copied to the root of my project and placed in the directory 'libraries':
https://dl.dropboxusercontent.com/u/67269258/Tuto/tree.PNG
In addition to mounting the above structure. In 'settings.glade' I had to add the new project:
include ':FreeMusic', ':libraries:ActionBarCompat:appcompat'
Inside the library project, added the file 'build.gradle'
It is located in: libraries/ActionBarCompat/appcompat
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
dependencies {
compile files(
'libs/android-support-v4.jar',
'libs/android-support-v7-appcompat.jar'
)
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
In 'build.gradle' (internal project) of my project.
dependencies {
compile project(':libraries:ActionBarCompat:appcompat')
}
In android manifest added the necessary theme:
<activity
android:theme="#style/Theme.AppCompat"
android:name="es.hol.soundmedia.MainActivity"
After all this work. Perhaps an easier way to set this up, but for me the account is working.
Unfortunately I can not show the result, because I'm being blocked, but I hope the instructions help.
For those that don't like needing manual user effort in Eclipse in order to do a build from checkout, the magical change that Eclipse makes is to add a line to project.properties like:
android.library.reference.1=../android-support-v7-appcompat
This is enough to build your application from ant. You can do this in the source yourself, or via the Eclipse user interface - either way you can check it in to your version control system and successfully build from a fresh checkout of the source without requiring manual steps.
But you can instead make the path a sub-directory of your own project if that suits better, E.g.
android.library.reference.1=android-support-v7-appcompat
... and ...
cp -r $SDK/extras/android/support/v7/appcompat android-support-v7-appcompat
Note that Eclipse will still show various warnings until the sub-directory is also added [manually!] to Eclipse's workspace as a project. But an ant build will successfully build without using Eclipse.
Check for R.java for appcompat v7 jar is present in your generated folders of your application