You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

导入API18的Eclipse ADT项目至AndroidStudio后Gradle构建Material样式报错求助

Fix: "resource android:style/TextAppearance.Material not found" After Importing Eclipse ADT Project to Android Studio

Hey there, let's tackle this error you're seeing. Those missing TextAppearance.Material resources are a common issue when importing old Eclipse projects (targeting API 18) into Android Studio, and here's why and how to fix it:

What's Causing This?

Material Design-related styles like TextAppearance.Material were first introduced in Android 5.0 (API Level 21). Your project is set to target API 18, but the auto-generated Gradle config from the import might be pulling in newer support libraries or using a higher compile SDK that references these incompatible resources.


Step 1: Fix Your Module's build.gradle Config

Open your app-level build.gradle file (under app/) and adjust these key settings:

  1. Set a Compatible Compile SDK Version
    You can keep supporting API 18 as your minimum, but set compileSdkVersion to 21 or higher (I recommend 28 for better compatibility with older support libraries):

    android {
        compileSdkVersion 28
        defaultConfig {
            applicationId "your.package.name"
            minSdkVersion 18
            targetSdkVersion 18 // You can upgrade this to 28 if you want, but 18 works too
            versionCode 1
            versionName "1.0"
        }
    }
    
  2. Update Support Library Versions
    From your import summary, android-support-v4.jar was replaced with com.android.support:support-v4:18.0.0—this version is way too old. Match it to your compileSdkVersion:

    dependencies {
        // For SDK 28, use this:
        implementation 'com.android.support:support-v4:28.0.0'
        // If you're using appcompat, add this too (same version):
        // implementation 'com.android.support:appcompat-v7:28.0.0'
    }
    

    Pro tip: If you use appcompat-v7, its version must match your compileSdkVersion to avoid resource conflicts.

  3. Pin Google Play Services Version
    The import used com.google.android.gms:play-services:+, which pulls the latest version (incompatible with API 18). Use a stable version that works with your compile SDK:

    // For SDK 28, this version works well:
    implementation 'com.google.android.gms:play-services:17.0.0'
    // Even better: Only import the modules you need (e.g., maps, location) to reduce app size
    // implementation 'com.google.android.gms:play-services-maps:17.0.0'
    

Step 2: Check Your App's Theme

Open res/values/styles.xml and make sure your theme uses a backward-compatible parent, not a Material-only one:

<!-- Avoid Theme.Material (API 21+ only) -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Your custom theme attributes go here -->
</style>

If your original Eclipse project used Theme.Holo styles, you can keep using those too—but AppCompat themes offer better cross-version support.


Step 3: Clean & Rebuild

After making these changes:

  1. Go to Build > Clean Project
  2. Then Build > Rebuild Project
  3. If you still have issues, try File > Invalidate Caches... > Invalidate and Restart to clear Android Studio's cache.

If It Still Doesn't Work, Share These Details

If the above steps don't fix the error, I'll need a bit more info to help:

  • Full content of your app-level build.gradle file
  • Contents of res/values/styles.xml and res/values-v21/styles.xml (if it exists)
  • Any other library dependencies your project uses that might reference Material styles

内容的提问来源于stack exchange,提问作者me.at.coding

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 09:07:32