I'm having a problem running the command 'ionic build android' , and I can not solve . Previously run the ionic command 'platform android add'.
D:\ionic\hello>ionic build android
Running command: "C:\Program Files (x86)\nodejs\node.exe" D:\ionic\hello\hooks\a
fter_prepare\010_add_platform_class.js D:\ionic\hello
add to body class: platform-android
ANDROID_HOME=C:\android-sdk-win
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_65
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:1.2.3.
Required by:
:android:unspecified
> Could not GET 'https://repo1.maven.org/maven2/com/android/tools/build/gr
adle/1.2.3/gradle-1.2.3.pom'.
> peer not authenticated
* 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.585 secs
Error: Error code 1 for command: cmd with args: /s,/c,"D:\ionic\hello\platforms\
android\gradlew cdvBuildDebug -b D:\ionic\hello\platforms\android\build.gradle -
Dorg.gradle.daemon=true -Pandroid.useDeprecatedNdk=true"
I need to generate a package to perform a test on a android device.
my build.gradle is :
apply plugin: 'android'
buildscript {
repositories {
mavenCentral()
}
// Switch the Android Gradle plugin version requirement depending on the
// installed version of Gradle. This dependency is documented at
// http://tools.android.com/tech-docs/new-build-system/version-compatibility
// and https://issues.apache.org/jira/browse/CB-8143
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
// Allow plugins to declare Maven dependencies via build-extras.gradle.
repositories {
mavenCentral()
}
task wrapper(type: Wrapper) {
gradleVersion = '2.8'
}
...
How can I solve ?
Replace your old gradle-1.2.3-all.zip to new downloaded
https://services.gradle.org/distributions/gradle-2.2.1-all.zip and try again.
May be your Gradle file in your C:\Users\shashi.gradle\wrapper\dists\gradle-2.2.1-all
Related
I'm havind this error when i try to build my react native app with :
npx react-native run-android
> Task :react-native-date-picker:parseDebugLocalResources FAILED
ReactNativeFirebase WARNING: NPM package '#react-native-firebase/storage' depends on '#react-native-firebase/app' v15.7.0 but found v14.12.0, this might cause build issues or runtime crashes.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.4/userguide/command_line_interface.html#sec:command_line_warnings
169 actionable tasks: 3 executed, 166 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-date-picker:parseDebugLocalResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.ParseLibraryResourcesTask$ParseResourcesRunnable
> '/Volumes/Untitled/project/node_modules/react-native-date-picker/android/build/intermediates/packaged_res/debug/._drawable' is not a directory
* 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 4m 55s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-date-picker:parseDebugLocalResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.ParseLibraryResourcesTask$ParseResourcesRunnable
> '/Volumes/Untitled/project/node_modules/react-native-date-picker/android/build/intermediates/packaged_res/debug/._drawable' is not a directory
* 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 4m 55s
at makeError (/Volumes/Untitled/project/node_modules/#react-native-community/cli-platform-android/node_modules/execa/index.js:174:9)
at /Volumes/Untitled/project/node_modules/#react-native-community/cli-platform-android/node_modules/execa/index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async runOnAllDevices (/Volumes/Untitled/project/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/Volumes/Untitled/project/node_modules/#react-native-community/cli/build/index.js:192:9)
info Run CLI with --verbose flag for more details.
Project versions:
React-native: 0.68.2
build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())
buildscript {
ext {
buildToolsVersion = "30.0.2"
kotlinVersion = "1.6.21"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
ndkVersion = "21.4.7075529"
}
repositories {
google()
mavenCentral() // New line
jcenter()
}
dependencies {
classpath('com.android.tools.build:gradle:7.3.1')
// classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21" // <- add this line
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral() // New line
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
mavenCentral {
// We don't want to fetch react-native from Maven Central as there are
// older versions over there.
content {
excludeGroup "com.facebook.react"
}
}
exclusiveContent {
// We get React Native's Android binaries exclusively through npm,
// from a local Maven repo inside node_modules/react-native/.
// (The use of exclusiveContent prevents looking elsewhere like Maven Central
// and potentially getting a wrong version.)
filter {
includeGroup "com.facebook.react"
}
forRepository {
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
google()
maven { url 'https://www.jitpack.io' }
}
configurations.all {
resolutionStrategy {
// Remove this override in 0.65+, as a proper fix is included in react-native itself.
force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
}
}
}
I tried clearing cach rebuild update gradle version, and delete node-modules and reinstall but didn't work checked my android API version '31' but didn't find a problem.
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1345 file(s) to forward-jetify. Using 8 workers...
info JS server already running.
info Installing the app...
FAILURE: Build failed with an exception.
Where:
Build file 'D:\workspace\HS\ParkCheck\parkcheck-android-app-master\android\app\build.gradle' line: 1
What went wrong:
A problem occurred evaluating project ':app'.
Failed to apply plugin 'com.android.internal.version-check'.
Minimum supported Gradle version is 6.7.1. Current version is 6.7. If using the gradle wrapper, try editing the distributionUrl in D:\workspace\HS\ParkCheck\parkcheck-android-app-master\android\gradle\wrapper\gradle-wrapper.properties to gradle-6.7.1-all.zip
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 4s
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
Please help me.
I cant build my project.
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
buildscript {
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// Add the following line:
// classpath 'com.google.gms:google-services:4.3.3' // Google Services plugin
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
I am trying to add Neumorphism and DayNightSwitch dependency in Android but the build failed every time.
I tried many times but I didn’t figured out what's the problem is.
The gradle plugin is 7.2 and the Gradle version is 7.0.1
Neumorphism dependency
dependencies {
implementation 'com.github.fornewid:neumorphism:{latest_version}'
}
DayNightSwitch dependency
dependencies {
implementation 'com.github.Mahfa:DayNightSwitch:1.4'
}
8: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find com.github.fornewid:neumorphism:0.3.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/github/fornewid/neumorphism/0.3.0/neumorphism-0.3.0.pom
- https://repo.maven.apache.org/maven2/com/github/fornewid/neumorphism/0.3.0/neumorphism-0.3.0.pom
Required by:
project :app
* 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.
Please try to specify a version for the dependency
implementation 'com.github.fornewid:neumorphism:0.3.0'
Please add Neumorphism dependecy in your app level build.gradle as below,:
implementation 'com.github.fornewid:neumorphism:0.3.0'
And add these lines inside dependencyResolutionManagement to your Settings.gradle:
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
jcenter() // Warning: this repository is going to shut down soon
}
apple#mosesdeMacBook-Pro:~/Desktop/sxtbdemo2$ react-native run-android
Scanning folders for symlinks in /Users/apple/Desktop/sxtbdemo2/node_modules (8ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'sxtbdemo2'.
Could not resolve all files for configuration ':classpath'.
Could not find com.android.tools.build:gradle:3.0.1.
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
Required by:
project :
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 12s
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: https://facebook.github.io/react-native/docs/android-setup.html
It is usually a problem with your repositories in your gradle files.
for me worked to modify the build.gradle like this:
buildscript {
repositories {
mavenLocal()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
so when you add google() it should work.
buildscript {
repositories {
jcenter()
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
Add google() inside buildscript() and Sync Project.
Reference : https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#apply_plugin
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.