简体   繁体   English

我正在编写我的第一个 Android 应用程序,我突然收到一页又一页的错误消息,我无法理解

[英]I am writing my first Android app and I am suddenly getting pages and pages of error messages that I can't make head or tail of

The game is supposed to read items in from an array and then display text boxes to the user to guess the letters of the word.游戏应该从数组中读取项目,然后向用户显示文本框以猜测单词的字母。 All went fine until I added in the line lr2.addView(edT);一切顺利,直到我在 lr2.addView(edT); 行中添加; I am not sure why or what went wrong.我不确定为什么或出了什么问题。 Any help would be much appreciated.任何帮助将非常感激。 By the way, I made sure everything was updated, etc.顺便说一句,我确保所有内容都已更新,等等。

package com.example.riva.fruitguessinggame;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.text.InputFilter;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import java.util.Random;


public class MainActivity extends Activity implements View.OnClickListener {

String fruits[] = {"apple", "lemon", "peach", "melon", "banana", "orange"};
char letters[];
String fruit;
EditText edT;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    LinearLayout ll = new LinearLayout(this);
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.setBackgroundColor(Color.GRAY);

    LinearLayout.LayoutParams edtTxtLayout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    edtTxtLayout.setMargins(5, 5, 10, 5);

    LinearLayout lr1 = new LinearLayout(this);
    LinearLayout lr2 = new LinearLayout(this);
    TextView tv1 = new TextView(this);

    // First row with instructions.
    tv1.setText("Guess the name of the fruit by filling in the boxes.");
    tv1.setTextSize(16f);
    tv1.setTextColor(Color.BLUE);
    tv1.setPadding(5,5,5,10);
    lr1.addView(tv1);

    // Choose a random fruit from the array
    int idx = new Random().nextInt(fruits.length);
    fruit = (fruits[idx]);

    edT = new EditText(this.getApplicationContext());

    // Loop through the item, creating a text box for each letter, second row
    for(int i=0; i<fruit.length(); i++){
        edT.setId(i);
        edT.setTextSize(20f);
        edT.setBackgroundColor(Color.WHITE);
        edT.setEms(2);
        edT.setTextColor(Color.BLUE);
        edT.setFilters(new InputFilter[]{new InputFilter.AllCaps()});
        edT.setLayoutParams(edtTxtLayout);
        edT.setOnClickListener(this);
        lr2.addView(edT);

        // Read the letters of the fruit name into an array
        letters = fruit.toCharArray();

    }

    lr2.setGravity(1);

    ll.addView(lr1);
    ll.addView(lr2);

    setContentView(ll);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

@Override
public void onClick(View v) {
    checkLetter();
}

private void checkLetter() {
    int a = edT.getId();


}

} }

The error messages are:错误消息是:

    --------- beginning of /dev/log/main
