java - Why is Android Studio trying to locate resource in debug package instead of the main one? -
i have app 4 different build types: debug , release (the normal ones), alpha , beta. declare types in build.gradle follows:
buildtypes { // release (or "live") variant. application id app.myapp.live release { minifyenabled true shrinkresources true debuggable false proguardfiles getdefaultproguardfile('proguard-android.txt'), 'proguard-rules.pro' signingconfig signingconfigs.config applicationidsuffix ".live" ext.enablecrashlytics = true // build config fields buildconfigfield("boolean", "release", "true") } // debug variant. application id app.myapp.debug debug { minifyenabled false shrinkresources false debuggable true applicationidsuffix ".debug" versionnamesuffix '-debug' ext.enablecrashlytics = false } // alpha variant. application id app.myapp.alpha alpha { initwith release debuggable true applicationidsuffix ".alpha" versionnamesuffix '-alpha' } // beta variant. closer live. application id app.myapp.beta beta { initwith release debuggable true applicationidsuffix ".beta" versionnamesuffix '-beta' } }
my folder structure correct , thing override in different build variants strings.xml (where app name differs). works correctly.
now, when having debug selected build variant, , try reference resources in layout file, following as:
error:(16) no resource identifier found attribute 'arc1color' in package 'app.myapp.debug'
why looking in "app.myapp.debug"? java packages should stay same, package id (and application id) should different in merged manifest when building. or thinking wrong here?
i'm using 'com.android.tools.build:gradle:2.3.3' , running 2.3.1
don't confuse java package package name , application id.
when create new project in android studio, applicationid matches java-style package name chose during setup. however, application id , package name independent of each other beyond point. can change code's package name (your code namespace) , not affect application id, , vice versa
and:
although may have different name manifest package , gradle applicationid, build tools copy application id apk's final manifest file @ end of build. if inspect androidmanifest.xml file after build, don't surprised package attribute has changed
more details here.
since using:
debug { applicationidsuffix ".debug" }
your package becomes 'app.myapp.debug'
java package of classes doesn't change.
error:(16) no resource identifier found attribute 'arc1color'
it means in debug build type not defining attribute arc1color
(may defined in resources inside other build types). check resources files.
Comments
Post a Comment