错误:程序包android.support.v7.app不存在问题

时间:2019-12-13 15:35:40

标签: java android

我不断收到这样的错误,怎么了?还有其他问题吗? 这给出了前三个红色的bug!

import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppcompatActivity;
import android.support.annotation.IdRes;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar

;

我是android开发的新手,并且我一直在使用命令行工具来创建android项目。我按照android开发人员指南中给出的所有说明进行操作。但是,他们更专注于IDE用户。

findbugs {
    sourceSets = []
    ignoreFailures = false
}

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "video.compress.optimizasyon"
        minSdkVersion 19
        targetSdkVersion 29
        versionCode 20
        versionName "0.20"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    lintOptions {
        disable "GoogleAppIndexingWarning"
        disable "MissingTranslation"
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    // ACRA depends on Java 8
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}    
dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'androidx.appcompat:appcompat:1.1.0'
        implementation 'androidx.browser:browser:1.0.0'
        implementation 'com.google.android.material:material:1.0.0'
        implementation 'androidx.legacy:legacy-support-v4:1.0.0'
        implementation 'com.android.support:appcompat-v7:27.0.0'
        implementation 'com.crystal:crystalrangeseekbar:1.1.3'
        implementation 'commons-io:commons-io:2.6'
        implementation group: 'com.google.guava', name: 'guava', version: '24.1-jre'
        implementation 'com.nononsenseapps:filepicker:4.2.1'
        implementation 'com.simplecityapps:recyclerview-fastscroll:1.0.18'
        implementation group: 'org.javatuples', name: 'javatuples', version: '1.2'
        implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.8'
        implementation 'ch.acra:acra:4.11'
        implementation 'com.google.android.gms:play-services-ads:18.2.0'
        implementation 'com.google.firebase:firebase-core:17.2.0'
        implementation 'com.google.firebase:firebase-analytics:17.2.0'
    } 

1 个答案:

答案 0 :(得分:0)

您正在使用androidx库。

删除此依赖项,因为您使用的是材料组件库:

implementation 'com.android.support:appcompat-v7:27.0.0'

然后更改这些类(代码和布局):

import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppcompatActivity;
import android.support.annotation.IdRes;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.annotation.IdRes;
import androidx.appcompat.app.ActionBar;
//import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar

完整的class mapping