I am making an Android application for translating into English, and so far I have used the voice recognition function to enter voice into a string. Now I want to translate this line into another language and pronounce the translated text using the TTS Engine. I created a separate translate_test file for testing purposes only. I learn and know that an API key is required in Android Studio. So I created an API key and enabled the Google Cloud Translation API. Now I try to import com.google.cloud.translate.Translation into my MainActivity, but I get this error:
error
I NEED 10 REPUTATION POINTS TO ALLOW AN IMAGE THAT MAY BE SHOWN. All I can say is that the imported file does not exist.
I need help on how to include cloud files. I am studying online, but still cannot find a tutorial or any information on how to include cloud files in Android Studio. I even read the docs . I need help and I will be glad if someone can give me some simple steps.
This is my MainActivity.java file:
package com.example.aman.translate_test; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; import com.google.cloud.translate.Translation; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView tv = (TextView) findViewById(R.id.textView); } }
This is my AndroidManifest.xml file:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.aman.translate_test"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <uses-permission android:name="android.permission.INTERNET"/> <uses-library android:name="com.google.cloud.translate.Translate" /> <meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/api_key"/> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application>
source share