【问题标题】:Import android.support.v7.app cannot be resolved导入android.support.v7.app 无法解决
【发布时间】:2015-05-24 11:58:30
【问题描述】:

导入时出现无法解决的错误 android.support.v7.app.Fragment。

我尝试了不同线程中给出的所有解决方案。 我是不是遗漏了什么,请帮忙。

  1. 我已经下载了安卓支持库。
  2. minSdkVersion 14 targetSdkVersion 14
  3. 添加依赖库

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:22.1.1'
        compile 'com.android.support:support-v4:22.1.1'
    }
    
  4. 同步build.gradle文件(右键文件-->同步 'build.gradle') 并清理你的项目(构建 --> 清理项目) 更改后。

我仍然无法重新喜欢这个。请帮忙

build.gradle(模块:app)

    apply plugin: 'com.android.application'
    android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.android.effectivenavigation"
        minSdkVersion 14
        targetSdkVersion 14
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.android.support:support-v4:22.1.1'
}

AndroidManifest.xml

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.android.effectivenavigation"
        android:versionCode="1"
    android:versionName="1.0">

    <uses-sdk android:minSdkVersion="14" />

    <application android:label="@string/app_name"
        android:icon="@drawable/ic_launcher"
        android:theme="@android:style/Theme.Holo.Light.DarkActionBar">

        <activity android:name=".MainActivity" android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".CollectionDemoActivity" android:label="@string/demo_collection" />

    </application>
</manifest>

【问题讨论】:

  • 你的电脑上是否安装了22.1.1版本,查看SDK管理器?
  • 是的sdk有android支持库22.1.1版本。

标签: android android-studio


【解决方案1】:

替换

 import android.support.v7.app.NotificationCompat;

 import android.support.v4.app.NotificationCompat;

【讨论】:

    【解决方案2】:

    抱歉,我无法发表评论。 尝试使用

    compile 'com.android.support:support-v4:21.0.+'
    

    低版本帮我解决了这个问题。

    【讨论】:

    • 还是一样...不走运:(
    【解决方案3】:

    右键单击您的项目,选择打开模块设置,然后在模块设置窗口中,点击Modules/app。然后在窗口右侧选择Dependencies TAB。然后按加号并选择“库依赖项”。 在新显示的窗口中,选择您的支持库并单击确定

    【讨论】:

    • 我只通过这个路径添加了库依赖
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-08
    • 1970-01-01
    • 1970-01-01
    • 2014-09-19
    • 1970-01-01
    相关资源
    最近更新 更多