package android.support.v4.app does not exist ; in Android studio 0.8

前端 未结 12 1554
我在风中等你
我在风中等你 2020-12-01 05:24

I\'ve recently updated the android studio IDE to 0.8 to work with the new android L SDK. To start I imported a finished android project that receives no errors in the older

相关标签:
12条回答
  • 2020-12-01 05:25

    [for some reasons this answer is related to Eclipse, NOT Android Studio!]

    Have you tried setting the support libraries to your class path? This link from the Android Developer's website has some info on how to do that.

    Try following these steps from the website:

    Create a library project based on the support library code:

    • Make sure you have downloaded the Android Support Library using the SDK Manager.
    • Create a library project and ensure the required JAR files are included in the project's build path:

      • Select File > Import.
      • Select Existing Android Code Into Workspace and click Next.
      • Browse to the SDK installation directory and then to the Support Library folder. For example, if you are adding the appcompat project, browse to /extras/android/support/v7/appcompat/.
      • Click Finish to import the project. For the v7 appcompat project, you should now see a new project titled android-support-v7-appcompat.
      • In the new library project, expand the libs/ folder, right-click each .jar file and select Build Path > Add to Build Path. For example, when creating the the v7 appcompat project, add both the android-support-v4.jar and android-support-v7-appcompat.jar files to the build path.
      • Right-click the library project folder and select Build Path > Configure Build Path.
      • In the Order and Export tab, check the .jar files you just added to the build path, so they are available to projects that depend on this library project. For example, the appcompat project requires you to export both the android-support-v4.jar and android-support-v7-appcompat.jar files.
      • Uncheck Android Dependencies.
      • Click OK to complete the changes.
    • You now have a library project for your selected Support Library that you can use with one or more application projects.

      • Add the library to your application project:
      • In the Project Explorer, right-click your project and select Properties.
      • In the category panel on the left side of the dialog, select Android.
      • In the Library pane, click the Add button.
      • Select the library project and click OK. For example, the appcompat project should be listed as android-support-v7-appcompat.
      • In the properties window, click OK.
    0 讨论(0)
  • 2020-12-01 05:25

    tl;dr Remove all unused modules which have a dependency on the support library from your settings.gradle.

    Long version:

    In our case we had declared the support library as a dependency for all of our modules (one app module and multiple library modules) in a common.gradle file which is imported by every module. However there was one library module which wasn't declared as a dependency for any other module and therefore wasn't build. In every few syncs Android Studio would pick that exact module as the one where to look for the support library (that's why it appeared to happen randomly for us). As this module was never used it never got build which in turn caused the jar file not being in the intermediates folder of the module.

    Removing this library module from settings.gradle and syncing again fixed the problem for us.

    0 讨论(0)
  • 2020-12-01 05:29

    None of the above solutions worked for me. What finally worked was:

    Instead of

    import android.support.v4.content.FileProvider;
    

    Use this

    import androidx.core.content.FileProvider;
    

    This path is updated as of AndroidX (the repackaged Android Support Library).

    0 讨论(0)
  • 2020-12-01 05:36

    IN ECLIPSE LUNA I ve resolved this issue by using contet menu on my Project : ANdroid Tools > Add support Library ...

    0 讨论(0)
  • 2020-12-01 05:40

    In my case the error was on a module of my project.I have resolved this with adding

    dependencies {
        implementation 'com.android.support:support-v4:20.0.+'
    }
    

    this dependency in gradle of corresponding module

    0 讨论(0)
  • 2020-12-01 05:41

    error: package android.support.v4.content does not exist import android.support.v4.content.FileProvider;

    using jetify helped to solve .

    from jcesarmobile' s post --- >https://github.com/ionic-team/capacitor/pull/2832

    Error: "package android.support.* does not exist" This error occurs when some Cordova or Capacitor plugin has old android support dependencies instead of using the new AndroidX equivalent. You should report the issue in the plugin repository so the maintainers can update the plugin to use AndroidX dependencies.

    As workaround you can also patch the plugin using jetifier

    npm install jetifier

    npx jetify

    npx cap sync android

    0 讨论(0)
提交回复
热议问题