IDE “Cannot Resolve @style/Theme.Appcompat” when using v7 compatibility support theme

后端 未结 13 604
北恋
北恋 2020-12-14 06:02

This is not really a huge issue, as my project still builds and runs correctly (using gradle), but I\'m having trouble getting Android Studio to recognize the application co

相关标签:
13条回答
  • 2020-12-14 06:40

    I changed from:

    classpath 'com.android.tools.build:gradle:+'

    to:

    classpath 'com.android.tools.build:gradle:2.2.3'

    and now it's working!

    0 讨论(0)
  • 2020-12-14 06:42

    I know i replied late, but this answer might help futures visitors.

    • Change from Gradle 0.12.+ to 0.12.1 and it will works.

      classpath 'com.android.tools.build:gradle:0.12.1'
      
    0 讨论(0)
  • 2020-12-14 06:43

    Don't add the library to the Java Build Path, add the library (as a project) in Settings>Android>Libraries>Add Library.

    0 讨论(0)
  • 2020-12-14 06:45

    I had this same issue. Sounds like you have the V7 jar file compiling fine but you are probably missing the xml resource needed.You need to manually include the 'Theme.xml' provided with the V7 package. Here is what I did to fix it.

    Look under:Adding libraries with resources http://developer.android.com/tools/support-library/setup.html

    The directions provided here aren't very clear because it doesn't tell you to bring any resources in. (maybe a bug in Android Studio?)

    Here is what I did:

    1. Update your SDK in the manager and be sure to include 'Android support repository' in extra's
    2. Go to SDK in file explorer (Finder on mac) track down the extra's folder (..\sdk\extras\android\support\v7\appcompat\res\values on Windows). Somewhere in there is a "themes.xml" and "themes_base.xml'. Copy both of these files.
    3. In your project paste the files into 'values' directory
    4. do a rebuilt and that did the trick for me.
    0 讨论(0)
  • 2020-12-14 06:45

    A common problem. In my case this works:

    In "android-support-v7-appcompat" project:

    -Delete “android-support-v7-appcompat” from Package explorer.
    -Import again and check “Copy into workspace”
    -In Properties -> Android -> in Project build target, uncheck Android 2.2 and check Android 4.1.2
    -In Java build path, uncheck if you have any .jar library, and uncheck the Dependences
    

    In other hand, the proyect that uses “android-support-v7-appcompat”

    in Propiedades -> Android add the library, but uncheck "IsLibrary”.
    -In Android -> Project build tarjet check Android 4.0.
    -In "Java Build Path" -> Order and Export -> Unchecked the .jar library
    -Finally do a “Project -> Clean” both projects 
    
    0 讨论(0)
  • 2020-12-14 06:46

    Downgrading build:gradle version 2.3.3 to 2.2.3 worked after struggling for hours!

    classpath 'com.android.tools.build:gradle:2.2.3'
    

    gradle-wrapper.properties:

    distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
    
    0 讨论(0)
提交回复
热议问题