AAPT error in Android studio while building the project - android

I have been getting this error while building my android project. I was not getting this error before but recently I updated my gradle version for supporting instant apps.
I'm wondering if thats what causing the issue.
Execution failed for task ':vuclip:processProdAutoFeatureResources'.
AAPT2 aapt2-3.2.1-4818971-osx Daemon #0: Unexpected error during link, attempting to stop daemon.
This should not happen under normal circumstances, please file an issue if it does.
Edit : The code is compiling fine but while building the apk using the command ./gradlew clean build, the build is failing with the above exception.
build.gradle
apply plugin: 'com.android.feature'
android {
compileSdkVersion buildVersion.targetSdk
defaultConfig {
baseFeature true
minSdkVersion buildVersion.minSdk
targetSdkVersion buildVersion.targetSdk
multiDexEnabled = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
debuggable false
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
lintOptions {
disable 'MissingTranslation'
checkReleaseBuilds false
abortOnError false
}
}
debug {
debuggable true
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
versionNameSuffix "-debug"
}
e2e {
initWith debug
debuggable true
minifyEnabled false
versionNameSuffix "-e2e"
}
auto {
initWith release
debuggable true
versionNameSuffix "-auto"
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
application project(':viuapp')
feature project(':discover')
api "com.android.support:appcompat-v7:$versions.supportLibrary"
api "com.android.support:design:$versions.supportLibrary"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
api project(':boot')
api project(':utilities')
api project(':analytics')
api project(':viu-logger')
api project(':fonts')
api project(':viu-constants')
api project(':app_context')
api project(':storage')
api project(':datamodels')
}
repositories {
mavenCentral()
}

I was finally able to fix it. The issue was I have made one module as library and not added it in my base module. All your feature modules MUST be added as a dependency in your play module.

Try:
File -> Invalidate caches/Restart and Invalidate and Restart

Related

Execution failed for task ':app:mergeDebugResources' , Unable to locate resourceFile in source-sets

Whenever I made any change to an XML file from the project and tried to run it, I got this error-
Execution failed for task ':app:mergeDebugResources'.
java.lang.IllegalArgumentException: Unable to locate resourceFile (D:Q\app\build\intermediates\merged-not-compiled-resources\debug\layout\notification_action.xml)
in source-sets.
For running the project I need to do Build > Clean Project every time if I make any changes to XML.
Below is my grade file -
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "xxxxx"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.6.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.github.ybq:Android-SpinKit:1.4.0'
}
I found by several testing that proguard rule is the issue for this error. Changing the proguard rules for debug solves the issue. Just need to set shrinkResources false in the debug buildTypes.
buildTypes {
debug {
minifyEnabled true
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
Restarting Android Studio was the solution in my case.
There is no need to set shrinkResouces false. I have set it to true and it works completely fine.
In short:
"clean project and move on"
Details:
Go to the "build tab" in the android studio > then click on "clean project".
enjoy!
"Clean Project and then run the app", this work for me you can also try this
Clearing Android Studio's cache resolved the issue for me.
Select 'File > Invalidate Caches' and then click the 'Invalidate and Restart' button.
In my case,I build my apk. I click build ->generate signed bundle or APK,
then I get the error
Unable to locate resourceFile
I delete the .idea folder in my project.
Then I build my apk again, it's no more error. it's working for me.
Build >> Rebuild Project solved my probem
just press Shift + F10 again.This is the fastest way, less time consuming than Clean -> Rebuild

Avoid 'Variant Selection Conflicts' warning when using android test plugin without release variant

What I want to do & the problem
I updated my Android Studio and Android Gradle Plugin to 3.0.1 and my Gradle Wrapper to 4.1 and can build & deploy my Android Gradle project in release variant on a device via IDE.
However, the following 'Gradle Sync' warning messages are shown:
Warning:Module 'library' has variant 'release' selected, but the modules ['integration-test'] depend on variant 'debug'
The problem here is, that there is no 'release' variant for the integration-test module which uses the 'com.android.test'
plugin.
If I simply try to add a release build type (buildTypes { release {} }) to the :integration-test module I receive:
Error:VariantInputs initialized with no merged manifest report on: DEFAULT
Details about the project (simplified)
The project consists of:
a :library module
an :app module which builds the app's apk and uses the :library module
an :integration-test module which:
uses the "com.android.test" plugin
dependents on the :app module via targetProjectPath ':app' & targetVariant 'debug'
and contains instrumented tests on the :app functions
only contains a 'main' folder (the test plugin does not support others)
This project is build after the Android Test Blueprint as the goal is here that the :app module does not know anything about the integration-test module's existence.
settings.gradle
include :library
include :app
include :integration-test
app/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
publishNonDefault true
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
applicationId "xxxxx"
testInstrumentationRunner rootProject.ext.testInstrumentationRunner
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
signingConfigs {
release {
keyAlias 'xxxx'
}
}
buildTypes {
debug {
testCoverageEnabled = true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
// This is needed by the integration-test module (i.e. com.android.test : integration test)
// in order for targetVariant to work without a flavor
publishNonDefault true
testOptions {
unitTests {
// Required so that logging methods do not throw not mocked exceptions in junit tests.
returnDefaultValues = true
}
}
compileOptions {
sourceCompatibility rootProject.ext.sourceCompatibility
targetCompatibility rootProject.ext.targetCompatibility
}
}
dependencies {
// Local dependencies
compile project(':library')
// i cleaned up all the other dependencies as they wouldn't help here
}
Question
Did anyone get an (integration-)test module using the com.android.test plugin to run with Android Gradle Plugin 3.0.1 without getting the "no release variant" error? If so, how can I avoid this error or how can I add such a release variant to a android test plugin based module (if this makes sense at all)?
I was also getting
VariantInputs initialized with no merged manifest report on: DEFAULT.
Then I followed exactly what is outlined in the https://github.com/googlesamples/android-testing-templates/tree/master/AndroidTestingBlueprint
The error went away when I removed release buildType from the `buildTypes' block in the test module's Gradle file.
From this:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
to
buildTypes {
}

how to generate app-debug

when I pressed run button I checked apk floder where app-debug-unaligned.apk generated but app-debug.apk not refreshed. I don't know what I did that this happened. check the date in picture
EDIT: maybe people think I am lying but it's not true. maybe problem is in build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "ir.parsdroid.instagrameducation"
minSdkVersion 8
targetSdkVersion 23
versionCode 11
versionName "1.5.3"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
proguardFile 'proguard-android-optimize.txt'
zipAlignEnabled false
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:support-v4:23.0.0'
compile files('src/main/libs/adad-2.9.jar')
}
In android studio, APK gets generated when we rebuild an application or run an application.
To get debug apk :
Rebuild your project or run your project
check your_app_location\app\build\outputs\apk
Edited :
Here in your gradle file you have used 'zipAlignEnabled' :
debug {
minifyEnabled true
proguardFile 'proguard-android-optimize.txt'
zipAlignEnabled false
}
Problem is because of it. So please check how to use 'zipAlignEnabled' and try again.!!
Hope it will help.
Agree with Mamata Gelanee. You can simply remove app-debug.apk file from folder and clean the project and release new build again then check.

The project is using an unsupported version of the Android Gradle plug-in (0.13.2). The recommended version is 1.0.0-rc2 [duplicate]

I've just updated my Android Studio and now my project won't build anymore. I get following error:
Error:(16, 0) Gradle DSL method not found: 'runProguard()'
Possible causes:<ul><li>The project 'App' may be using a version of Gradle that does not contain the method.
Gradle settings</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
I didn't change anything, everything worked properly before the update. Here's my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.ochs.pipette"
minSdkVersion 10
targetSdkVersion 21
versionCode 8
versionName "1.6"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'it.sephiroth.android.library.imagezoom:library:1.0.4'
compile 'com.android.support:palette-v7:21.0.+'
}
And here's the other one:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0-rc2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
I don't know how to fix the problem, could anyone help me?
runProguard has been renamed minifyEnabled. See the changelog here for confirmation - version 0.14.0 (2014/10/31) of the Android Gradle plugin made the swap.
As #stkent said, runProguard has been renamed to minifyEnabled in version 0.14.0 (2014/10/31) of Gradle.
To fix this, you need to change runProguard to minifyEnabled in the build.gradle file of your project. For example,
buildTypes {
release {
runProguard false // Does not exist anymore...
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
would be replaced by
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
You can see other issues here but this worked for me.
runProguard has been renamed to minifyEnabled in version 0.14.0 (2014/10/31) of Gradle.
To fix this, you need to change runProguard to minifyEnabled in the build.gradle file of your project.

After Android Studio update: Gradle DSL method not found: 'runProguard()'

I've just updated my Android Studio and now my project won't build anymore. I get following error:
Error:(16, 0) Gradle DSL method not found: 'runProguard()'
Possible causes:<ul><li>The project 'App' may be using a version of Gradle that does not contain the method.
Gradle settings</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
I didn't change anything, everything worked properly before the update. Here's my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.ochs.pipette"
minSdkVersion 10
targetSdkVersion 21
versionCode 8
versionName "1.6"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'it.sephiroth.android.library.imagezoom:library:1.0.4'
compile 'com.android.support:palette-v7:21.0.+'
}
And here's the other one:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0-rc2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
I don't know how to fix the problem, could anyone help me?
runProguard has been renamed minifyEnabled. See the changelog here for confirmation - version 0.14.0 (2014/10/31) of the Android Gradle plugin made the swap.
As #stkent said, runProguard has been renamed to minifyEnabled in version 0.14.0 (2014/10/31) of Gradle.
To fix this, you need to change runProguard to minifyEnabled in the build.gradle file of your project. For example,
buildTypes {
release {
runProguard false // Does not exist anymore...
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
would be replaced by
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
You can see other issues here but this worked for me.
runProguard has been renamed to minifyEnabled in version 0.14.0 (2014/10/31) of Gradle.
To fix this, you need to change runProguard to minifyEnabled in the build.gradle file of your project.

Categories

Resources