当我启动并完成Android项目时,我只能在计算机中看到一个问题。我的朋友在他的电脑和手机上开始同样的项目时会看到不同的问题。这些是我们的logcat报告。问题在哪里,请帮助,谢谢。
我的Logcat报告:
05-19 19:20:22.564: D/dalvikvm(949): GC_FOR_ALLOC freed 1022K, 32% free 3626K/5324K, paused 233ms, total 273ms
05-19 19:20:22.564: I/dalvikvm-heap(949): Grow heap (frag case) to 4.596MB for 960016-byte allocation
05-19 19:20:22.853: D/dalvikvm(949): GC_CONCURRENT freed 7K, 15% free 4556K/5324K, paused 5ms+6ms, total 247ms
05-19 19:21:25.005: D/dalvikvm(949): GC_CONCURRENT freed 1033K, 23% free 4147K/5356K, paused 77ms+7ms, total 153ms
05-19 19:21:25.005: D/dalvikvm(949): WAIT_FOR_CONCURRENT_GC blocked 44ms
05-19 19:21:25.044: I/dalvikvm-heap(949): Grow heap (frag case) to 5.143MB for 1000016-byte allocation
05-19 19:21:25.295: D/dalvikvm(949): GC_CONCURRENT freed 1499K, 43% free 3623K/6336K, paused 81ms+104ms, total 257ms
05-19 19:21:25.415: D/dalvikvm(949): GC_FOR_ALLOC freed <1K, 43% free 3623K/6336K, paused 34ms, total 34ms
05-19 19:21:25.424: I/dalvikvm-heap(949): Grow heap (frag case) to 4.632MB for 1000016-byte allocation
05-19 19:21:25.534: D/dalvikvm(949): GC_CONCURRENT freed 0K, 28% free 4600K/6336K, paused 75ms+6ms, total 108ms
05-19 19:21:25.534: D/dalvikvm(949): WAIT_FOR_CONCURRENT_GC blocked 21ms
05-19 19:21:25.574: E/saveToExternalStorage()(949): open failed: EACCES (Permission denied)
05-19 19:21:25.574: I/Choreographer(949): Skipped 223 frames! The application may be doing too much work on its main thread.
其他设备的Logcat报告:
模拟器Logcat报告:
05-19 18:41:08.442: E/AndroidRuntime(798): FATAL EXCEPTION: main
05-19 18:41:08.442: E/AndroidRuntime(798): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.yoritgenerator/com.example.yoritgenerator.QRHandler}: java.lang.NullPointerException
05-19 18:41:08.442: E/AndroidRuntime(798): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
05-19 18:41:08.442: E/AndroidRuntime(798): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-19 18:41:08.442: E/AndroidRuntime(798): at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-19 18:41:08.442: E/AndroidRuntime(798): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-19 18:41:08.442: E/AndroidRuntime(798): at android.os.Handler.dispatchMessage(Handler.java:99)
05-19 18:41:08.442: E/AndroidRuntime(798): at android.os.Looper.loop(Looper.java:137)
05-19 18:41:08.442: E/AndroidRuntime(798): at android.app.ActivityThread.main(ActivityThread.java:5039)
05-19 18:41:08.442: E/AndroidRuntime(798): at java.lang.reflect.Method.invokeNative(Native Method)
05-19 18:41:08.442: E/AndroidRuntime(798): at java.lang.reflect.Method.invoke(Method.java:511)
05-19 18:41:08.442: E/AndroidRuntime(798): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-19 18:41:08.442: E/AndroidRuntime(798): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-19 18:41:08.442: E/AndroidRuntime(798): at dalvik.system.NativeStart.main(Native Method)
05-19 18:41:08.442: E/AndroidRuntime(798): Caused by: java.lang.NullPointerException
05-19 18:41:08.442: E/AndroidRuntime(798): at com.example.yoritgenerator.QRHandler.onCreate(QRHandler.java:24)
05-19 18:41:08.442: E/AndroidRuntime(798): at android.app.Activity.performCreate(Activity.java:5104)
05-19 18:41:08.442: E/AndroidRuntime(798): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
05-19 18:41:08.442: E/AndroidRuntime(798): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
05-19 18:41:08.442: E/AndroidRuntime(798): ... 11 more
电话Logcat报告:
05-19 21:47:09.701: W/dalvikvm(17334): threadid=1: thread exiting with uncaught exception (group=0x40f672a0)
05-19 21:47:09.706: E/AndroidRuntime(17334): FATAL EXCEPTION: main
05-19 21:47:09.706: E/AndroidRuntime(17334): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.yoritgenerator/com.example.yoritgenerator.QRHandler}: java.lang.NullPointerException
05-19 21:47:09.706: E/AndroidRuntime(17334): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
05-19 21:47:09.706: E/AndroidRuntime(17334): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
05-19 21:47:09.706: E/AndroidRuntime(17334): at android.app.ActivityThread.access$700(ActivityThread.java:140)
05-19 21:47:09.706: E/AndroidRuntime(17334): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
05-19 21:47:09.706: E/AndroidRuntime(17334): at android.os.Handler.dispatchMessage(Handler.java:99)
05-19 21:47:09.706: E/AndroidRuntime(17334): at android.os.Looper.loop(Looper.java:137)
05-19 21:47:09.706: E/AndroidRuntime(17334): at android.app.ActivityThread.main(ActivityThread.java:4921)
05-19 21:47:09.706: E/AndroidRuntime(17334): at java.lang.reflect.Method.invokeNative(Native Method)
05-19 21:47:09.706: E/AndroidRuntime(17334): at java.lang.reflect.Method.invoke(Method.java:511)
05-19 21:47:09.706: E/AndroidRuntime(17334): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
05-19 21:47:09.706: E/AndroidRuntime(17334): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
05-19 21:47:09.706: E/AndroidRuntime(17334): at dalvik.system.NativeStart.main(Native Method)
05-19 21:47:09.706: E/AndroidRuntime(17334): Caused by: java.lang.NullPointerException
05-19 21:47:09.706: E/AndroidRuntime(17334): at com.example.yoritgenerator.QRHandler.onCreate(QRHandler.java:24)
05-19 21:47:09.706: E/AndroidRuntime(17334): at android.app.Activity.performCreate(Activity.java:5206)
05-19 21:47:09.706: E/AndroidRuntime(17334): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
05-19 21:47:09.706: E/AndroidRuntime(17334): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
05-19 21:47:09.706: E/AndroidRuntime(17334): ... 11 more
我们的守则:
submitButton.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
if( userPassword.getText().toString().equals(loginPassword) )
{
if( loginPassword.equals( defaultPassword ) )
{
Toast.makeText(Login.this, "DO NOT FORGET TO CHANGE DEFAULT PASSWORD!!!", Toast.LENGTH_SHORT).show();
//changePassword();
if(!isCreate){
//createMenu();
Intent qrCodeGenerate = new Intent( "com.example.yoritgenerator.QRHANDLER" );
startActivity( qrCodeGenerate );
}
QrHandler班级:
package com.example....
import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
public class QRHandler extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final EditText qrMessage = (EditText)findViewById(R.id.qrText);
final Button convertButton = (Button)findViewById(R.id.generate);
convertButton.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
setContentView(R.layout.qr_image);
ImageView imageView = (ImageView) findViewById(R.id.qr_image);
String qrData = qrMessage.getText().toString();
int qrCodeDimention = 500;
Generator qrCodeEncoder = new Generator(qrData, null, Contents.Type.TEXT, BarcodeFormat.QR_CODE.toString(), qrCodeDimention);
try
{
Bitmap bitmap = qrCodeEncoder.encodeAsBitmap();
imageView.setImageBitmap(bitmap);
}
catch (WriterException e)
{
e.printStackTrace();
}
}
});
}
}