06-26 14:32:27.150    2342-2483/? E/SmartFaceManager﹕ checkForSmartStay S
06-26 14:32:27.170    2342-2580/? E/SecCamera-JNI-Java﹕ SecCamera.open()
06-26 14:32:27.175    2342-2580/? E/SecCamera-JNI-Java﹕ SecCamera()
06-26 14:32:27.395    1933-1933/? E/ISecCameraHardware﹕ FocusMode=infinity, PrevFocusMode=infinity
06-26 14:32:27.395    1933-2330/? E/ISecCameraHardware﹕ preview window is NULL!
06-26 14:32:27.545    2342-7910/? E/SmartFaceManager﹕ Listener does not implements SmartFaceInfoListener2
06-26 14:32:27.720    2342-2582/? E/SmartScreen_JNI﹕ processImage start : prev time [ 117920485 ]
06-26 14:32:27.910    2342-2582/? E/SmartScreen_JNI﹕ processImage end : function time [ 188584 ] [-1]
06-26 14:32:27.910    2342-2582/? E/SmartScreen_JNI﹕ processImage start : prev time [ 189523 ]
06-26 14:32:27.910    2342-7910/? E/SmartFaceManager﹕ checkForSmartStay onInfo: 100: 0
06-26 14:32:28.040    2342-2582/? E/SmartScreen_JNI﹕ processImage end : function time [ 127923 ] [-1]
06-26 14:32:28.040    2342-7910/? E/SmartFaceManager﹕ checkForSmartStay onInfo: 100: 0
06-26 14:32:28.205    2342-2483/? E/SmartFaceManager﹕ checkForSmartStay X: false
06-26 14:32:36.160    2342-2482/? E/SEC PowerHAL﹕ sysfs_write : Error opening /sys/class/input/input1/enabled: No such file or directory
06-26 14:32:36.160    2342-2482/? E/SEC PowerHAL﹕ sysfs_write : Error opening /sys/class/input/input8/enabled: No such file or directory
06-26 14:32:36.985    2809-2809/? E/NfcService﹕ callback == null
06-26 14:32:41.315    2342-2459/? E/KeyguardHostView﹕ KeyguardHostView()
06-26 14:32:41.605    2342-2459/? E/KeyguardShortcutView﹕ density = 320
06-26 14:32:41.840    2342-2459/? E/LSO﹕ LSO Service is not yet ready!!!
06-26 14:32:41.840    2342-2459/? E/LSO﹕ LSO Service is not yet ready!!!
06-26 14:32:41.840    2342-2459/? E/LSO﹕ LSO Service is not yet ready!!!
06-26 14:32:41.840    2342-2459/? E/LSO﹕ LSO Service is not yet ready!!!
06-26 14:32:41.850    2342-2459/? E/LSO﹕ LSO Service is not yet ready!!!
06-26 14:32:41.850    2342-2459/? E/LSO﹕ LSO Service is not yet ready!!!
06-26 14:32:41.850    2342-2459/? E/LSO﹕ LSO Service is not yet ready!!!
06-26 14:32:41.850    2342-2459/? E/LSO﹕ LSO Service is not yet ready!!!
06-26 14:35:11.780    6232-6377/? E/SPPClientService﹕ [b] __PingReply__
06-26 14:35:17.365    7943-7943/? E/dalvikvm﹕ Could not find class 'android.app.job.JobScheduler', referenced from method com.android.email.service.s.a
06-26 14:35:17.370    7943-7943/? E/dalvikvm﹕ Could not find class 'android.app.job.JobScheduler', referenced from method com.android.email.service.s.b
06-26 14:35:17.730    7943-7967/? E/Gmail﹕ Error finding the version of the Email provider.....
android.content.pm.PackageManager$NameNotFoundException: com.google.android.email
        at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:103)
        at com.google.android.gm.EmailMigrationService.a(SourceFile:1279)
        at com.google.android.gm.EmailMigrationService.onHandleIntent(SourceFile:219)
        at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:176)
        at android.os.HandlerThread.run(HandlerThread.java:61)
