Stop Android Studio from using the support library

I am trying to run an Android project in Android Studio so as NOT to use the support library. My problem is that when I use fragments, it expects support fragments and causes the application to crash.

My Min SDK is 14, and my target SDK is 19. I understand that since I am targeting these versions, I do not need a support library. Correct me if I am wrong.

I am trying to fix this error java.lang.ClassCastException: com.google.android.gms.maps.MapFragment cannot be cast to android.support.v4.app.Fragment . And I know that I can fix it just by using SupportMapFragment . But I do not want to do this. I want to use a regular MapFragment

So, my main question is: how can I make it stop waiting for fragments of the support library and just use regular fragments. I also had this problem with other fragments, not just the map.

+7
java android android-fragments android-support-library
source share
3 answers

If you removed the support library from build.gradle and there is no file in the libs folder, are you sure you want to delete the import?

From the error message, it looks like you will have the following import (otherwise the error will not know about trying to throw fragments in support) at the top of your class:

import android.support.v4.app.Fragment;

Remove this, replace it with:

import android.app.Fragment;

Do this with all the support links.

+1
source share

I am surprised that no one can give you a direct answer. Hope my answer helps.

So, so that Android Studio does not use the support library, especially the notorious AppCompat v7, follow these steps:

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

2) Delete the line labeled 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 android: theme application to: android:theme="@android:style/Theme.Holo.Light"

5) Go into your activity and delete 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 continue the recovery until you earn it, and then run the project to ensure that nothing works and your links are in order.

For me, I got errors indicating that the application: ShowAsAction is not supported or not. I had to change it to android: ShowAsAction. Just make sure that for any error, read it carefully and follow the recommendations in the small dialog boxes that appear next to the error line.

+9
source share

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

your project name → libs

uninstall android-support-v4.jar. If you do, delete all import files using android.support.v4 and replace them with appropriate (non-supporting) imports.

+1
source share

All Articles