Can't Find Theme.AppCompat.Light for New Andro

2018-12-31 10:23发布

I am trying to implement the new ActionBar support library that was released by Google a couple days ago. In the past, I have successfully implemented ActionBarSherlock without any issues using the same method listed on Google Developer's Support Library Setup page - using the guide on how to include the resources (which is similar to how ActionBarSherlock did it). I have the library project loaded in to my own project as a library as well.

I can tell the library is loading fine. When, instead of extending Activity on my MainActivity.java, I changed it to extend ActionBarActivity (as per Google's instructions), no errors occur - and it imports correctly.

I even tried bypassing the style.xml file and adding @style/Theme.AppCompat.Light directly in to the AndroidManifest.xml for both <application> and <activity> with android:theme="@style/ThemeAppCompat.Light" with all attempts resulting in the same error.

Now the issue is I cannot get it to change the theme, let alone even build without throwing an error. Below is the error I am receiving, followed by the style.xml file I changed to use the new theme.

I have moderate experience working with Android apps and am running Eclipse with the latest version of the Support Libraries and SDK compiling with API 18 (Android 4.3).

Error Received During Build

error: Error retrieving parent for item: No resource found that matches the given name '@style/Theme.AppCompat.Light'. styles.xml /ActBarTest/res/values line 3 Android AAPT Problem

style.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.ProsoftStudio.ACTest" parent="@style/Theme.AppCompat.Light">
    </style>
</resources>

Any suggestions? This was never an issue with ActionBarSherlock. I want to work on using this new support library. It almost seems like the .jar is loading, but not the resources.

30条回答
与风俱净
2楼-- · 2018-12-31 11:00

in eclipse right click on your project-> select build path and then select configure build path. from the window select the jar file that you want and refresh your project

查看更多
时光乱了年华
3楼-- · 2018-12-31 11:01

Follow the steps of @rcdmk. Delete the android support v4.jar in YOUR project. It conflicts with the new updated version found in appcompat.

查看更多
刘海飞了
4楼-- · 2018-12-31 11:01

Since the Import dialouge is different in Android Studio 1.0.1, I could't get Svyatoslav Lobachs version to work.

Instead I downloaded "Android Support Repository" in the SDK Manager. Then added

dependencies {
...
compile "com.android.support:appcompat-v7:18.0.+"
}

to build.gradle. Worked for me.

查看更多
梦醉为红颜
5楼-- · 2018-12-31 11:03

http://developer.android.com/tools/support-library/setup.html has a bug. In Property->Java build path->'Project' and 'Order and Export', there should not be any jar's. Removing them, and checking 'Android Private Libraries' and 'Android Dependencies' solved my problem.

查看更多
情到深处是孤独
6楼-- · 2018-12-31 11:03

I had the same issue and even after importing/adding a jar/library as mentioned in the answers it would not solve the error. Out of frustration, I just created a new workspace and created a fresh android project and it automatically imported appcompat_v7 and there were no errors on clean and build. Didn't have to import a single jar/ library manually. Just FYI I am using eclipse Mars.1 Release (4.5.1) and was facing the exact same issue everytime I created a new android project.

查看更多
高级女魔头
7楼-- · 2018-12-31 11:04

For IntelliJ IDEA or Android Studio:

Add this to app.gradle build file

dependencies {
    compile "com.android.support:appcompat-v7:21.0.+"
} 

Replace -v:xx.0+, with your build target, if you have 19 platform then it must be like:

dependencies {
    compile "com.android.support:appcompat-v7:19.0.+"
}
查看更多
登录 后发表回答