android studio cant build - android

FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:preDexDebug'.
java.io.IOException: Cannot run program "C:\Users\SETIAWAN\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat":
CreateProcess error=2, The system cannot find the file specified
Try: Run with --stacktrace option to get the stack trace. Run with -- info or --debug option to get more log output.
BUILD FAILED
Total time: 1 mins 12.109 secs
Anyone can help. When I try to run dx.bat. Error Windows can't find this file(dx.bat)

You may adding android-support-v4.jar for multiple times. Remove the dependencies of android-support-v4.jar from project's build.gradle and just have a single dependencies, such that:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}

Related

Error while running react-native app please help me

WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed soon. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.5.2.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '23.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
Task :app:processDebugResources FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings
234 actionable tasks: 14 executed, 220 up-to-date
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugResources'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
C:\coding\App\storyqube-frontend\android\app\src\main\AndroidManifest.xml:13:5-71:19: AAPT: error: resource mipmap/storyqube (aka com.storyqube:mipmap/storyqube) not found.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 18s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugResources'.
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource linking failed
C:\coding\App\storyqube-frontend\android\app\src\main\AndroidManifest.xml:13:5-71:19: AAPT: error: resource mipmap/storyqube (aka com.storyqube:mipmap/storyqube) not found.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 18s
at makeError (C:\coding\App\storyqube-frontend\node_modules\execa\index.js:174:9)
at C:\coding\App\storyqube-frontend\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (C:\coding\App\storyqube-frontend\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
at async Command.handleAction (C:\coding\App\storyqube-frontend\node_modules\react-native\node_modules\#react-native-community\cli\build\index.js:186:9)
PS C:\coding\App\storyqube-frontend>
Check your build.gradle files in your android folder and search for compile and replace it it with implementation.
Change:
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile project(':react-native-sqlite-storage')
}
To:
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:23.0.1"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-sqlite-storage')
}

Can't use ConstraintLayout! Error: AAPT2 error: check logs for details

