Code Monkey home page Code Monkey logo

hms-codelabs's People

Contributors

healthkit-hms avatar hms-mlkit avatar hms-scankit avatar hmspushkit avatar huawei-mobile-services-core avatar liangfu123 avatar lulala703 avatar mike-mei avatar zwx747425 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hms-codelabs's Issues

Please set your app apiKey

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.

Can screenshots be added to the Readme?

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 πŸ₯³

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.