Conflict with Huawei HMS plugin in android with gradle 7.0.0 - android

I'm getting this error with Gradle 7.0 while it was working fine for 6.8.3
agcp-gradle-7-error
AGCPlugin
FAILURE: Build failed with an exception.
What went wrong:
A problem was found with the configuration of task ':app:processDebugAGCPlugin' (type 'AGCPluginTask').
Type 'AGCPluginTask' property 'randomEncryptComponent' of type boolean shouldn't be annotated with #Optional.
Reason: Properties of primitive type cannot be optional.
Possible solutions:
Remove the #Optional annotation.
Use the java.lang.Boolean type instead.
Please refer to https://docs.gradle.org/7.0/userguide/validation_problems.html#cannot_use_optional_on_primitive_types for more details about this problem.

I no longer get any errors with:
classpath 'com.huawei.agconnect:agcp:1.5.2.300'
and
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip

Currently Gradle 7.0 is not supported. As I hear, it will be supported at the end of June.

Related

Gradle task failing when updating to gradle 7.3.3

I have updated my project with gradle version 7.3.3 but getting the below error: Any suggestion.
Some problems were found with the configuration of task ':compileDebugRenderscript' (type 'RenderscriptCompile').
- In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.tasks.RenderscriptCompile' method 'useAndroidX()' should not be annotated with: #Input.
After scan:
* Exception is:
org.gradle.internal.execution.WorkValidationException: Some problems were found with the configuration of task ':compileDebugRenderscript' (type 'RenderscriptCompile').
- In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.tasks.RenderscriptCompile' method 'useAndroidX()' should not be annotated with: #Input.
Reason: Input/Output annotations are ignored if they are placed on something else than a getter.
Possible solutions:
1. Remove the annotations.
2. Rename the method.

ANTLR Tool version 4.7.1 used for code generation does not match the current runtime version 4.5.3

Im working on an Android App, currently using DSL and some libraries, suddenly the build gave me this error.
Task :app:kaptDebugKotlin FAILED
ANTLR Tool version 4.7.1 used for code generation does not match the current runtime version 4.5.3ANTLR Runtime version 4.7.1 used for parser compilation does not match the current runtime version 4.5.3
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
java.lang.reflect.InvocationTargetException (no error message)
i've been searching but with no success...
If you wanna see the issue you can clone the project. Project GITHUB
Im using Android Studio Canary 4.1.
So the solution was from the build.gradle
basically the import from ROOM was this
import(Room.compiler)
so i changed to this, and the issue was solved :)
kapt(Room.compiler)
Inside the build.gradle(Module:app) copypaste this code
configurations.all() {
resolutionStrategy.force "org.antlr:antlr4-runtime:4.5.3"
resolutionStrategy.force "org.antlr:antlr4-tool:4.5.3"
}
For anyone still experiencing this issue, just update your Room to the latest version:
androidx.room:room-runtime:2.3.0-alpha04
androidx.room:room-compiler:2.3.0-alpha04
It's due to this bug: https://issuetracker.google.com/issues/155215201
The problem was fixed for me by changing this.
from:
implementation "androidx.room:room-runtime:$depVersion"
implementation "androidx.room:room-compiler:$depVersion"
to:
implementation "androidx.room:room-runtime:$depVersion"
annotationProcessor "androidx.room:room-compiler:$depVersion"
Removing suspend keyword from queries in DAO interface, solved my problem
I got similar error. I have all files in Java and I changed few files to Kotlin. Then this issue showed up.
I have a function in a Java file accessing static function in a Kotlin file. That's the point where the app crashed.
Code in Kotlin file:
companion object{
#JvmStatic
fun myStaticFunction(){
// body of the static function
}
}
I added the annotation #JvmStatic(see the above code) to the function and the error got resolved.
This is a very specific scenario in which this crash occurs and may not be applicable to all.
At lease for me, the root cause of this problem/error is because of the data binding not being handled properly.
Currently, Android Studio does not have a mechanism to show error message for unreferenced variables in .xml file.
For example,
In MyViewModel.kt, If I have a property name as,
var email
and you are mapping this property in xml as,
#={model.errEmail}
instead of #={model.email}
You get to see this error.
If you see this error, just go to layout xml file and check the binding names/mappings and correct it.
Had a similar issue. I was trying to implement bindingAdapters to a TextView of a ViewHolder in my recyclerview
I failed to implement a bindingAdapter for a TextView after adding the adding a unique app attribute
app:tDate="#{transaction}
in the xml layout file for my recylerView item.
<TextView
android:id="#+id/trans_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/trans_category"
app:layout_constraintTop_toTopOf="parent"
app:tDate="#{transaction}"/>
Solved it by well.. implementing it.
#BindingAdapter("tDate")
fun TextView.setValue(item: Transactions){
text = item.date.toString()
}

