在最近升级我的android工作室之后,我无法再构建我的项目了.
每次执行构建时,我都会遇到以下错误:
error: resource drawable/splash_screen (aka com.whereisthemonkey.nowalism:drawable/splash_screen) not found.
Message{kind=ERROR, text=error: resource drawable/splash_screen (aka com.whereisthemonkey.nowalism:drawable/splash_screen) not found., sources=[C:\Users\Lucas\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\cf575568f869a44c685b16e47de83a28\res\values\values.xml:1632:5-84], original message=, tool name=Optional.of(AAPT)}
Run Code Online (Sandbox Code Playgroud)
即使文件splash_screen.xml存在于drawable文件夹下,此错误仍然存在.
重建,清理项目和使缓存无效不起作用!
添加android.enableAapt2 = false行并不能解决真正的问题,因此我宁愿找到问题的根源.
以下显示了我的gradle.build文件:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'//https://github.com/bumptech/glide/issues/1939
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.whereisthemonkey.nowalism"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
// Keep the following configuration in order to target Java 8.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility …Run Code Online (Sandbox Code Playgroud) 我正在开发一个 android 应用程序大约 2 个月。几乎每次我在尝试构建项目时创建自定义可绘制对象时,都会出现 Android 资源链接失败错误,然后是 android studio 无法定位的可绘制对象的名称。
我的解决方案是,我将这些可绘制对象移出我的项目的某个位置,并在出现错误后重建应用程序我再次将可绘制对象移回我的项目,当我重建我的项目时,APK不再有错误,我可以构建、运行、甚至生成APK和那些drawables 工作得很好。但是现在我的项目完成了,我想生成签名的 apk,但是我无法摆脱 Android 资源链接失败的错误。我在下面放了一些我的可绘制代码。
retry_btn.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:drawable="@drawable/register_btn_disabled"/>
<item android:state_pressed="true" android:drawable="@drawable/register_btn_clicked"/>
<item android:state_pressed="false" android:drawable="@drawable/register_btn_normal"/>
<item android:drawable="@drawable/register_btn_normal"/>
</selector>
Run Code Online (Sandbox Code Playgroud)
story_box.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:color="#70707070" android:width="1dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
table_border.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape
android:shape="rectangle">
<stroke android:width="1dp" android:color="#333333" />
<solid android:color="#EEEEEE" />
</shape>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)
我的项目中可以使用所有可绘制对象,但是当我尝试生成签名的 apk 时,我得到了这个输出:
Android 资源链接失败
输出:C:\Users\MyUser\AndroidStudioProjects\MyAppName\app\src\main\res\layout\activity_main.xml:51: 错误:资源可绘制/搜索(又名 uk.MyAppName.www.MyAppName:drawable/search)不是成立。
C:\Users\MyUser\AndroidStudioProjects\MyAppName\app\src\main\res\layout\activity_movie.xml:234: …