Kotlin jetpack compose impossible to compile Backend Exception - android-jetpack-compose

my project does not compile with this stacktrace:
org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
File being compiled: myApp/navigation/NavGraph.kt
The root cause java.lang.RuntimeException was thrown at: org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:50)
at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException(CodegenUtil.kt:239)
at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException$default(CodegenUtil.kt:235)
at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invokeSequential(performByIrFile.kt:68)
at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(performByIrFile.kt:55)
at org.jetbrains.kotlin.backend.common.phaser.PerformByIrFilePhase.invoke(performByIrFile.kt:41)
at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:96)
at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:29)
at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:96)
at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:29)
at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:96)
at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.invokeToplevel(CompilerPhase.kt:43)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.doGenerateFilesInternal(JvmIrCodegenFactory.kt:195)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:60)
at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:331)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:123)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:58)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:170)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:92)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.RuntimeException: Exception while generating code for:
FUN name:SetupNavGraph visibility:public modality:FINAL <> (navController:androidx.navigation.NavHostController, viewModel:androidx.lifecycle.ViewModel, $composer:androidx.compose.runtime.Composer?, $changed:kotlin.Int) returnType:kotlin.Unit
With my class being
#OptIn(ExperimentalCoroutinesApi::class)
#Composable
fun SetupNavGraph(
navController: NavHostController,
viewModel: ViewModel
) {
NavHost(
navController = navController,
startDestination = Screen.Splash.route
) {
composable(
route = Screen.Splash.route
) {
SplashScreen(
navController = navController,
viewModel = viewModel as MainActivityViewModel
)
}
composable(
route = Screen.Map.route
) {
MapScreen(
)
}
}
}
I do not find any hint online and don't know what to do.
Note that the project compiled at least once before and my current work does not touch this kotlin file.

Related

Getting Error while testing LiveData observer in AndroidTest : java.lang.IllegalStateException: Cannot invoke observeForever on a background thread

Here tried running this code but returns above error when used any Dispatcher(Main, IO) on runTest, runBlockingTest. Only using runBlocking returns Different Error LiveData Value TimeOut error, Value is never set.
fun checkIfStringTranslated() {
val translateString = TranslateString("मेरा नाम नवनीत हैं।", "", TranslateLanguage.ENGLISH)
val translatedLiveData = translateString.getTranslation()
testScope.runTest {
Dispatchers.setMain(UnconfinedTestDispatcher(testScheduler))
try{ val result = translatedLiveData.getOrAwaitValue()
assertThat(result).isEqualTo("My name is ")
}finally {
Dispatchers.resetMain()
}
}}
This TranslateString.getTranslation() observes liveData of translatedText from MLkit translate.

Unable to move jira support ticket to Done status using Rest Client

I am using Java rest client with following maven dependency:
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-app</artifactId>
<version>5.2.0</version>
</dependency>
And the following code:
void markDuplicateAndClose(IssueRestClient client, ...) {
...
Iterable<Transition> transitions = client.getTransitions(duplicateIssue.getTransitionsUri()).claim();
Transition doneTransition = getTransitionByName(transitions, "Done");
String requiredFieldId = null;
for (Field f : doneTransition.getFields()) {
if (f.isRequired())
requiredFieldId = f.getId();
};
Collection<FieldInput> fieldInputs = Arrays.asList(new FieldInput(requiredFieldId, "Duplicate"));
TransitionInput ti = new TransitionInput(doneTransition.getId(), fieldInputs);
promise = client.transition(keyToIssuesMap.get(duplicate), ti).claim();
...
}
private Transition getTransitionByName(Iterable<Transition> transitions, String stateName) {
for (Transition t: transitions) {
if (t.getName().equals(stateName))
return t;
}
return null;
}
However, I get the following error:
Exception in thread "main" RestClientException{statusCode=Optional.of(400), errorCollections=[ErrorCollection{status=400, errors={customfield_10212=Could not find valid 'id' or 'value' in the Parent Option object.}, errorMessages=[]}]}
at com.atlassian.jira.rest.client.internal.async.DelegatingPromise.claim(DelegatingPromise.java:45)
at com.xyz.jira_accessor.jira.Util.markDuplicates(Util.java:109)
at com.xyz.jira_accessor.jira.Util.main(Util.java:132)
Caused by: RestClientException{statusCode=Optional.of(400), errorCollections=[ErrorCollection{status=400, errors={customfield_10212=Could not find valid 'id' or 'value' in the Parent Option object.}, errorMessages=[]}]}
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$2.apply(AbstractAsynchronousRestClient.java:176)
What is wrong with my code?
As discussed in below comments, I tried to see the underlying codes for the option:
Option shown as compulsory on the UI
HTML from Chrome Debugger for the same:
And so I changed the above code to:
Collection<FieldInput> fieldInputs = Arrays.asList(new FieldInput("customfield_11607", "12091"));
TransitionInput ti = new TransitionInput(doneTransition.getId(), fieldInputs);
promise = client.transition(keyToIssuesMap.get(duplicate), ti).claim();
But it still did not work.
Just that the error message changed to:
errors={customfield_11607=Could not find valid 'id' or 'value' in the Parent Option object.}
(To Jira Team) Can you make the error messages bit more meaningful and simplify the API please? It is very hard to figure out things. Or at least, provide some more examples which are easily searchable on the Internet.

