不知道怎么回事。。
package com.example.lenovo.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this,"123456".charAt(2),Toast.LENGTH_SHORT).show();
}
});
}
}
报错:
11/04 17:21:36: Launching app
$ adb push D:\study\Android\MyApplication2\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.example.lenovo.myapplication
$ adb shell pm install -r "/data/local/tmp/com.example.lenovo.myapplication"
Success
$ adb shell am start -n "com.example.lenovo.myapplication/com.example.lenovo.myapplication.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 4133 on device Nexus_5_API_24 [emulator-5554]
W/System: ClassLoader referenced unknown path: /data/app/com.example.lenovo.myapplication-1/lib/x86
I/InstantRun: Instant Run Runtime started. Android package is com.example.lenovo.myapplication, real application class is null.
W/System: ClassLoader referenced unknown path: /data/app/com.example.lenovo.myapplication-1/lib/x86
W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
W/gralloc_ranchu: Gralloc pipe failed
[ 11-04 09:21:43.377 4133: 4133 D/ ]
HostConnection::get() New Host Connection established 0xa63882c0, tid 4133
[ 11-04 09:21:43.425 4133: 4224 D/ ]
HostConnection::get() New Host Connection established 0xa6388740, tid 4224
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 1
W/ResourceType: No package identifier when getting value for resource number 0x00000033
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.lenovo.myapplication, PID: 4133
android.content.res.Resources$NotFoundException: String resource ID #0x33
at android.content.res.Resources.getText(Resources.java:331)
at android.widget.Toast.makeText(Toast.java:287)
at com.example.lenovo.myapplication.MainActivity$1.onClick(MainActivity.java:19)
at android.view.View.performClick(View.java:5610)
at android.view.View$PerformClick.run(View.java:22260)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Application terminated.