Desmond DAI
Desmond DAI

Reputation: 495

Android - able to use AppCompatActivity without support library

In my application's build.gradle, the dependencies are:

compile 'com.android.support:support-v4:22.0.0'
compile 'com.android.support:recyclerview-v7:22.0.0'
compile 'com.android.support:cardview-v7:22.0.0'
compile 'com.android.support:support-v13:22.0.0'
compile 'com.android.support:palette-v7:22.0.0'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:percent:22.2.0'
compile 'com.google.android.gms:play-services:7.0.0'

Without compile 'com.android.support:appcompat-v7:22.0.0', I can still use AppCompatActivity and ActionBar that are from support v7 library. Any answers explaining the reasons behind will be appreciated :)

Upvotes: 4

Views: 684

Answers (2)

Vishal Patoliya ツ
Vishal Patoliya ツ

Reputation: 3238

You can use Updated design support libraries like

compile 'com.android.support:design:23.1.1'

compile 'com.android.support:appcompat-v7:23.1.1'

Upvotes: 0

Gabriele Mariotti
Gabriele Mariotti

Reputation: 363459

You are using

compile 'com.android.support:design:22.2.1'

It has a dependency with 'com.android.support:appcompat-v7:22.2.1'

It means that your project has the appcompat library also if you haven't added it in the build.gradle, so you can use AppCompatActivity and ActionBar

Here the pom file:

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.android.support</groupId>
  <artifactId>design</artifactId>
  <version>22.2.1</version>
  <packaging>aar</packaging>
  <dependencies>
    <dependency>
      <groupId>com.android.support</groupId>
      <artifactId>appcompat-v7</artifactId>
      <version>22.2.1</version>
      <type>aar</type>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.android.support</groupId>
      <artifactId>support-v4</artifactId>
      <version>22.2.1</version>
      <type>aar</type>
      <scope>compile</scope>
    </dependency>
  </dependencies>
</project>

Also you can display the dependency tree with the command gradle dependencies.
You can read more info here. (src: Using gradle to find dependency tree)

Upvotes: 5

Related Questions