06-26 14:38:34.075    6232-6232/? E/SPPClientService﹕ [[PushClientService]] F:false, D:false, E:false, T:false, S:true, R:false
06-26 14:40:34.050    1930-2015/? E/SecTVOutService﹕ virtual void android::SecTVOutService::setHdmiStatus(uint32_t)::mSecHdmi.connect() fail
06-26 14:40:34.060    2342-2482/? E/SEC PowerHAL﹕ sysfs_write : Error opening /sys/class/input/input1/enabled: No such file or directory
06-26 14:40:34.070    2342-2482/? E/SEC PowerHAL﹕ sysfs_write : Error opening /sys/class/input/input8/enabled: No such file or directory
06-26 14:40:35.050    2738-2898/? E/GLThread﹕ create surface
06-26 14:40:35.190    2809-2809/? E/NfcService﹕ callback == null
06-26 14:40:35.385    2823-2823/? E/Launcher﹕ Error finding setting, default accessibility to not found: accessibility_enabled
06-26 14:40:35.490    2342-4427/? E/EnterpriseContainerManager﹕ ContainerPolicy Service is not yet ready!!!
06-26 14:40:35.525    2809-2809/? E/NfcService﹕ callback == null
06-26 14:40:35.800    8037-8102/? E/notifySoException﹕ [kinfoc][8102] JNI_OnLoad env=0x57fd46c0
06-26 14:40:35.800    8037-8102/? E/notifySoException﹕ [kinfoc][8102] LoadCrashHandler succeed
06-26 14:40:36.185    2342-2816/? E/EnterpriseContainerManager﹕ ContainerPolicy Service is not yet ready!!!
06-26 14:40:36.295    8037-8126/? E/GooglePlayServicesUtil﹕ The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
06-26 14:40:36.840    8037-8037/? E/﹕ Device driver API match
Device driver API version: 23
User space API version: 23
06-26 14:40:36.840    8037-8037/? E/﹕ mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Wed Oct  9 21:05:57 KST 2013
06-26 14:40:39.570    2342-4427/? E/EnterpriseContainerManager﹕ ContainerPolicy Service is not yet ready!!!
06-26 14:40:40.780    2823-2823/? E/Launcher﹕ Error finding setting, default accessibility to not found: accessibility_enabled
06-26 14:40:41.080    2809-2809/? E/Parcel﹕ Reading a NULL string not supported here.
06-26 14:40:41.095    2342-2721/? E/EnterpriseContainerManager﹕ ContainerPolicy Service is not yet ready!!!
06-26 14:40:41.160    8185-8231/? E/notifySoException﹕ [kinfoc][8231] JNI_OnLoad env=0x4000fa48
06-26 14:40:41.170    8185-8231/? E/notifySoException﹕ [kinfoc][8231] LoadCrashHandler succeed
06-26 14:40:41.305    2738-2898/? E/GLThread﹕ create surface
06-26 14:40:41.795    8185-8267/? E/SYSCORE﹕ [virusengine][8267] LoadCrashHandler succeed
06-26 14:40:44.210    2342-2470/? E/android.os.Debug﹕ !@Dumpstate > sdumpstate -k -t -z -d -o /data/log/dumpstate_app_error
06-26 14:40:52.290    2823-2823/? E/Launcher﹕ Error finding setting, default accessibility to not found: accessibility_enabled
06-26 14:40:52.325    2738-2898/? E/GLThread﹕ create surface
06-26 14:40:53.610    2835-2835/? E/NetworkScheduler.SchedulerReceiver﹕ Invalid parameter app
06-26 14:40:53.610    2835-2835/? E/NetworkScheduler.SchedulerReceiver﹕ Invalid package name : Perhaps you didn't include a PendingIntent in the extras?
06-26 14:40:54.080    8500-8512/? E/SPPClientService﹕ ============PushLog. commonIsShipBuild. stop!
06-26 14:40:54.080    8500-8512/? E/SPPClientService﹕ [PushClientApplication] Push log off : This is Ship build version
06-26 14:40:54.405    8515-8515/? E/dalvikvm﹕ Could not find class 'android.app.Notification$Action$Builder', referenced from method b.a
06-26 14:40:54.475    8515-8515/? E/dalvikvm﹕ Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method b.a
06-26 14:40:54.555    2342-2470/? E/ViewRootImpl﹕ sendUserActionEvent() mView == null
06-26 14:40:54.560    2342-2342/? E/EnterpriseContainerManager﹕ ContainerPolicy Service is not yet ready!!!
06-26 14:40:54.595    8515-8515/? E/dalvikvm﹕ Could not find class 'android.app.Notification$Action$Builder', referenced from method b.a
06-26 14:40:54.625    8515-8515/? E/dalvikvm﹕ Could not find class 'android.transition.Transition', referenced from method b.a
06-26 14:40:54.625    8515-8515/? E/dalvikvm﹕ Could not find class 'android.transition.Transition', referenced from method b.a
06-26 14:40:54.630    8515-8515/? E/dalvikvm﹕ Could not find class 'android.transition.Transition', referenced from method b.a
06-26 14:40:54.695    8515-8515/? E/dalvikvm﹕ Could not find class 'android.app.RemoteInput[]', referenced from method b.a
06-26 14:40:54.710    8515-8515/? E/dalvikvm﹕ Could not find class 'android.transition.Transition', referenced from method b.b
06-26 14:40:55.325    8536-8536/? E/dalvikvm﹕ Could not find class 'android.app.Notification$Action$Builder', referenced from method f.a
06-26 14:40:55.330    8536-8536/? E/dalvikvm﹕ Could not find class 'android.app.RemoteInput$Builder', referenced from method f.a
06-26 14:40:55.345    8536-8536/? E/dalvikvm﹕ Could not find class 'android.transition.Transition', referenced from method f.a
06-26 14:40:55.375    8536-8536/? E/dalvikvm﹕ Could not find class 'android.app.Notification$Action$Builder', referenced from method f.a
06-26 14:40:55.390    8536-8536/? E/dalvikvm﹕ Could not find class 'android.transition.Transition', referenced from method f.a
06-26 14:40:55.390    8536-8536/? E/dalvikvm﹕ Could not find class 'android.transition.Transition', referenced from method f.a
06-26 14:40:55.390    8536-8536/? E/dalvikvm﹕ Could not find class 'android.transition.Transition', referenced from method f.a
06-26 14:40:55.390    8536-8536/? E/dalvikvm﹕ Could not find class 'android.transition.Transition', referenced from method f.a
06-26 14:40:55.400    8536-8536/? E/dalvikvm﹕ Could not find class 'android.app.RemoteInput[]', referenced from method f.a
06-26 14:40:55.420    8536-8536/? E/dalvikvm﹕ Could not find class 'android.transition.Transition', referenced from method f.b
06-26 14:40:55.430    8536-8536/? E/dalvikvm﹕ Could not find class 'com.google.android.apps.hangouts.telephony.TeleConnectionService', referenced from method f.i
06-26 14:40:55.430    8536-8536/? E/dalvikvm﹕ Could not find class 'android.telecom.TelecomManager', referenced from method f.k
06-26 14:40:55.545    8536-8556/? E/SQLiteLog﹕ (1) no such table: mmsconfig
06-26 14:40:55.555    8536-8556/? E/Babel﹕ canonicalizeMccMnc: invalid mccmnc nullnull
06-26 14:40:55.585    8536-8536/? E/dalvikvm﹕ Could not find class 'android.telecom.PhoneAccount$Builder', referenced from method cqf.e
06-26 14:40:55.585    8536-8536/? E/dalvikvm﹕ Could not find class 'android.telecom.TelecomManager', referenced from method cqf.g
06-26 14:40:55.620    8536-8536/? E/dalvikvm﹕ Could not find class 'com.google.android.libraries.hangouts.video.ScreenCaptureVideoSource$2', referenced from method com.google.android.libraries.hangouts.video.ScreenCaptureVideoSource.<init>
06-26 14:40:57.415    2835-2835/? E/NetworkScheduler.SchedulerReceiver﹕ Invalid parameter app
06-26 14:40:57.415    2835-2835/? E/NetworkScheduler.SchedulerReceiver﹕ Invalid package name : Perhaps you didn't include a PendingIntent in the extras?
06-26 14:40:59.855    8815-8827/? E/SPPClientService﹕ ============PushLog. commonIsShipBuild. stop!
06-26 14:40:59.855    8815-8827/? E/SPPClientService﹕ [PushClientApplication] Push log off : This is Ship build version
06-26 14:40:59.930    2835-2835/? E/AuthorizationBluetoothService﹕ Proximity feature is not enabled.
06-26 14:41:00.010    8624-8624/? E/dalvikvm﹕ Could not find class 'android.telecom.TelecomManager', referenced from method com.google.android.gms.wearable.service.y.a
06-26 14:41:00.090    2778-4155/? E/MDM﹕ [67] b.run: Couldn't connect to Google API client: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null}
06-26 14:42:45.510    2342-2483/? E/SmartFaceManager﹕ checkForSmartStay S
06-26 14:42:45.530    2342-2580/? E/SecCamera-JNI-Java﹕ SecCamera.open()
06-26 14:42:45.530    2342-2580/? E/SecCamera-JNI-Java﹕ SecCamera()
06-26 14:42:45.865    1933-2330/? E/ISecCameraHardware﹕ FocusMode=infinity, PrevFocusMode=infinity
06-26 14:42:45.865    1933-2331/? E/ISecCameraHardware﹕ preview window is NULL!
06-26 14:42:46.010    2342-8846/? E/SmartFaceManager﹕ Listener does not implements SmartFaceInfoListener2
06-26 14:42:46.195    2342-2582/? E/SmartScreen_JNI﹕ processImage start : prev time [ 618282716 ]
06-26 14:42:46.455    2342-2582/? E/SmartScreen_JNI﹕ processImage end : function time [ 260730 ] [-1]
06-26 14:42:46.455    2342-8846/? E/SmartFaceManager﹕ checkForSmartStay onInfo: 100: 0
06-26 14:42:46.455    2342-2582/? E/SmartScreen_JNI﹕ processImage start : prev time [ 261363 ]
06-26 14:42:46.570    2342-2582/? E/SmartScreen_JNI﹕ processImage end : function time [ 114892 ] [-1]
06-26 14:42:46.570    2342-8846/? E/SmartFaceManager﹕ checkForSmartStay onInfo: 100: 0
06-26 14:42:46.570    2342-2582/? E/SmartScreen_JNI﹕ processImage start : prev time [ 115594 ]
06-26 14:42:46.700    2342-2582/? E/SmartScreen_JNI﹕ processImage end : function time [ 131092 ] [-1]
06-26 14:42:46.755    2342-2483/? E/SmartFaceManager﹕ checkForSmartStay X: false
06-26 14:42:54.490    2342-2482/? E/SEC PowerHAL﹕ sysfs_write : Error opening /sys/class/input/input1/enabled: No such file or directory
06-26 14:42:54.490    2342-2482/? E/SEC PowerHAL﹕ sysfs_write : Error opening /sys/class/input/input8/enabled: No such file or directory
06-26 14:42:54.960    2809-2809/? E/NfcService﹕ callback == null
06-26 14:42:59.710    2342-2459/? E/KeyguardHostView﹕ KeyguardHostView()
06-26 14:43:00.035    2342-2459/? E/KeyguardShortcutView﹕ density = 320
06-26 14:43:00.210    2342-2459/? E/LSO﹕ LSO Service is not yet ready!!!
06-26 14:43:00.210    2342-2459/? E/LSO﹕ LSO Service is not yet ready!!!
06-26 14:43:00.210    2342-2459/? E/LSO﹕ LSO Service is not yet ready!!!
06-26 14:43:00.210    2342-2459/? E/LSO﹕ LSO Service is not yet ready!!!
06-26 14:43:00.380    2342-2459/? E/LSO﹕ LSO Service is not yet ready!!!
06-26 14:43:00.380    2342-2459/? E/LSO﹕ LSO Service is not yet ready!!!
06-26 14:43:00.380    2342-2459/? E/LSO﹕ LSO Service is not yet ready!!!
06-26 14:43:00.380    2342-2459/? E/LSO﹕ LSO Service is not yet ready!!!
06-26 14:46:35.515    8885-8885/? E/dalvikvm﹕ Could not find class 'android.app.job.JobScheduler', referenced from method com.android.email.service.s.a
06-26 14:46:35.515    8885-8885/? E/dalvikvm﹕ Could not find class 'android.app.job.JobScheduler', referenced from method com.android.email.service.s.b
06-26 14:46:36.000    8885-8922/? E/Gmail﹕ Error finding the version of the Email provider.....
android.content.pm.PackageManager$NameNotFoundException: com.google.android.email
        at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:103)
        at com.google.android.gm.EmailMigrationService.a(SourceFile:1279)
        at com.google.android.gm.EmailMigrationService.onHandleIntent(SourceFile:219)
        at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:176)
        at android.os.HandlerThread.run(HandlerThread.java:61)
