使用Eclipse+ADT替代Android Studio遇编译错误求助
Hey there, I totally get the frustration of sticking with ADT/Eclipse because your machine can't handle Android Studio—been there, done that. Let's break down how to fix this Theme.AppCompat.Light error step by step:
Why this happens
Theme.AppCompat.Light isn't part of the core Android SDK—it comes from the Android Support Library (the older precursor to AndroidX). If this library isn't installed in your SDK, or your project isn't linked to it, Eclipse won't find the theme resource.
Step 1: Install the required Support Library via SDK Manager
- Open the SDK Manager in Eclipse: Go to
Window > Android SDK Manager - Scroll down to the Extras category (it's usually at the bottom)
- Make sure both
Android Support LibraryandAndroid Repositoryare checked. If they're not installed, click "Install packages" to get them.- Note: If you're using a really old SDK (like API 21 or lower), you'll need the matching version of the Support Library—don't worry, the SDK Manager will grab the right one for your SDK level.
Step 2: Link the AppCompat Library to your project
The Support Library comes with a ready-to-use library project for AppCompat:
- Navigate to your SDK installation folder, then go to
extras/android/support/v7/appcompat - Import this folder into Eclipse:
File > Import > Android > Existing Android Code Into Workspace - Right-click your main project, select
Properties > Android - Under the Library section, click
Addand choose theappcompat-v7project you just imported. Click OK to save.
Step 3: Double-check your theme configuration
- Open your
res/values/styles.xmlfile. If you're using a custom theme, make sure it inherits fromTheme.AppCompat.Lightlike this:<style name="AppTheme" parent="Theme.AppCompat.Light"> <!-- Your custom style attributes go here --> </style> - Verify your
AndroidManifest.xmlreferences this theme in the<application>tag:<application ... android:theme="@style/AppTheme">
Step 4: Clean and rebuild your project
Eclipse can be finicky with cached resources. Do this to rule out cache issues:
- Go to
Project > Clean, select your project, and click "OK" - Once the clean finishes, rebuild your project by selecting
Project > Build Project
Bonus tip: Match ADT and SDK versions
If you're still having issues, make sure your ADT plugin version matches your SDK version. For example, if you're using SDK API 22, install ADT 22.x—mismatched versions can cause weird compatibility bugs.
That should get your project building without that theme error. Let me know if you hit any snags along the way!
内容的提问来源于stack exchange,提问作者Constantin Müller