VaadinOnKotlin.dataSource undefined

I'm new to web development and started experimenting with VaadinOnKotlin. In Bootstrap.kt I have this code
val cfg = HikariConfig().apply {
jdbcUrl = "jdbc:postgresql://localhost:5432/test_db"
username = "joe"
password = "public"
}
cfg.driverClassName = org.postgresql.Driver::class.java.getName()
JdbiOrm.setDataSource(HikariDataSource(cfg))
VaadinOnKotlin.init()
val flyway = Flyway.configure()
.dataSource(VaadinOnKotlin.dataSource)
.load()
flyway.migrate()
VaadinOnKotlin.dataSource or VaadinOnKotlin.getDataSource() are undefined.
They get defined if I import eu.vaadinonkotlin.sql2o.dataSource, but doing that causes following crash
java.lang.NoSuchMethodError: 'void com.github.vokorm.VokOrm.init()'
at eu.vaadinonkotlin.sql2o.VokOrmPlugin.init(VokOrmPlugin.kt:12) ~[na:na]
at eu.vaadinonkotlin.VaadinOnKotlin.init(VaadinOnKotlin.kt:17) ~[na:na]
at com.smartiops.epsilon.Bootstrap.contextInitialized(Bootstrap.kt:59) ~[na:na]
Could this be a version issue? I see this in my build.gradle.kts
plugins {
kotlin("jvm") version "1.3.72"
id("org.gretty") version "3.0.3"
war
id("com.vaadin") version "0.8.0"
}
thanks for your help
I figured out what I was doing wrong. In build.gradle.kts I had to add
dependencies {
implementation("eu.vaadinonkotlin:vok-framework-vokdb:0.8.2")
}
and in Bootstrap.kts I had to add
import eu.vaadinonkotlin.vokdb.dataSource

Can I load custom jsm modules in bootstrap.js of a restartless add-on?

