Execution failed for task ':app:transformClassesAndResourcesWithProguardForXXXRelease' - android

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.

Related

Unable to load class 'ijinit_dkec9zswd4p83aajh1klyj0h5'. (React_native gradle sync issue)

Unable to load class 'ijinit_dkec9zswd4p83aajh1klyj0h5'. (React_native gradle sync issue)
I am facing this issue on Gradle sync while building .apk, dubug apk is working fine.
I have also cleaned Gradle and rebuilt my app but still no improvement.
Error image
Build Script:
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 31
ndkVersion = "21.4.7075529"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Error:
Unable to load class 'ijinit_dkec9zswd4p83aajh1klyj0h5'.
This is an unexpected error. Please file a bug containing the idea.log file.
FAILURE: Build failed with an exception.
What went wrong:
Could not load compiled classes for initialization script 'C:\Users\User\AppData\Local\Temp\ijinit.gradle' from cache.
ijinit_dkec9zswd4p83aajh1klyj0h5
Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Exception is:
org.gradle.api.GradleException: Could not load compiled classes for initialization script 'C:\Users\User\AppData\Local\Temp\ijinit.gradle' from cache.
Caused by: java.lang.ClassNotFoundException: ijinit_dkec9zswd4p83aajh1klyj0h5
Had a similar error, fixed it by upgrading Android Studio. It needed a proper sync after upgrade.
Refer to https://issuetracker.google.com/issues/36990380
Update will solve your problem
Help -> Check for Updates

Build failed when adding Neumorphism dependency in Android

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
}

How the build flutter gradle? Its failed

I added the firestore and firebase auth to my flutter project, but now it is not starting.
If I write gradlew build in the terminal I get a error code:
> Configure project :app
Adding a Configuration as a dependency is a confusing behavior which isn't recommended. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. If you're interested in inheriting the dependencies from the Configuration you are adding, you s
hould use Configuration#extendsFrom instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.artifacts.Configuration.html#org.gradle.api.artifacts.Configuration:extendsFrom(org.gradle.api.artifacts.Configuration[]) for more details.
at build_90hb1guh6a6ptpmu6otfn4x4q$_run_closure3.doCall(D:\eyyup\AndroidStudioProjects\todo\android\build.gradle:27)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
The AbstractArchiveTask.destinationDir property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the destinationDirectory property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.
gradle.api.tasks.bundling.AbstractArchiveTask:destinationDir for more details.
at FlutterPlugin$_addFlutterTasks_closure16$_closure35.doCall(D:\src\flutter\packages\flutter_tools\gradle\flutter.gradle:762)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
The AbstractArchiveTask.archiveName property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveFileName property instead. See https://docs.gradle.org/6.7/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.a
pi.tasks.bundling.AbstractArchiveTask:archiveName for more details.
at FlutterPlugin$_addFlutterTasks_closure16$_closure35.doCall(D:\src\flutter\packages\flutter_tools\gradle\flutter.gradle:763)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
> Configure project :firebase_auth
WARNING: The option setting 'android.enableR8=true' is deprecated.
It will be removed in version 5.0 of the Android Gradle plugin.
You will no longer be able to disable R8
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':app:debugAndroidTestCompileClasspath'.
> Could not find com.google.firebase:firebase-analytics:.
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.
* Get more help at https://help.gradle.org
BUILD FAILED in 5s
What can I do the solve this problem?
Did you remember to update your build.gradle files? Or did you create this project with an older version of Flutter (in which case the dependencies might be too old for that version of Firebase Analytics).
Check that your android/build.gradle file contains the following:
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3'
}
}
and your android/app/build.gradle file contains the following:
dependencies {
def multidex_version = "2.0.1"
implementation "androidx.multidex:multidex:$multidex_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics:17.2.2'
}
apply plugin: 'com.google.gms.google-services'
Further information is here https://github.com/FirebaseExtended/flutterfire/issues/2649#issuecomment-635855829

Exception while trying to execute build in ionic application

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

Allow unstable Android Gradle builds on Jenkins

Hi I have set up my Android project on Jenkins to provide CI. Its working well, running tests on a connected Android handset. The tests run on the Android Test Framework which extends jUnit3.
Unfortunately, the build is marked as a failure if there are any test failures. I'd like to be able to improve this in two ways:
Allowing unstable builds
Being able to mark known test failures
For item 1 I tried adding this to the project build.gradle:
connectedCheck {
ignoreFailures = true
}
But it has no effect. Looking at the build log, I realised the actual test task is called connectedInstrumentTest, but this task is not found:
connectedInstrumentTest {
ignoreFailures = true
}
causes:
Could not find method connectedInstrumentTest() for arguments [build_4ldpah0qgf0ukktofecsq41r98$_run_closure3#9cd826] on project ':Playtime'.
That am I missing?
Thanks
EDIT: Heres my project build.gradle, nothing special:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 16
testPackageName "com.bb.pt.test"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
}
}
connectedCheck {
ignoreFailures = true
}
My gradle settings in jenkins:
switches: --stacktrace --info
tasks: :pt:assembleDebug :pt:assembleTest :pt:connectedCheck
EDIT:
I built gradlew and tried that. Same output. I don't want the build to FAIL if there are test failures:
:pt:connectedInstrumentTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':pt:connectedInstrumentTest'.
> There were failing tests. See the report at: file:///home/simon/WorkingCopies/bb/code/trunk/pt/pt/build/reports/instrumentTests/connected/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
BUILD FAILED
I tried to qualify the task name in build.gradle:
task connectedCheck {
ignoreFailures = true
}
But it thinks I am trying to add a new task rather than modify the existing one.
FAILURE: Build failed with an exception.
* Where:
Build file '/home/simon/WorkingCopies/bb/code/trunk/pt/pt/build.gradle' line: 31
* What went wrong:
A problem occurred evaluating project ':pt'.
> Cannot add task ':pt:connectedCheck' as a task with that name already exists.
After our conversation I believe that:
the problem is gradle configuration only and not jenkins related. Get it to work in gradle.
in gradle I believe (though I am not an expert) you should get the connectedInstrumentTest to ignore failures, but your attempt to use the following failed
connectedInstrumentTest {
ignoreFailures = true
}
maybe the solution is to wrap this config node like this:
project.gradle.taskGraph.whenReady {
connectedInstrumentTest {
ignoreFailures = true
}
}
https://github.com/stanfy/hotandroid/blob/master/part0/build.gradle

Categories

Resources