Execution failed for task ':app:bintrayUpload' and Execution failed for task ':app:bintrayPublish'

Cannot cast object 'task ':bintrayUpload'' with class 'com.jfrog.bintray.gradle.tasks.BintrayUploadTask_Decorated' to class 'com.jfrog.bintray.gradle.tasks.BintrayUploadTask'
Cannot cast object 'task ':asista-ui:bintrayUpload'' with class 'com.jfrog.bintray.gradle.tasks.BintrayUploadTask_Decorated' to class 'com.jfrog.bintray.gradle.tasks.BintrayUploadTask'
New Dependency added to My project and this dependency was writted in kotlin but i am Using language for Java.So,My App Displayed a error Message for Adding a Kotlin Version.I Am added a Kotlin Version 1.0.50 something.
So I Solved this Error For Following->
Remove the Kotlin Version and Its using Place and Its Solved..And Update your gradle built version for Latest...
Another Error For Displayed in bintrayPublish failed
this error solved for using this Method->
**Change bintray latest Version.(E.g:1.8.4) **

androidX jetifier - Is there a way to ignore jetifying a .JAR?

Trying to update my app to androidX dependencies. Followed instructions here, and compilation failed.
The error came from JetifyTransform task failing to process a certain .JAR dependency (FYI - Samsungs Spass SDK) :
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:kaptGenerateStubsStandardNo_vendorDebugKotlin'.
> Could not resolve all artifacts for configuration ':app:standardNo_vendorDebugCompileClasspath'.
> Failed to transform file 'pass-v1.2.2.jar' to match attributes {artifactType=processed-jar} using transform JetifyTransform
> Failed to transform '/Users/hanandann/StudioProjects/ArnakPaymentsAndroid/Payments/app/libs/pass-v1.2.2.jar' using Jetifier. Reason: null. (Run with --stacktrace for more details.)
> Failed to transform file 'pass-v1.2.2.jar' to match attributes {artifactType=processed-jar} using transform JetifyTransform
> Failed to transform '/Users/hanandann/StudioProjects/ArnakPaymentsAndroid/Payments/app/libs/pass-v1.2.2.jar' using Jetifier. Reason: null. (Run with --stacktrace for more details.)
Trying to jetify with jetifier-standalone tool had similar results:
Hanans-MacBook-Pro:bin hanandann$ ./jetifier-standalone -i /Users/hanandann/StudioProjects/.../app/libs/pass-v1.2.2.jar -o /Users/hanandann/StudioProjects/.../app/libs/pass-v1.2.2jet.jar
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 8
at org.objectweb.asm.ClassReader.readFrameType(ClassReader.java:2313)
at org.objectweb.asm.ClassReader.readFrame(ClassReader.java:2269)
at org.objectweb.asm.ClassReader.readCode(ClassReader.java:1448)
at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1126)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:698)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:500)
at com.android.tools.build.jetifier.processor.transform.bytecode.ByteCodeTransformer.runTransform(ByteCodeTransformer.kt:39)
at com.android.tools.build.jetifier.processor.Processor.visit(Processor.kt:443)
at com.android.tools.build.jetifier.processor.archive.ArchiveFile.accept(ArchiveFile.kt:49)
at com.android.tools.build.jetifier.processor.Processor.visit(Processor.kt:425)
at com.android.tools.build.jetifier.processor.archive.Archive.accept(Archive.kt:76)
at com.android.tools.build.jetifier.processor.Processor.transformLibrary(Processor.kt:421)
at com.android.tools.build.jetifier.processor.Processor.transform(Processor.kt:247)
at com.android.tools.build.jetifier.processor.Processor.transform$default(Processor.kt:234)
at com.android.tools.build.jetifier.standalone.Main.run(Main.kt:157)
at com.android.tools.build.jetifier.standalone.Main$Companion.main(Main.kt:109)
at com.android.tools.build.jetifier.standalone.Main.main(Main.kt)
Now, I don't really mind if SDK's don't get jetified, so I tried setting android.enableJetifier=false in my gradle.properties file, but compilation failed again for a different reason- SupportMapFragment isn't compatible with androidX yet as is reported here
So I'm stuck. With jetify the .JAR won't transform. with it - SupportMapFarg is incompatible.
Any suggestions?
P.S. you know what would be nice? if there was an ignore option for the jetifying function
added this to gradle.properties:
android.jetifier.blacklist = pass
as suggested by folks at google here.
Be warned - this feature is experimental and unsupported.
Update- current syntax is android.jetifier.ignorelist={your.ignored.lib} as Suggested by #YaMiN
Currently android.jetifier.blacklist is deprecated.
It was removed in version 7.0 of the Android Gradle plugin.
This property has been replaced by android.jetifier.ignorelist
If you need to ignore just a specific .jar file from the jetifier. You can add the file name in the gradle.properties like on the last line from this example.
android.useAndroidX=true
android.enableJetifier=true
android.jetifier.blacklist=liblinphone-4.0.1-debug-symbols.jar
Add this in project's gradle.properties:
android.jetifier.blacklist =xx.aar,yy.jar
split the black list with comma
update on 2022/06/07
If you use gradle 7, it change to android.jetifier.ignorelist