I'm trying to load a custom module in a restartless add-on, using the following:
chrome/content/modules/Test.jsm:
var EXPORTED_SYMBOLS = [ 'Test' ];
let Test = {};
chrome.manifest:
content test chrome/content/
bootstrap.js:
const Cu = Components.utils;
// Tried this first, but figured perhaps chrome directives aren't loaded here yet
// let test = Cu.import( 'chrome://test/modules/Test.jsm', {} ).Test;
function install() {
let test = Cu.import( 'chrome://test/modules/Test.jsm', {} ).Test;
}
function uninstall() {
let test = Cu.import( 'chrome://test/modules/Test.jsm', {} ).Test;
}
function startup() {
let test = Cu.import( 'chrome://test/modules/Test.jsm', {} ).Test;
}
function shutdown() {
let test = Cu.import( 'chrome://test/modules/Test.jsm', {} ).Test;
}
However, I get the following types of WARN messages (this one was for shutdown(), but basically identical for all functions and in the earlier attempt in the global scope):
1409229174591 addons.xpi WARN Exception running bootstrap method
shutdown on test#extensions.codifier.nl: [Exception... "Component
returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE)
[nsIXPCComponents_Utils.import]" nsresult: "0x80070057
(NS_ERROR_ILLEGAL_VALUE)" location: "JS frame ::
resource://gre/modules/addons/XPIProvider.jsm ->
file:///test/bootstrap.js :: shutdown :: line 21" data: no] Stack
trace: shutdown()#resource://gre/modules/addons/XPIProvider.jsm ->
file:///test/bootstrap.js:21 <
XPI_callBootstrapMethod()#resource://gre/modules/addons/XPIProvider.jsm:4232
<
XPI_updateAddonDisabledState()#resource://gre/modules/addons/XPIProvider.jsm:4347
<
AddonWrapper_userDisabledSetter()#resource://gre/modules/addons/XPIProvider.jsm:6647
< uninstall()#extensions.xml:1541 < oncommand()#about:addons:1 <
Are chrome.manifest directives not yet available in bootstrap.js? Or is what I am attempting some kind of security violation, perhaps? Or am I simply doing something trivially wrong?
What I was hoping to achieve, is that I could do something like the following:
chrome/content/modules/Test.jsm:
var EXPORTED_SYMBOLS = [ 'Test' ];
let Test = {
install: function( data, reason ) {
},
/* etc */
bootstrap: function( context ) {
context.install = this.install;
context.uninstall = this.uninstall;
context.startup = this.startup;
context.shutdown = this.shutdown;
}
}
bootstrap.js:
const Cu = Components.utils;
Cu.import( 'chrome://test/modules/Test.jsm' );
Test.bootstrap( this );
Perhaps it's a bit over the top to begin with, but I just kind of like the idea of hiding implementations in modules and/or objects and keeping bootstrap.js super clean.
If you happen to have suggestions on how to achieve this by other means: I'm all ears.
Yes you can your path is wrong though.
Just do this:
let test = Cu.import( 'chrome://test/content/modules/Test.jsm', {} ).Test;
notice the /content/
You don't have to do the .Test unless you want the lower case test to hold it. You can just do:
Cu.import( 'chrome://test/content/modules/Test.jsm');
and use as Test.blah where blah is whatever is in the JSM module.
This code can go anywhere, it does not have to be in the install function.
Make sure to unload the custom JSM modules or else it can lead to zombie compartments which is bad for memory. Read here:
last paragraph here: https://developer.mozilla.org/en-US/docs/Extensions/Common_causes_of_memory_leaks_in_extensions
more reading but optional: https://developer.mozilla.org/en-US/docs/Zombie_compartments
Beyond #Noitidart's answer, you don't have to use chrome.manifest' and register a content package if your only concern is how to import your module.
function install(data, reason) {
Components.utils.import(data.resourceURI.spec + "relative/path/to/your/module.jsm");
}

Dart cannot access cloud endpoint API

It's frustrating and I'm stuck here for one week and no clue how to fix it ; (
Inspired by Gerwin Sturm's great work (https://github.com/Scarygami/gdg-endpoint-demo) and I like to build the java backend instead.
But unfortunately, every time when I'm trying to call the endpoints API, a NoSuchMethodError error arise.
Exception: NoSuchMethodError : method not found: '_client#0x296594a'
Receiver: Instance of 'Dbentryendpoint'
Arguments: []
Stack Trace: #0 Object.noSuchMethod (dart:core-patch:1737:25)
#1 Dbentryendpoint.listDBEntry (http://127.0.0.1:3030/C:/Users/VincentZhou/dart/dart_dbentryendpoint_v1_api_client/packages/google_dbentryendpoint_v1_api/src/browser/dbentryendpoint.dart:162:16)
#2 main.fetch (http://127.0.0.1:3030/C:/Users/VincentZhou/dart/dart_dbentryendpoint_v1_api_client/demo.dart:24:20)
#3 main (http://127.0.0.1:3030/C:/Users/VincentZhou/dart/dart_dbentryendpoint_v1_api_client/demo.dart:64:8)
Exception: NoSuchMethodError : method not found: '_client#0x296594a'
Receiver: Instance of 'Dbentryendpoint'
Arguments: []
Stack Trace: #0 Object.noSuchMethod (dart:core-patch:1737:25)
#1 Dbentryendpoint.insertDBEntry (http://127.0.0.1:3030/C:/Users/VincentZhou/dart/dart_dbentryendpoint_v1_api_client/packages/google_dbentryendpoint_v1_api/src/browser/dbentryendpoint.dart:124:16)
#2 main.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (http://127.0.0.1:3030/C:/Users/VincentZhou/dart/dart_dbentryendpoint_v1_api_client/demo.dart:56:28)
the source code of demo.dart is almost identical to the original one (https://github.com/Scarygami/gdg-endpoint-demo) and I only change the cloudendpint API and web client ID.
import "dart:html";
import 'packages/google_dbentryendpoint_v1_api/dbentryendpoint_v1_api_browser.dart' as gdglib;
import 'packages/google_plus_v1_api/plus_v1_api_browser.dart' as pluslib;
import 'packages/google_oauth2_client/google_oauth2_browser.dart';
final CLIENT_ID = "878766780041.apps.googleusercontent.com";
final SCOPES = ["https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/plus.me"];
void main() {
var auth = new GoogleOAuth2(CLIENT_ID, SCOPES);
var gdg = new gdglib.Dbentryendpoint(auth);
var plus = new pluslib.Plus(auth);
var container = query("#entries");
var loginButton = query("#login");
var sendButton = query("#send");
InputElement textInput = query("#text");
var authorSpan = query("#author");
pluslib.Person me;
void fetch() {
//gdg.makeAuthRequests = false;
gdg.makeAuthRequests = true;
gdg.listDBEntry(limit:10).then((l) {
container.text = "";
if (l.items != null) {
l.items.forEach((e) {
var p = new ParagraphElement();
var date = e.date.replaceAll("T", " ");
p.text = "$date - ${e.author}: ${e.text}";
container.append(p);
});
}
});
}
loginButton.onClick.listen((Event e) {
auth.login().then((token) {
loginButton.style.display = "none";
plus.makeAuthRequests = true;
plus.people.get("me").then((p) {
me = p;
authorSpan.text = "${me.displayName}:";
authorSpan.style.display = "inline-block";
textInput.style.display = "inline-block";
sendButton.style.display = "inline-block";
sendButton.onClick.listen((Event e) {
var text = textInput.value;
textInput.value = "";
var entry = new gdglib.DBEntry.fromJson({
"author": me.displayName,
"text": text
});
gdg.makeAuthRequests = true;
gdg.insertDBEntry(entry).then((entry) {
fetch();
});
});
});
});
});
on the Google App Engine side, I generate the cloud endpoint class automatically by the GPE and then add the client ID related info:
#Api(name = "dbentryendpoint",
clientIds={Ids.WEB_CLIENT_ID,com.google.api.server.spi.Constant.API_EXPLORER_CLIENT_ID},
scopes={"https://www.googleapis.com/auth/userinfo.email"}
)
public class DBEntryEndpoint {
.....
Appreciate for any help!
I think I figure out the way to work around it but I don't know why:
the "generate cloud endpoints" of GPE doesn't generate the path,
for example it generate the method listEntities, not entities.list
the path is necessary to generate resource in
_ah/api/discovery/v1/apis/dbentryendpoint/v1/rest; without path ,there is only schemas and methods, not schemas and resources
without resources, the Dart client generator only export empty
resouces.dart under /commom folder. and the mothods will be inside
entityEndpoints.dart, which cannot correctly recognize the
_client(), which is defined in client.dart under /common.
So the demo.dart cannot find the method.
Question: why the path is ncessary? because GPE dont generate the path automatically, can we have a way to generate the correct dart client file without manually adding the path in google app engine file? Thanks.
The package import does not look correct, try this.
import 'packages:google_dbentryendpoint_v1_api/dbentryendpoint_v1_api_browser.dart' as gdglib;
import 'packages:google_plus_v1_api/plus_v1_api_browser.dart' as pluslib;
import 'packages:google_oauth2_client/google_oauth2_browser.dart';

Resources