Les gars Je n'arrive pas à lancer mon application. S'il vous plaît aider.java - Android Studio - Impossible d'instancier l'activité
Voici l'erreur: enter image description here
Voici mon fichier MainActivity:
package com.example.aman.text_to_speech;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.speech.tts.TextToSpeech;
import android.widget.EditText;
import java.util.Locale;
public class MainActivity extends AppCompatActivity
{
TextToSpeech tt;
EditText ed = (EditText)findViewById(R.id.editText);
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tt = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener()
{
public void onInit(int status)
{
if(status != TextToSpeech.ERROR)
tt.setLanguage(new Locale("hi", "IN"));
}
});
}
public void speak_my_text(View vv)
{
String string = ed.getText().toString();
tt.speak(string,TextToSpeech.QUEUE_FLUSH,null,null);
}
}
Voici mon fichier AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.aman.text_to_speech">
<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">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Voici mon fichier application:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.aman.text_to_speech"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
Je ne reçois pas mon erreur de syntaxe, je ne reçois que l'erreur dans le logcat. Alors les gars, j'ai vraiment besoin d'aide pour mon application. Si quelqu'un peut me donner des suggestions, ce sera une aide précieuse. Merci
Postez n'importe quel texte pertinent dans votre question. Ne postez pas de captures d'écran. – shmosel
N'étiez-vous pas capable de lire ?? Im en utilisant la capture d'écran pour afficher l'erreur sur l'émulateur ainsi –
[Pourquoi ne pas télécharger des images de code sur SO lors de la pose d'une question?] (Https://meta.stackoverflow.com/a/285557/1553851) – shmosel