Using Android.Support.V7.Widget.Cardview in My Project (Eclipse)

Using android.support.v7.widget.CardView in my project (Eclipse)

I finally found a way to use CardView in ADT/Eclipse. It's actually pretty easy:

  1. Create a new project in Android Studio
  2. Add the CardView dependency as explained in the other answers to this question
  3. Open ADT and create a new library project with package name android.support.v7.cardview
  4. Delete all resources ADT auto-created
  5. Find the exploded-aar folder in Android Studio and copy the following files to these locations:
    • res/values/values.xml to the same location in your ADT project
    • classes.jar to libs/ in your ADT project
    • AndroidManifest.xml use it to replace the auto-generated manifest in ADT

  6. Add classes.jar to the build path and make sure it's exported
  7. Add a reference to the library project in the project you want to use CardView in. You can follow the steps provided under Adding libraries with resources here: https://developer.android.com/tools/support-library/setup.html

As an alternative to having to create a new Android Studio project in order to get the AAR's content, you could also simply find and unzip the AAR from the local maven repo. Just follow the steps provided by Andrew Chen below.

Please note the CardView library might not be available in source- and ADT-compatible-form because it's still only a preview and a WIP. As there might be bug fixes and improvements in following releases, it's important to keep the library up-to-date, which is easy using the Gradle dependency, but must be done manually when using the steps provided above.

Trouble importing android.support.v7.widget.CardView into Eclipse

Adding the library

Gradle

compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:cardview-v7:22.0.0'

Eclipse

Using android.support.v7.widget.CardView in my project (Eclipse)

Proper LinearLayout

As the error said, a LinearLayout needs a layout_width and a layout_heighth. Always.

Error inflating class and android.support.v7.widget.CardView

I guess I can answer my own question.

Go to File -> Import -> Existing Android code into workspace --> Browse (Go to sdk/extras/android/support/v7/cardview) --> Click ok --> Click Finish

Your project explorer will now show cardview as a project.

Right click on cardview project --> Properties --> Android(Left Pane) --> Enable isLibrary (tick the checkbox) --> Apply --> ok

Now Right click on your project --> Properties --> Android(Left pane) --> Add (under library) --> cardview --> apply --> ok

Now right click on your project again --> build path --> configure build path --> Under projects tab, add cardview

You are done.

Error inflating android.support.v7.widget.CardView

At first add setContentView();

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main) //missing
val recyclerView = findViewById(R.id.contactsView) as RecyclerView

Use Exact version App Level build.gradle

 dependencies {

implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
}

FYI

You are using very old versions. If you want to use latest then libraries will not work unless you make the following changes in your app:

  • Upgrade compileSdkVersion to 28 or later.
  • Update your app to use Jetpack (AndroidX).

AndroidX replaces the original support library APIs with packages in the androidx namespace. Read official guideline about AndroidX Overview.

Your Cardview & recyclerview will

 implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'

android.support.v7.widget.CardView (Fix Build Path, Edit XML, Create Class) Using Android Studio 3.4

Can you try using

 implementation 'androidx.cardview:cardview:1.0.0'

Instead and

androidx.cardview.widget.CardView

In XML?

how to use androidx library instead of android.support.v7.widget.CardView

You can use new cardview dependency androidx.cardview:cardview:1.0.0.

And in xml use <androidx.cardview.widget.CardView/> instead of <android.support.v7.widget.CardView/>.

Importing CardView and RecyclerView (Android 5.0) in my existing project (eclipse)

They are also available as Android library projects now, in extras/android/support/v7/ of your SDK installation. Make a copy of those projects elsewhere on your hard drive, import them into Eclipse, then reference them as libraries from your app following the instructions in the documentation.



Related Topics



Leave a reply



Submit