TeamCity, Android, Gradle Script failure

I have been struggling to get TeamCity to build my Android Project. I have finally gotten the server to be able to compile the project with Gradlew (although I have to ignore lint errors, which I am not happy about - it will not tell me which lint errors are being violated EDIT: I found it in ..\build\outputs\lint-results.html)
But now I can see that it is trying to execute the following:
C:\TeamCity\buildAgent\work\284714bad9f1a533\MyProject>gradlew.bat --init-script C:\TeamCity\buildAgent\plugins\gradle-runner\scripts\init.gradle clean build
And I am getting the following error:
FAILURE: Build failed with an exception.
* Where:
Initialization script 'C:\TeamCity\buildAgent\plugins\gradlerunner\scripts\init.gradle' line: 31
* What went wrong:
A problem occurred evaluating initialization script.
> Cannot invoke method split() on null object
I have checked this line and it seems fairly standard:
initscript {
dependencies {
def teamCityInitLib = System.getenv("TEAMCITY_BUILD_INIT_PATH")
println "Init lib: ${teamCityInitLib}"
def classPathFiles = teamCityInitLib.split(File.pathSeparator) //line 31
classpath files(classPathFiles)
}
}
Can anyone help me? NOTE: the following command works without a problem:
gradlew.bat clean build
Seems that you don't have TEAMCITY_BUILD_INIT_PATH variable in your PATH on your build machine. You can add it either by standart ways, depending on OS, or by adding it to Build Parameters in Configuration Steps of your build.
It seems like the build file is not being found. At least, that is what support is telling me. To me this is a TeamCity bug and not on my side. When I find out more, I'll post it.
Found this post while looking for a way to emulate a TC build from the command line and trying to understand how to set TEAMCITY_BUILD_INIT_PATH.
In my environment I determined that it's set to:
/apps/teamcity-agent/agent/lib/serviceMessages.jar:/apps/teamcity-agent/agent/lib/runtime-util.jar:/apps/teamcity-agent/agent/plugins/gradle-runner/lib/gradle-runner-common.jar
Where /apps/teamcity-agent is the my TC install path.
Hope this helps.

Categories

Resources