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:10

Its bit late but here is how I get it done in AndroidStudio !

Right click on app to goto properties Right click on app to goto properties

Go to Dependencies and click on '+' sign and choose library dependency Go to Dependencies and click on '+' sign and choose library dependency Choose appcompat-v7 Choose appcompat-v7

查看更多
回忆,回不去的记忆
3楼-- · 2018-12-31 11:13

IntelliJ IDEA solution.

1. Run Android SDK Manager and install the latest SDK and Android Support Libarary. The version of SDK and Android Support Libarary should be the same! 23 in my case. Another variants will give you the errors.
enter image description here
2. Change SDK version of your IDEA project to the last one you installed in previous step. (ps. you may not use Maven).
enter image description here

3. Add new Module from existing sourse to your IDEA project.
enter image description here

4. Add AppCompat project. !!! Should be under the last SDK too! (ps. Say "Yes" anywhere in process of this step)
enter image description here

5. Open settings of your main Project Module and add to it next 3 dependecies:

5.1. Module Dependency. Chose android-support-v7-appcompat
enter image description here

5.2. 2 pc. Library Dependencies. Add android-sdk\extras\android\support\v7\appcompat\libs\android-support-v4.jar and android-support-v4\android-support-v7-appcompat.jar
enter image description here

In total it will be:
enter image description here

6. Very important!!!
Add theme with prefix @style (not another!).
enter image description here



Android Studio solution.

1. Run Android SDK Manager and install the latest SDK and Android Support Libarary. The version of SDK and Android Support Libarary should be the same! 23 in my case. Another variants will give you the errors.
enter image description here

2. Add next to build.gradle

dependencies {
    compile 'com.android.support:appcompat-v7:23.0.1'
} 

P.S. If you are new in Android developing, I strongly recomend you move to Android Studio & Gradle right now - you will get the simplest way of managing your android app.

查看更多
余生无你
4楼-- · 2018-12-31 11:13

you need reference $ANDROID_SDK/extras/android/support/v7/appcompat

查看更多
千与千寻千般痛.
5楼-- · 2018-12-31 11:13

You had better make new project with any name , then use appcompat_v7 that program make new .

Right Click Project-> properties->Android

In the section library Add and choose library appcompat.

查看更多
闭嘴吧你
6楼-- · 2018-12-31 11:13

In my case the problem occurred since I wanted to use a SDK that doesnt include the required library. When I increased the min. SDK level the problem dissappeared. Of course directly including the library's itself, should remove the error as well.

查看更多
人间绝色
7楼-- · 2018-12-31 11:13

Forget everything. Just use the appcompat library downloaded using the Android Studio. It has all the missing definitions. No matter whether you are using in Eclipse or not.

查看更多
登录 后发表回答