AppCompatActivity cannot be resolved to a type

2019-06-14 14:22发布

问题:

I am trying to add Theme to my project. It requires appcompat v7.

I added the support library according to the steps mentioned in the Android developer website. After searching a lot I came to know that support library v4 will conflict with support library v7.

So I removed the android library v4 from my project. Because of that now I got the NotificationCompat error(import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat.Builder;).

What I have to do? Please someone help me in resolving the issue. Thanks in advance

回答1:

I came to know that support library v4 will conflict with support library v7

It is wrong.

AppCompat v7 has a dependency with support-v4.
You can check the pom file.

 <groupId>com.android.support</groupId>
 <artifactId>appcompat-v7</artifactId>
 <version>23.0.1</version>
 <packaging>aar</packaging>
 <dependencies>
    <dependency>
      <groupId>com.android.support</groupId>
      <artifactId>support-v4</artifactId>
      <version>23.0.1</version>
      <type>aar</type>
      <scope>compile</scope>
    </dependency>
  </dependencies>

You can use without problems the appcompat and the support-v4.