Stop Android Studio from using Support Library

僤鯓⒐⒋嵵緔 提交于 2019-12-05 05:06:23

If you've removed the support library from the build.gradle, and there's no file in the libs folder, have you made sure to delete the imports?

From the error message, it looks like you'll have the following import (else the error wouldn't know about trying to cast to a support Fragments) at the top of your class:

import android.support.v4.app.Fragment;

Delete this, replace it with:

import android.app.Fragment;

Do this with all the support references.

I'm surprised no one can still give you a straight forward answer. I hope my response will help.

So to stop Android Studio from using support library especially the infamous AppCompat v7, follow these few steps:

1) Gradle Scripts > build.gradle(Module: app)

2) Remove the line that says compile 'com.android.support:appcompat-v7:22.1.1'

3) res/values/styles.xml > change the parent value to: parent="@android:style/Theme.Holo.Light"

4) AndroidManifest.xml > change the application android:theme to: android:theme="@android:style/Theme.Holo.Light"

5) Go into your activities and remove the line that imports the support library. Change it to: import android.app.Activity;

6) Now in the menu bar: Build > ReBuild Project. Correct any errors then keep rebuilding until you get it to work, then run your project to ensure nothing crashes and your references are in order.

For me I got errors stating that I app:ShowAsAction is not supported or so. I had to change it to android:ShowAsAction. Just Make sure that for any error, you read it carefully and follow the suggestions in the little dialogues boxes that pop up beside the error line.

To completly remove the suppport library, go to the package explorer window, and in

your project name -> libs

remove the android-support-v4.jar. If you do that, remove all imports startng with android.support.v4 and replace them with apropriate (non support) imports.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!