I want to use ConstraintLayout recently. But it seems to be more complicated than I can imagine. When I add the dependency, compile error comes as below:
Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
When I execute gradlew assemble, I get this:
AGPBI: {"kind":"error","text":"error: duplicate value for resource \u0027attr/content\u0027 with config \u0027\u0027.","sources":[{"file":"D:\\Cache\\.gradle\\caches\\transforms-1\\files-1.1\\appcompat-v7-27.1.1.aar\\b4523fa2ae32c684fd710140c71c62d6\\res\\values\\values.xml","position":{"startLine":250,"startColumn":4,"startOffset":27058,"endColumn":68,"endOffset":27122}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: resource previously defined here.","sources":[{"file":"D:\\Cache\\.gradle\\caches\\transforms-1\\files-1.1\\appcompat-v7-27.1.1.aar\\b4523fa2ae32c684fd710140c71c62d6\\res\\values\\values.xml","position":{"startLine":250,"startColumn":4,"startOffset":27058,"endColumn":68,"endOffset":27122}}],"original":"","tool":"AAPT"}
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 7s
Here is my build.gradle file:
...
repositories {
google()
}
...
dependencies {
def app = rootProject.ext.android
// android support
implementation "com.android.support:appcompat-v7:27.1.1"
implementation "com.android.support:design:27.1.1"
implementation "com.android.support:palette-v7:27.1.1"
implementation "com.android.support:recyclerview-v7:27.1.1"
implementation "com.android.support:cardview-v7:27.1.1"
implementation "com.android.support:percent:27.1.1"
implementation "com.android.support:support-v4:27.1.1"
implementation "com.android.support:gridlayout-v7:27.1.1"
implementation "com.android.support:support-vector-drawable:27.1.1"
implementation 'com.android.support:multidex:1.0.3'
implementation 'junit:junit:4.12'
implementation "android.arch.lifecycle:extensions:1.1.1"
...
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
}
I had tried to clean, rebuild, invalidate and restart. They didn't work. And I also tried to update gradle plugin. But I saw more errors. Somebody help me please! It has bothered me for a couple of days.
PS, Information you may need:
Windows 7
android studio 3.3.2
gradle 3.1.4
java 8

Could not get unknown property 'FCM_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler

I am setting up an Android project in Android Studio with Cordova.
I have the following in my dependencies (\platforms\android\build.gradle):
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
// SUB-PROJECT DEPENDENCIES START
debugCompile(project(path: "CordovaLib", configuration: "debug"))
releaseCompile(project(path: "CordovaLib", configuration: "release"))
compile "com.android.support:support-v13:26.+"
compile "me.leolin:ShortcutBadger:1.1.17#aar"
compile "com.google.firebase:firebase-messaging:$FCM_VERSION"
// SUB-PROJECT DEPENDENCIES END
}
When I try to run cordova build android I get the following error:
Could not get unknown property 'FCM_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler
In my config.xml in the root of my project I have the following where theat variable is declared:
<plugin name="phonegap-plugin-push" spec="^2.1.3">
<variable name="FCM_VERSION" value="11.6.2" />
</plugin>
Full error message in terminal:
ANDROID_HOME=C:\Users\Shabaz\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_131
Subproject Path: CordovaLib
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to C:\Users\Shabaz\AppData\Local\Android\Sdk\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
at build_20908j486irej0tvcnl5l4x1o.run(C:\wamp\www\acm-waste-track-cordova\platforms\android\build.gradle:142)
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\wamp\www\acm-waste-track-cordova\platforms\android\build.gradle' line: 259
* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not get unknown property 'FCM_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.931 secs
Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\wamp\www\acm-waste-track-cordova\platforms\android\build.gradle' line: 259
* What went wrong:
A problem occurred evaluating root project 'android'.
> Could not get unknown property 'FCM_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Anyone know whats going on here?

Execution failed for task ':app:transformClassesAndResourcesWithProguardForXXXRelease'

When I upgrade android studio version to 2.3,and gradle version to 3.3,and android gradle plugin version to 2.3.0,and buildToolsVersion version to 25.0.0,It has some problem when I use this command "gradlew assembleRelease" to package my application.
Shrinking...
Printing usage to [E:\workspace\android_source\src\app\build\outputs\mapping\XXX\release\usage.txt]...
Removing unused program classes and class elements...
Original number of program classes: 10650
Final number of program classes: 10247
Optimizing...
Warning: Exception while processing task java.io.IOException: java.lang.NullPointerException
:app:transformClassesAndResourcesWithProguardForXXXRelease FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesAndResourcesWithProguardForXXXRelease'.
> Job failed, see logs for details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1 mins 34.554 secs
but when I downgrade android gradle plugin to version 2.2.3,and buildToolsVersion to 23.0.1,It works well.
I have resolved this problem,It is because the proguard version is too low,if we update the gradle plugin,the version is greater than 2.3.0,we must use the proguard version 5.3.2 or higher,this is how to use the high proguard version,here is two solutions:
1.Add these code in build script method of your build.gradle file:
buildscript {
...
configurations.all {
resolutionStrategy {
force 'net.sf.proguard:proguard-gradle:5.3.3'
}
}
}
then,repackage.
2.To download proguard.jar by this link
.then,create a folder in root path of your project,put the jar in this folder,add these code in your build.gradle file:
buildscript {
repositories {
flatDir{dirs 'proguard'}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath ':proguard:'
}
}
then,repackage.

Found com.google.android.gms:play-services-auth:9.2.1, but version 9.0.0 is needed and Duplicate zza.class errors

I have a react-native project and I'm trying to setup google signin on it. To that I need to setup the react-native-google-signin plugin which asks me to add the following to the build.gradle file :
compile(project(":react-native-google-signin")){
exclude group: "com.google.android.gms" // very important
}
compile 'com.google.android.gms:play-services-auth:9.2.1'
When I do this, I get a build error like this :
Found com.google.android.gms:play-services-auth:9.2.1, but version 9.0.0 is needed for the google-services plugin.
:app:processDebugGoogleServices FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
> Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 9.0.0.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.62 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment.
Go to https://facebook.github.io/react-native/docs/getting-started.html
and check the Android tab for setup instructions.
When I make the play-services-auth 9.0.0, it gives me this error :
:app:transformClassesWithJarMergingForDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/common/api/zza.class
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 2.107 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment.
Go to https://facebook.github.io/react-native/docs/getting-started.html
and check the Android tab for setup instructions.
My build.gradle dependencies look like this:
dependencies {
compile project(':react-native-fbsdk')
compile(project(':react-native-firebase-analytics')){
exclude group: "com.google.android.gms" // very important
}
compile project(':react-native-share')
compile project(':react-native-video')
compile project(':react-native-uuid-generator')
compile project(':react-native-udp')
compile project(':react-native-tcp')
compile project(':react-native-code-push')
compile project(':react-native-camera')
compile project(':react-native-linear-gradient')
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile project(':react-native-image-picker')
compile(project(":react-native-google-signin")){
exclude group: "com.google.android.gms" // very important
}
compile 'com.google.android.gms:play-services-auth:9.0.0'
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
Any idea what's happening? I tried many fixes suggested on other threads but none helped. I will get these two errors all the time. Please help!
Full error logs are here : https://gist.github.com/THPubs/1ca6405f62671c698c4aee0c73c8324e

Categories

Resources