简体   繁体   English

获取错误:包 android.support.v7.app 不存在 import android.support.v7.app.ActionBar

[英]Getting error: package android.support.v7.app does not exist import android.support.v7.app.ActionBar

Build Gradle of My Parent project:构建我的父项目的 Gradle:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationId "com.cnx.dictionarytool"
        minSdkVersion 14
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

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

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

BUILD Gradle of module project::构建模块项目的 Gradle::

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}

apply plugin: 'com.android.application'

repositories {
    jcenter()
    google()
}
configurations {
    smallicu
}
dependencies {
    implementation 'com.android.support:appcompat-v7:25.3.1'
    implementation 'com.android.support:design:25.3.1'
    implementation group: 'com.ibm.icu', name: 'icu4j', version: '58.2'
    // Note: you can just replace "smallicu" by implementation
    // and remove the "compile files" part if you do not
    // care about the size of the apk
    /*smallicu 'com.ibm.icu:icu4j:57.1'
    implementation files("$buildDir/icu4j-57.1.small.jar") {
        builtBy 'makesmallicu'
    }*/
}

/*task makesmallicu (type:Exec, dependsOn: configurations.smallicu) {
    inputs.file "mksmallicu.sh"
    inputs.file "${configurations.smallicu.resolve()[0]}"
    outputs.dir "$buildDir"
    outputs.file "$buildDir/icu4j-57.1.small.jar"
    // necessary due to gradle bug: GRADLE-2638
    new File("$buildDir").mkdirs()
    commandLine "./mksmallicu.sh", "${configurations.smallicu.resolve()[0]}", "$buildDir/icu4j-57.1.small.jar"
}*/

def utildir = hasProperty("quickdicUtilDir") ? quickdicUtilDir : "Util"

android {
    compileSdkVersion 29
    lintOptions {
        disable "MissingTranslation"
    }
    buildTypes {
        debug {
            applicationIdSuffix ".debug"
        }
        release {
            minifyEnabled true
            shrinkResources true
        }
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src', utildir + "/src"]
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
    defaultConfig {
        applicationId 'de.reimardoeffinger.quickdic'
        targetSdkVersion 29
        resConfigs "de", "es", "fr", "it", "ja", "pt", "pt-rBR", "ru", "zh-rCN"
        minSdkVersion 14
    }
}

I am able to run Parent project independently and I am also able to run module project independently我可以独立运行父项目,也可以独立运行模块项目

But when import library project in parent project as module.... I get below error (There are many errors such)但是当将父项目中的库项目作为模块导入时......我得到以下错误(有很多错误)

error: package android.support.v7.app does not exist
import android.support.v7.app.ActionBar;
                             ^

This is because your parent project uses AndroodX libraries while your module uses Android Support Libraries.这是因为您的父项目使用 AndroodX 库,而您的模块使用 Android 支持库。 Migrate your module project to use AndroidX libraries.迁移您的模块项目以使用 AndroidX 库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM