hms-core / hms-codelabs Goto Github PK
View Code? Open in Web Editor NEWHMS Core samples for codelabs
Home Page: https://developer.huawei.com/consumer/en/community/codelabs
License: Apache License 2.0
HMS Core samples for codelabs
Home Page: https://developer.huawei.com/consumer/en/community/codelabs
License: Apache License 2.0
I have a project using kotlin multiplatform. When I start the configuration wizard Android App Module list is empty.
I have Been trying to integrate Realtime text translation API Into my app. I followed the documentation but Upon testing application crashes saying to set the app API key
These are crash logs
Process: com.sotec.translate.app.huawei, PID: 14445
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:321)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:246)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.Error: please set your app apiKey
at com.huawei.hms.mlsdk.common.MLApplication.getApiKey(MLApplication.java:412)
at com.huawei.hms.mlsdk.common.MLApplication.getAuthorizationToken(MLApplication.java:381)
at com.huawei.hms.mlsdk.translate.p.j.a(RestClientContext.java:12)
at com.huawei.hms.mlsdk.translate.p.l$b.(RestClientRequestHeaders.java:16)
at com.huawei.hms.mlsdk.translate.p.l$b.(RestClientRequestHeaders.java:1)
at com.huawei.hms.mlsdk.translate.cloud.MLRemoteTranslator.c(MLRemoteTranslator.java:16)
at com.huawei.hms.mlsdk.translate.cloud.MLRemoteTranslator.a(MLRemoteTranslator.java:25)
at com.huawei.hms.mlsdk.translate.cloud.MLRemoteTranslator.syncTranslate(MLRemoteTranslator.java:1)
at com.translate.languagetranslator.freetranslation.network.TranslationUtils.callUrlAndParseResult(TranslationUtils.java:72)
at com.translate.languagetranslator.freetranslation.network.TranslationUtils.doInBackground(TranslationUtils.java:38)
at com.translate.languagetranslator.freetranslation.network.TranslationUtils.doInBackground(TranslationUtils.java:18)
I have enabled the MLKit service from Console As is mentioned here
.
**Below is the code I Used **
` private String callUrlAndParseResult(String langFrom, String langTo, String word)
throws Exception {
// Create a text translator using custom parameter settings.
MLRemoteTranslateSetting setting = new MLRemoteTranslateSetting
.Factory()
// Set the source language code. The BCP-47 standard is used for Traditional Chinese, and the ISO 639-1 standard is used for other languages. This parameter is optional. If this parameter is not set, the system automatically detects the language.
.setSourceLangCode(langFrom)
// Set the target language code. The BCP-47 standard is used for Traditional Chinese, and the ISO 639-1 standard is used for other languages.
.setTargetLangCode(langTo)
.create();
MLRemoteTranslator mlRemoteTranslator = MLTranslatorFactory.getInstance().getRemoteTranslator(setting);
try {
return mlRemoteTranslator.syncTranslate(word);
// Processing logic for recognition success.
} catch (MLException mlException) {
// Processing logic for detection failure.
// Obtain the result code. You can process the result code and customize respective messages displayed to users.
int errorCode = mlException.getErrCode();
// Obtain the error information. You can quickly locate the fault based on the result code.
return errorCode+mlException.getMessage();
}finally {
if (mlRemoteTranslator!= null) {
mlRemoteTranslator.stop();
}
}
}
`
Please Guide Me what I am Doing Wrong, Because I cannot find any help anywhere else.
I've tried this sample and I encountered a problem:
Why HMS PushKit needs android.permission.REQUEST_INSTALL_PACKAGES
How you doinβ π
Can screenshots be added to the all Readme pages?
If there are screenshots, more detailed information about the project will be provided.
Happy working π₯³
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.