[英]RenderScript package does not exist - although added to build.gradle
我(再次)在我的項目中遇到支持庫問題。 我想在我的應用程序中使用RenderScript庫進行一些圖像處理。 這個項目是我從別人手中接過的,這是我迄今為止的第一個Android Studio / gradle項目。 因此,我仍然缺乏經驗,特別是關於所有這些gradle配置文件。
問題是:我已將以下行包含在app模塊中的build.gradle文件中:
defaultConfig {
...
renderscriptTargetApi Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
renderscriptSupportModeEnabled true
...
}
project.ANDROID_BUILD_TARGET_SDK_VERSION已在gradle.properties中設置為15和22,這沒有什么區別。
但是,每當我編譯項目時,我總會得到這樣的錯誤:
Error:(12, 39) error: package android.support.v8.renderscript does not exist
真正奇怪的是:如果我從頭創建一個新項目並在app模塊中的build.gradle中包含相同的兩行,我可以毫無問題地使用RenderScript類。 所以我認為這不是我的一般配置的問題,但必須以某種方式與項目相關。 我只是不確定任何事情都會導致這樣的行為並禁用包,盡管gradle腳本中的行正確。
有一件事可能很重要,讓我從一開始就想知道:當我第一次將這些行添加到gradle腳本並在我的類文件中創建import語句時,Android工作室詢問它是否應該將一些支持庫jar文件作為庫導入。 我不知道為什么要這樣做,因為據我所知,支持類不需要任何額外的設置。 我同意導入它,但正如我上面所說的那樣,包和類仍然無法找到。
從我的項目完整的build.gradle文件(即不工作):
apply plugin: 'com.android.application'
android {
compileSdkVersion Integer.parseInt(project.ANDROID_COMPILE_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
applicationId 'com.some.app'
multiDexEnabled = true
renderscriptTargetApi Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
renderscriptSupportModeEnabled true
minSdkVersion Integer.parseInt(project.MIN_SDK)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
}
signingConfigs {
signingConfigs {
debug {
storeFile file('<some file>')
keyAlias 'xxx'
keyPassword 'xxx'
storePassword 'xxx'
}
release {
storeFile file('<some file>')
keyAlias 'xxx'
keyPassword 'xxx'
storePassword 'xxx'
}
}
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.release
debuggable false
jniDebuggable false
zipAlignEnabled true
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile 'com.android.support:appcompat-v7:22.2.0+'
compile 'com.android.support:support-v4:22.2.0+'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':firebase_plugin')
compile project(':geofire')
compile 'com.android.support:multidex:1.0.0'
compile files('libs/acra-4.5.0.jar')
}
來自虛擬項目的app模塊的build.gradle文件( 確實有效):
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.self.bitmapscaletest"
minSdkVersion 15
targetSdkVersion 22
renderscriptTargetApi 15
renderscriptSupportModeEnabled true
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
}
較大的項目有多個模塊,這可能是個問題嗎? 我是否還必須調整其他模塊的gradle腳本?
先感謝您!
發布后不久我似乎解決了它。 不同的模塊確實似乎是問題所在。 將這兩行添加到其他模塊的gradle.build后,應用程序將編譯並啟動。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.