I enable the new D8 desuaring in Android Studio 3.1.3 in my gradle.properties:
android.enableD8.desugaring=true
Now the compilation fails with this error in one of the java-only modules:
com.android.tools.r8.errors.Unreachable:
Unexpected type adjustment from java.lang.String[] to java.lang.Object[]
Here is the full stack-trace
Note: the old dexer works fine (when I deactivate the option above)
I've checked the java-module and I cannot even find String[] or Object[] in any of the java-files. Adding --debug --scan also didn't give me any more insights in what the problem could be.
Any ideas what the problem can be or how I can get more detailed error info from the dexer: e.g. in which file the erroneous code is?
Although the reason could be any depends on project I want to share the way I have fixed such error:
rename failing jar to zip
run D8 directly on it, something like
D:\Development\Tools\android-sdk\build-tools\28.0.2\d8.bat D:\Development\<PROJECT_PATH>\build\intermediates\intermediate-jars\debug\classes.jar.zip
remove classes one by one from zip and go back step 2 until exception is gone
To speed up the process I was removing files in bulk to narrow down to the package and then to the exact file causing D8 failure.
As it turned out it was the following code (I'm using com.annimon.stream.Stream):
Stream.of(SOME_MAP).map(Map.Entry::getValue).findFirst().orElse(null);
where SOME_MAP is HashMap<String, String[]> and workaround was to use
Stream.of(SOME_MAP).map(entry -> entry.getValue()).findFirst().orElse(null);
Related
While running lint a strange error occurred. This appears to happen after a androidx.lifecycle update from 2.2.0 to 2.3.0:
../../src/main/java/my/project/MyService.kt: Unexpected failure during lint analysis of MyService.kt
(this is a bug in lint or one of the libraries it depends on)
Message: org.jetbrains.uast.UastErrorType cannot be cast to com.intellij.psi.PsiClassType
The crash seems to involve the detector androidx.lifecycle.lint.NonNullableMutableLiveDataDetector.
You can try disabling it with something like this:
android {
lintOptions {
disable "NullSafeMutableLiveData"
}
}
Stack: ClassCastException:NonNullableMutableLiveDataDetector.visitMethodCall(NonNullableMutableLiveDataDetector.kt:103)
←UElementVisitor$DelegatingPsiVisitor.visitMethodCallExpression(UElementVisitor.kt:1079)
←UElementVisitor$DelegatingPsiVisitor.visitCallExpression(UElementVisitor.kt:1059)
←UCallExpression$DefaultImpls.accept(UCallExpression.kt:85)
←UCallExpressionEx$DefaultImpls.accept(UCallExpression.kt:-1)
←KotlinUSimpleReferenceExpression$KotlinAccessorCallExpression.accept(KotlinUSimpleReferenceExpression.kt:129)
←KotlinUSimpleReferenceExpression.visitAccessorCalls(KotlinUSimpleReferenceExpression.kt:116)
←KotlinUSimpleReferenceExpression.accept(KotlinUSimpleReferenceExpression.kt:83)
You can set environment variable LINT_PRINT_STACKTRACE=true to dump a full stacktrace to stdout.
This issue type represents a problem running lint itself. Examples include failure to find bytecode for source files (which means certain detectors could not be run), parsing errors in lint configuration files, etc.
These errors are not errors in your own code, but they are shown to make it clear that some checks were not completed.
To suppress this error, use the issue id "LintError" as explained in the Suppressing Warnings and Errors section.
When I disable NullSafeMutableLiveData - as suggested - the error doesn't occur anymore, great! But I wonder where this issue comes from and if there's a better solution than simply ignoring that specific check completely. Is it a bug in the androidx.lifecycle dependency I could report, or is it possible to somehow conflict with an error in my project I could fix? (if so, any advice finding out where?)
Note: this only happened when lint was run on Bitrise, I didn't encounter this when running lint in Android Studio. Not sure if this is somehow related though.
This is the error:
Note that these strings can lead to crashes if the string is looked up on
any locale not providing a translation, so it's important to clean them
up.
657 errors, 0 warnings
Gradle build finished with 657 error(s) and 10 warning(s) in 4h 33m 28s 959ms
Any idea why this might?
Okey... then I think the error is in your string.xml...
you have to include all strings in your string.xml and string-xx.xml..
Even if you are not translating all strings, you have to keep the string in both xml files...
Hope you got me...
I'm currently building an android application using ANT on a Jenkins server.
DexGuard is set to run on release in the custom_rules.xml.
Currently there is an issue when DexGuard tries to convert a method:
[dexguard] Unexpected error while converting:
[dexguard] Class = [o/?]
[dexguard] Method = [?(Ljava/lang/String;)Lo/?;]
[dexguard] Exception = [java.lang.IllegalStateException] (Variable v17 too large for instruction [neg-int v17, v17])
[dexguard] java.lang.IllegalStateException: Variable v17 too large for instruction [neg-int v17, v17]
...
Stack trace
...
[dexguard] Not converting this method
My question is, is there a way to get DexGuard to exit with an error status so that either ANT or Jenkins can mark the build as failed?
At the moment it simply prints the stack trace and continues.
I am currently using the Text-finder plugin for Jenkins as a post build step to match a DexGuard exception. If found it downgrades the build to failed.
DexGuard currently ignores methods that it can't convert from Java bytecode to Dalvik bytecode, for any reason -- notably corrupt input code. In this case, it looks more like a bug in DexGuard itself. We'll fix it as soon as possible, and we'll consider adding a flag to stop with an error status.
(I am the lead developer of ProGuard and DexGuard)
I have been trying to port my first iOS app to Android with apportable.
I have solved alot of warnings and errors but cannot get rid of this last one.
The App I made is a fitness application for jogging so it uses CoreLocation.
Everything looks good when I run apportable now except this last error:
Build/android-armeabi-debug/com.apptonix.easyrunner/testTabbedWithCore/libtestTabbedWithCore.a(DetailViewController.m.o):/Users/peterbodlund/Documents/xcodeprojects/Training/inlamning5/testTabbedWithCore/testTabbedWithCore/DetailViewController.m:function L_OBJC_CLASSLIST_REFERENCES_$_114: error: undefined reference to 'OBJC_CLASS_$_MKPinAnnotationView'
scons: * [Build/android-armeabi-debug/EasyRunner/apk/lib/armeabi/libverde.so] Error 1
scons: building terminated because of errors.
Exception AttributeError: "'NoneType' object has no attribute 'pack'" in > ignored
Usually this is an indicator that there were link errors. Check your output higher up and look for missing symbol errors.
The build log is confusing because the build is parallel by default.
Add the option -j1 to cause the build to stop immediately after the first error.
When trying to build my android project I get the following error. I've been able to compile without complain on other machines with (what I believe to be) the exact same setup (ubuntu 11.10/eclipse indigo/same android sdk)
Unable to execute dex: java.lang.StackOverflowError. Check the Eclipse log for stack trace.
Conversion to Dalvik format failed: Unable to execute dex: java.lang.StackOverflowError. Check the Eclipse log for stack trace.
In the eclipse log all I get is about 2 pages of :
java.lang.StackOverflowError
at com.android.dx.cf.code.Ropper$2.visitBlock(Ropper.java:1310)
at com.android.dx.cf.code.Ropper.forEachNonSubBlockDepthFirst0(Ropper.java:1647)
at com.android.dx.cf.code.Ropper.forEachNonSubBlockDepthFirst0(Ropper.java:1671)
at com.android.dx.cf.code.Ropper.forEachNonSubBlockDepthFirst0(Ropper.java:1671)
at com.android.dx.cf.code.Ropper.forEachNonSubBlockDepthFirst0(Ropper.java:1671)
...
Any suggestions would be greatly appreciated. :)
Edit:
Searching the log files I also found that I got this error right before.
Warning: A handler conflict occurred. This may disable some commands.
Conflict for 'org.eclipse.ltk.ui.refactor.apply.refactoring.script':
HandlerActivation(commandId=org.eclipse.ltk.ui.refactor.apply.refactoring.script,
handler=ActionDelegateHandlerProxy(null,org.eclipse.ltk.ui.refactoring.actions.ApplyRefactoringScriptAction),
expression=AndExpression(ActionSetExpression(org.eclipse.cdt.ui.CodingActionSet,org.eclipse.ui.internal.WorkbenchWindow#9801f4),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow#9801f4)),sourcePriority=16640)
HandlerActivation(commandId=org.eclipse.ltk.ui.refactor.apply.refactoring.script,
handler=ActionDelegateHandlerProxy(null,org.eclipse.jdt.internal.ui.refactoring.actions.ApplyRefactoringScriptAction),
expression=AndExpression(ActionSetExpression(org.eclipse.jdt.ui.CodingActionSet,org.eclipse.ui.internal.WorkbenchWindow#9801f4),WorkbenchWindowExpression(org.eclipse.ui.internal.WorkbenchWindow#9801f4)),sourcePriority=16640)
I had got the same error and was able to solve it... Hope it helps you...
Look in the bin folder of your project directory and you will see .dex files generated.. Delete them and try to run your project again...