06-26 14:49:28.000    1930-2015/? E/SecTVOutService﹕ virtual void android::SecTVOutService::setHdmiStatus(uint32_t)::mSecHdmi.connect() fail
06-26 14:49:28.015    2342-2482/? E/SEC PowerHAL﹕ sysfs_write : Error opening /sys/class/input/input1/enabled: No such file or directory

I got an error message that my post contains too many characters, so if there is a need, I can post more of the error messages in another post.我收到一条错误消息,指出我的帖子包含太多字符,因此如果有需要,我可以在另一篇帖子中发布更多错误消息。 Any help would be MUCH appreciated!任何帮助将非常感激!

The logs show every event that is happening on your device.日志显示您设备上发生的每个事件。 These contain logs from your app and the ones from other apps and services that are currently running on the device.这些包含来自您的应用程序以及当前在设备上运行的其他应用程序和服务的日志。

If you are using Android Studio, you can filter which logs logcat should display.如果您使用的是 Android Studio,您可以过滤 logcat 应该显示哪些日志。 As seen in the image below, you can select the app you are running (1), and the option that only logs created by this app should be shown (2)如下图所示,您可以选择您正在运行的应用程序 (1),以及只显示此应用程序创建的日志的选项 (2)

Android Studio 截图

I suspect that you are now just looking at the logs for all apps running on the device, and they will just output whatever they want.我怀疑您现在只是查看设备上运行的所有应用程序的日志,它们只会输出他们想要的任何内容。 Try setting the logcat filter to something that will only show your own app's output.尝试将 logcat 过滤器设置为仅显示您自己的应用程序输出的内容。

