我是Android新手。在我的应用程序中有一个照片捕获功能。拍摄照片后,我的应用程序突然变成白屏并崩溃。复制这个问题真的很难。当应用程序崩溃时,这是我的日志猫。
02-11 11:14:13.071 27373-27373/io.omoto.omotokairaliapp D/dalvikvm: Late-enabling CheckJNI
02-11 11:14:13.071 27373-27373/io.omoto.omotokairaliapp D/dalvikvm: Try to disable coredump for pid 27373
02-11 11:14:13.091 27373-27379/io.omoto.omotokairaliapp E/jdwp: Failed sending reply to debugger: Broken pipe
02-11 11:14:13.091 27373-27379/io.omoto.omotokairaliapp D/dalvikvm: Debugger has detached; object registry had 1 entries
02-11 11:14:13.111 27373-27373/io.omoto.omotokairaliapp W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
02-11 11:14:13.111 27373-27373/io.omoto.omotokairaliapp I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
02-11 11:14:13.111 27373-27373/io.omoto.omotokairaliapp W/dalvikvm: VFY: unable to resolve interface method 20301: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
02-11 11:14:13.111 27373-27373/io.omoto.omotokairaliapp D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
02-11 11:14:13.111 27373-27373/io.omoto.omotokairaliapp I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
02-11 11:14:13.111 27373-27373/io.omoto.omotokairaliapp W/dalvikvm: VFY: unable to resolve interface method 20305: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
02-11 11:14:13.111 27373-27373/io.omoto.omotokairaliapp D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
02-11 11:14:13.141 27373-27373/io.omoto.omotokairaliapp I/dalvikvm: Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawable
02-11 11:14:13.141 27373-27373/io.omoto.omotokairaliapp W/dalvikvm: VFY: unable to resolve virtual method 626: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
02-11 11:14:13.141 27373-27373/io.omoto.omotokairaliapp D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
02-11 11:14:13.141 27373-27373/io.omoto.omotokairaliapp I/dalvikvm: Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawableForDensity
02-11 11:14:13.141 27373-27373/io.omoto.omotokairaliapp W/dalvikvm: VFY: unable to resolve virtual method 628: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
02-11 11:14:13.141 27373-27373/io.omoto.omotokairaliapp D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
02-11 11:14:13.171 27373-27373/io.omoto.omotokairaliapp I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
02-11 11:14:13.171 27373-27373/io.omoto.omotokairaliapp W/dalvikvm: VFY: unable to resolve virtual method 663: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
02-11 11:14:13.171 27373-27373/io.omoto.omotokairaliapp D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
02-11 11:14:13.171 27373-27373/io.omoto.omotokairaliapp I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
02-11 11:14:13.171 27373-27373/io.omoto.omotokairaliapp W/dalvikvm: VFY: unable to resolve virtual method 685: Landroid/content/res/TypedArray;.getType (I)I
02-11 11:14:13.171 27373-27373/io.omoto.omotokairaliapp D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
我的gradle文件是
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "io.omoto.omotokairaliapp"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
// multipart httpClient
compile('org.apache.httpcomponents:httpmime:4.3') {
exclude module: "httpclient"
}
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services-gcm:10.0.1'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.loopj.android:android-async-http:1.4.8'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.3'
compile 'cn.pedant.sweetalert:library:1.3'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:1.2.32@aar'
compile 'com.android.support:design:23.4.0'
compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
compile 'com.romainpiel.shimmer:library:1.4.0@aar'
compile 'com.android.support:customtabs:23.4.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.github.amlcurran.showcaseview:library:5.0.0'
compile 'com.brucetoo.pickview:library:1.1.1'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
compile 'com.fasterxml.jackson.core:jackson-databind:2.2.+'
}
我在谷歌搜索了很多。我仍然没有得到任何解决方案。请帮我解决这个问题
这是我拍摄照片的代码
package io.omoto.omotokairaliapp.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.squareup.picasso.Picasso;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.List;
import io.omoto.omotokairaliapp.Adapter.SelectedPatientDetailsAdapter;
import io.omoto.omotokairaliapp.Beans.CRMresponsePojo;
import io.omoto.omotokairaliapp.Beans.SelectedLanguage;
import io.omoto.omotokairaliapp.Constants.Constants;
import io.omoto.omotokairaliapp.Pojo.LoginResponsePojo;
import io.omoto.omotokairaliapp.R;
import io.omoto.omotokairaliapp.UIDs.ImgeURLdb;
import io.omoto.omotokairaliapp.UIDs.Page40CSATUID;
import io.omoto.omotokairaliapp.Utls.FButton;
import io.omoto.omotokairaliapp.Utls.Snack;
import io.omoto.omotokairaliapp.dev.Home;
public class DisplaySelectedInformation extends AppCompatActivity {
private FButton continueBtn;
private FButton backBtn;
private boolean doubleBackToExitPressedOnce = false;
private Intent intent;
private Context context = DisplaySelectedInformation.this;
private SelectedLanguage selectedLanguage;
private ImageView selectNewPic;
private ImageView dispProfilePic;
private int requestCode = 20;
private ImageView imageView;
private FrameLayout profileImageLayout;
private boolean picTaken;
private ImgeURLdb imgeURLdb;
private LoginResponsePojo loginResponsePojo;
private ListView listView;
public final String PREFS_NAME = "MyPrefsFile";
private ArrayList<CRMresponsePojo.DataSampleBean> selectedBean;
private String id = null;
private CRMresponsePojo crMresponsePojo;
private Page40CSATUID page40CSATUID;
private TextView teluguText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dis);
continueBtn = (FButton) findViewById(R.id.continu);
backBtn = (FButton) findViewById(R.id.back);
selectNewPic = (ImageView) findViewById(R.id.capture);
dispProfilePic = (ImageView) findViewById(R.id.user_image);
imageView = (ImageView) findViewById(R.id.selec_img);
profileImageLayout = (FrameLayout) findViewById(R.id.profile_image_layout);
listView = (ListView)findViewById(R.id.sel_patient_list);
teluguText = (TextView)findViewById(R.id.teleugu_text);
//set Telugu text
teluguText.setText("Continue in "+getString(R.string.telugu));
teluguText.setVisibility(View.GONE);
loginResponsePojo = LoginResponsePojo.getInstance();
continueBtn.setButtonColor(getResources().getColor(R.color.omoto_green));
imgeURLdb = new ImgeURLdb(context);
page40CSATUID = new Page40CSATUID(context);
selectedLanguage = SelectedLanguage.getInstance();
crMresponsePojo = new CRMresponsePojo();
selectedBean = new ArrayList<CRMresponsePojo.DataSampleBean>();
loginResponsePojo.setInterfacePhotoUpload(true);
if (loginResponsePojo.isInterfacePhotoUpload()) {
profileImageLayout.setVisibility(View.VISIBLE);
} else {
profileImageLayout.setVisibility(View.GONE);
}
//// TODO: 30/01/2017 remove comment
String filePath = Environment.getExternalStorageDirectory()
.getAbsolutePath() + File.separator + "/Omoto Images/" + Constants.IMAGE2_NAME;
File imgFile = new File(filePath);
if (imgFile.exists()) {
Picasso.with(context).load(imgFile).fit().into(imageView);
}
// read the object from file
String crmResponseObjFilePath = Environment.getExternalStorageDirectory()
.getAbsolutePath() + File.separator + "/Omoto/" + Constants.RESPONSE_OBJ_FILE_NAME;
File objFile = new File(crmResponseObjFilePath);
FileInputStream fis = null;
ObjectInputStream in = null;
try {
fis = new FileInputStream(objFile);
in = new ObjectInputStream(fis);
crMresponsePojo = (CRMresponsePojo) in.readObject();
in.close();
fis.close();
} catch (Exception ex) {
ex.printStackTrace();
}
final SharedPreferences pref = getSharedPreferences(PREFS_NAME,0);
id = pref.getString("ID",null);
String regid = null;
for (CRMresponsePojo.DataSampleBean data:crMresponsePojo.getDataSample()) {
regid = data.getRegistrationId();
if (regid.equalsIgnoreCase(id)){
selectedBean.add(data);
crMresponsePojo.setDataSample(selectedBean);
//show selected information
setSelectedListAdapter(crMresponsePojo);
break;
}
}
selectNewPic.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
capturePhoto();
}
});
dispProfilePic.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
capturePhoto();
}
});
continueBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedLanguage.selectedLanguage("english");
if (loginResponsePojo.isInterfacePhotoUpload()) {
picTaken = checkPicIsTaken();
if (picTaken) {
Intent intent = new Intent(DisplaySelectedInformation.this, PageViewActivity.class);
startActivity(intent);
page40CSATUID.deleteData();
finish();
} else {
Toast.makeText(context, "Please capture photo by clicking camera icon", Toast.LENGTH_SHORT).show();
}
} else {
Intent intent = new Intent(DisplaySelectedInformation.this, PageViewActivity.class);
startActivity(intent);
finish();
}
}
});
teluguText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedLanguage.selectedLanguage("telugu");
if (loginResponsePojo.isInterfacePhotoUpload()) {
picTaken = checkPicIsTaken();
if (picTaken) {
Intent intent = new Intent(DisplaySelectedInformation.this, PageViewActivity.class);
startActivity(intent);
page40CSATUID.deleteData();
finish();
} else {
Toast.makeText(context, "Please capture photo by clicking camera icon", Toast.LENGTH_SHORT).show();
}
} else {
Intent intent = new Intent(DisplaySelectedInformation.this, PageViewActivity.class);
startActivity(intent);
finish();
}
}
});
backBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
resetDisplayedInformation();
selectedLanguage.selectedLanguage("english");
if (loginResponsePojo.isCrmPushEnabled()) {
// animatedStartActivity();
Intent intent = new Intent(DisplaySelectedInformation.this,CRMactivity.class);
startActivity(intent);
finish();
} else {
Intent intent = new Intent(DisplaySelectedInformation.this, WelcomeActivty.class);
startActivity(intent);
finish();
}
// animatedStartActivity();
}
});
}
private void setSelectedListAdapter(CRMresponsePojo crMresponsePojo) {
List<String> fieldList = new ArrayList<String>();
List<String> valueList = new ArrayList<String>();
fieldList.add("Name");
fieldList.add("Room no");
fieldList.add("Reg id");
valueList.add(crMresponsePojo.getDataSample().get(0).getFirstname()+" "+crMresponsePojo.getDataSample().get(0).getLastname());
valueList.add(crMresponsePojo.getDataSample().get(0).getQualifyInfo().getRoomno());
valueList.add(crMresponsePojo.getDataSample().get(0).getRegistrationId());
SelectedPatientDetailsAdapter selectedPatientDetailsAdapter = new SelectedPatientDetailsAdapter(this,valueList,fieldList);
listView.setAdapter(selectedPatientDetailsAdapter);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (this.requestCode == requestCode && resultCode == RESULT_OK) {
File root = new File(Environment.getExternalStorageDirectory(), "Feedback");
if (!root.exists()) {
//noinspection ResultOfMethodCallIgnored
root.mkdirs();
}
File file = new File(root, Constants.PROFILE_IMAGE_NAME + ".jpeg");
checkFlowIdisPresent(file);
}
}
private void capturePhoto() {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
File root = new File(Environment.getExternalStorageDirectory(), "Feedback");
if (!root.exists()) {
//noinspection ResultOfMethodCallIgnored
root.mkdirs();
}
File file = new File(root, Constants.PROFILE_IMAGE_NAME + ".jpeg");
Uri outputFileUri = Uri.fromFile(file);
Intent photoPickerIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
photoPickerIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
photoPickerIntent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
photoPickerIntent.putExtra("return-data", true);
photoPickerIntent.putExtra("android.intent.extras.CAMERA_FACING", 1);
startActivityForResult(photoPickerIntent, requestCode);
}
});
thread.start();
}
private void checkFlowIdisPresent(File file) {
int flowidCount;
flowidCount = imgeURLdb.getImageNameCount(Constants.PROFILE_IMAGE_NAME);
if (flowidCount == 0) {
imgeURLdb.addImagePath(Constants.PROFILE_IMAGE_NAME, String.valueOf(file));
if (file.exists()){
displayPic();
}
}
}
private boolean checkPicIsTaken() {
int imageNameCount = imgeURLdb.getImageNameCount(Constants.PROFILE_IMAGE_NAME);
return imageNameCount != 0;
}
private void displayPic() {
String filePath = Environment.getExternalStorageDirectory()
.getAbsolutePath() + File.separator + "/Feedback/" + Constants.PROFILE_IMAGE_NAME + ".jpeg";
File imgFile = new File(filePath);
Bitmap bitmap = decodeFile(imgFile);
if (imgFile.exists()) {
dispProfilePic.setImageBitmap(bitmap);
} else {
dispProfilePic.setBackgroundResource(R.drawable.user_image);
}
}
private Bitmap decodeFile(File f) {
try {
// Decode image size
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeStream(new FileInputStream(f), null, o);
// The new size we want to scale to
final int REQUIRED_SIZE = 70;
// Find the correct scale value. It should be the power of 2.
int scale = 1;
while (o.outWidth / scale / 2 >= REQUIRED_SIZE &&
o.outHeight / scale / 2 >= REQUIRED_SIZE) {
scale *= 2;
}
// Decode with inSampleSize
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize = scale;
return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onStop() {
super.onStop();
}
private void animatedStartActivity() {
// we only animateOut this activity here.
// The new activity will animateIn from its onResume() - be sure to
// implement it.
final Intent intent = new Intent(DisplaySelectedInformation.this,
CRMactivity.class);
// disable default animation for new intent
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
ActivitySwitcher.animationOut(findViewById(R.id.container),
getWindowManager(),
new ActivitySwitcher.AnimationFinishedListener() {
@Override
public void onAnimationFinished() {
startActivity(intent);
}
});
}
private void resetDisplayedInformation() {
imgeURLdb = new ImgeURLdb(context);
imgeURLdb.deleterecord(Constants.PROFILE_IMAGE_NAME);
deleteImageFromStorage(Constants.PROFILE_IMAGE_NAME);
}
// Delete image from storage
private void deleteImageFromStorage(String imageName) {
String root = Environment.getExternalStorageDirectory().toString();
File myDir = new File(root + "/Feedback");
File file = new File(myDir, imageName + ".jpeg");
boolean deleted = file.delete();
Log.i("deleted", deleted + "");
}
public void onBackPressed() {
if (doubleBackToExitPressedOnce) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Confirm");
builder.setMessage("Are you sure you'd like to exit and go to Admin?");
builder.setPositiveButton("YES", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Constants.CAMPAIGN_RATING_NPS = "";
Constants.filterRetain = false;
Constants.filterRetainPosition = 1;
Constants.selectedFilter = "All";
Constants.EMPTYFIELDS = true;
intent = new Intent(DisplaySelectedInformation.this, Home.class);
startActivity(intent);
}
});
builder.setNegativeButton("NO", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// Do nothing
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
return;
}
this.doubleBackToExitPressedOnce = true;
//Toast.makeText(this, "Press the back button once again to Logout.", Toast.LENGTH_SHORT).show();
Snack.show(context, "Press the back button once again to go to Admin.");
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
doubleBackToExitPressedOnce = false;
}
}, 2000);
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.i("tag", "DisplaySelectedInformation onDestroy called");
freeUpAllResources();
/* RefWatcher refWatcher = OmotoApplication.getRefWatcher(this);
refWatcher.watch(this);*/
}
private void freeUpAllResources() {
continueBtn = null;
backBtn = null;
context = null;
selectNewPic = null;
dispProfilePic = null;
imageView = null;
profileImageLayout = null;
page40CSATUID = null;
selectedBean = null;
crMresponsePojo = null;
imgeURLdb = null;
}
}