我知道对 SVG 的官方支持直到 api 级别 23 才开始,但是我如何在最小 sdk 为 17 的应用程序中使用它?
我之前有过它的工作,我不知道发生了什么变化。我正在使用 AndroidSVG 库。
当我尝试构建生产 APK 时出现此错误
错误:(163)错误:可绘制类型的预期资源[ResourceType]
这是我收到此错误的 150 行代码之一
socialTypeImage.setImageResource(R.raw.icon_other_blue);
我不知道要提供什么其他信息,所以如果您需要更多信息,请告诉我。
谢谢
我不知道我的问题是否重复,但如果是,这些解决方案都不起作用。
buildscript {
repositories {
mavenCentral()
jcenter()
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' }
maven { url 'http://repository.codehaus.org' }
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0-alpha1'
//classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.14.7'
classpath 'com.google.code.ksoap2-android:ksoap2-android:3.1.1'
classpath 'org.codehaus.groovy.modules.http-builder:http-builder:0.5.2'
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' }
maven { url "https://repo.commonsware.com.s3.amazonaws.com" }
maven { url "http://repository.codehaus.org" }
maven { url 'https://maven.fabric.io/public' }
}
import groovyx.net.http.HTTPBuilder
def getBuildNumber(projectName) {
def http = new HTTPBuilder('http://eco-crossbar-620.appspot.com')
try {
def resp = http.get(path: "/${projectName}")
println "NEW BUILD NUMBER: ${resp.BODY}"
resp.BODY
} catch (ignored) {
println "ERROR RETRIEVING BUILD NUMBER"
0
}
}
def getWorkingBranch() {
def workingBranch = "build"
try {
workingBranch = """git --git-dir=${rootDir}/.git
--work-tree=${rootDir}/
rev-parse --abbrev-ref HEAD""".execute().text.trim()
} catch (ignored) {
// git unavailable or incorrectly configured
}
println "Working branch: " + workingBranch
return workingBranch.replaceAll("/", "-")
}
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 23
buildToolsVersion '23.0.2'
def build = getBuildNumber("lookcounter-android")
defaultConfig {
applicationId "com.lookcounter"
minSdkVersion 17
targetSdkVersion 23
versionCode 67
versionName "0.1.$versionCode"
vectorDrawables.useSupportLibrary = true
buildConfigField "String", "DEFAULT_USERNAME", "\"\""
buildConfigField "String", "DEFAULT_PASSWORD", "\"\""
resValue "string", "base64_encoded_public_key", "key"
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "String", "DEFAULT_USERNAME", "\"\""
buildConfigField "String", "DEFAULT_PASSWORD", "\"\""
debuggable false
jniDebuggable false
renderscriptDebuggable false
pseudoLocalesEnabled false
}
debug {
minifyEnabled false
debuggable true
jniDebuggable true
renderscriptDebuggable true
pseudoLocalesEnabled true
zipAlignEnabled false
}
}
signingConfigs {
dev {
storeFile file("../LookCounter.keystore")
storePassword "izpa55word"
keyAlias "lookcounterkey"
}
prod {
storeFile file("../LookCounter.keystore")
keyAlias "lookcounterprodkey"
}
}
productFlavors {
production {
buildConfigField "boolean", "DEV_BUILD", "false"
resValue "string", "app_name", "Lookcounter"
signingConfig signingConfigs.prod
versionCode 2
minSdkVersion 17
targetSdkVersion 23
}
dev {
buildConfigField "boolean", "DEV_BUILD", "true"
resValue "string", "app_name", "(DEV) Lookcounter"
signingConfig signingConfigs.dev
applicationId 'com.lookcounter'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
android.applicationVariants.all { variant ->
if (variant.buildType.name.equals("release")) {
variant.assemble.doLast {
def apkName
def dirName = System.getProperty("user.home") + "/Desktop/lookcounter/apk"
if (variant.name.contains("production")) {
dirName += "PlayStore"
apkName = "Lookcounter_v${versionCode}_PlayStore_${versionName}.apk"
} else {
dirName += "dev"
def branchName = getWorkingBranch()
if (branchName.equals("develop")) {
apkName = "Lookcounter_v${versionCode}_DEV_${build}.apk"
} else {
apkName = "Lookcounter_v${versionCode}_DEV_${branchName}_${build}.apk"
}
}
copy {
def source = variant.outputs.get(0).getOutputFile()
from source
into dirName
include source.name
rename source.name, apkName
println "Output APK copied to $dirName/$apkName"
}
}
}
}
}
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// compile "com.dev.sacot41:scviewpager:0.0.4"
compile project(':androidSVG')
compile files('../libraries/PriorityDeque-1.0.jar')
compile project(':cropper')
testCompile 'junit:junit:4.12'
// Possibly Keep
compile('com.doomonafireball.betterpickers:library:1.6.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
// KEEP
compile('com.nostra13.universalimageloader:universal-image-loader:1.9.5') {
exclude group: 'com.android.support', module: 'support-v7'
}
compile('com.twitter.sdk.android:tweet-composer:0.7.3@aar') {
transitive = true;
}
compile('com.crashlytics.sdk.android:answers:1.3.6@aar') {
transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true;
}
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:support-v4:23.2.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.jakewharton:butterknife:5.1.2'
compile 'org.apache.commons:commons-lang3:3.1'
compile 'com.github.clans:fab:1.6.2'
compile 'com.facebook.android:facebook-android-sdk:3.21.1'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.google.code.ksoap2-android:ksoap2-android:3.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:support-vector-drawable:23.2.0'
compile 'com.android.support:animated-vector-drawable:23.2.0'
}