LinearLayout ll = new LinearLayout(this); LinearLayout ll = new LinearLayout(this);

provide width and height ,提供宽度和高度,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我是 android 开发的新手。 我正在制作我的第一个应用程序,但出现错误: - I am new to android development. I am making my first app but I am getting an error: 为什么我的权限突然消失在我正在编写的Android应用程序上? - Why did my permissions suddenly disapper on an Android app I am writing? 我突然在Gradle的Android Studio中收到Play-Service-app-indexing:10.0.1错误 - I am Suddenly getting Play-Service-app-indexing:10.0.1 error in gradle of android Studio 运行我的应用程序时,我在android studio中收到此错误 - I am getting this error in android studio while running my app 我的 Android 应用程序出现错误 - I am getting an error in my android application 我正在编写android应用程序,但遇到异常,我无法解决 - i am writing android application i am getting exception and i can not solve 如果我运行应用程序,我突然收到此错误,这是什么问题? - If I run application , I am suddenly getting this error , what is the problem? 我在android中收到此错误 - I am getting this error in android 我在使用 android studio 构建我的第一个 flutter 应用程序时遇到问题,几乎没有错误有人可以帮助我吗? - I am having issue building my first flutter app with android studio getting few errors can someone help me? 为什么在运行应用程序时出现此错误? - Why am I getting this error when I run my app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM