[英]Getting error: package android.support.v7.app does not exist import android.support.v7.app.ActionBar
構建我的父項目的 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'
}
構建模塊項目的 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
}
}
我可以獨立運行父項目,也可以獨立運行模塊項目
但是當將父項目中的庫項目作為模塊導入時......我得到以下錯誤(有很多錯誤)
error: package android.support.v7.app does not exist
import android.support.v7.app.ActionBar;
^
這是因為您的父項目使用 AndroodX 庫,而您的模塊使用 Android 支持庫。 遷移您的模塊項目以使用 AndroidX 庫。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.