У меня нормально работает приложение в эмуляторе с API 28. Но когда я запускаю приложение в эмуляторе с API 29, оно показывает
Это не только показывает, останавливается в эмуляторе. Я попытался установить его на мобильный, и он также показывает ту же ошибку.
Журнал показывает эту ошибку следующим образом:
2020-02-14 19:48:12.922 20370-20370/? E/stickerappmake: Unknown bits set in runtime_flags: 0x8000
2020-02-14 19:48:15.326 20370-20454/com.testdev.appname E/eglCodecCommon: glUtilsParamSize: unknow param 0x000088ef
2020-02-14 19:48:15.326 20370-20454/com.testdev.appname E/eglCodecCommon: glUtilsParamSize: unknow param 0x000088ef
2020-02-14 19:48:15.385 20370-20454/com.testdev.appname E/eglCodecCommon: glUtilsParamSize: unknow param 0x000088ef
2020-02-14 19:48:15.385 20370-20454/com.testdev.appname E/eglCodecCommon: glUtilsParamSize: unknow param 0x000088ef
2020-02-14 19:48:17.138 20370-20454/com.testdev.appname E/eglCodecCommon: glUtilsParamSize: unknow param 0x000088ef
2020-02-14 19:48:17.139 20370-20454/com.testdev.appname E/eglCodecCommon: glUtilsParamSize: unknow param 0x000088ef
2020-02-14 19:48:17.243 20370-20454/com.testdev.appname E/eglCodecCommon: glUtilsParamSize: unknow param 0x000088ef
2020-02-14 19:48:17.243 20370-20454/com.testdev.appname E/eglCodecCommon: glUtilsParamSize: unknow param 0x000088ef
2020-02-14 19:48:19.984 20370-20464/com.testdev.appname E/eglCodecCommon: glUtilsParamSize: unknow param 0x000088ef
2020-02-14 19:48:19.984 20370-20464/com.testdev.appname E/eglCodecCommon: glUtilsParamSize: unknow param 0x000088ef
2020-02-14 19:48:20.048 20370-20454/com.testdev.appname E/eglCodecCommon: glUtilsParamSize: unknow param 0x000088ef
2020-02-14 19:48:20.048 20370-20454/com.testdev.appname E/eglCodecCommon: glUtilsParamSize: unknow param 0x000088ef
2020-02-14 19:48:20.059 20370-20454/com.testdev.appname E/eglCodecCommon: glUtilsParamSize: unknow param 0x000088ef
2020-02-14 19:48:20.063 20370-20454/com.testdev.appname E/eglCodecCommon: glUtilsParamSize: unknow param 0x000088ef
2020-02-14 19:48:22.727 20370-20370/com.testdev.appname E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.testdev.appname, PID: 20370
java.lang.NullPointerException: Attempt to get length of null array
at com.testdev.appname.activities.CreateFragment.loadStickersCreated(CreateFragment.java:52)
at com.testdev.appname.activities.CreateFragment.onCreateView(CreateFragment.java:88)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2439)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:797)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3273)
at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3229)
at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:201)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:620)
at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1425)
at android.app.Activity.performStart(Activity.java:7825)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3294)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Я вижу некоторые проблемы с кодом java в CreateFragment. java. И код java выглядит следующим образом: Код CreateFragment. java:
пакет com.devname.appname.activities;
import android.app.Activity;
import android.app.AlertDialog;
import android.support.v4.app.Fragment;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import com.facebook.drawee.view.SimpleDraweeView;
import com.devname.appname.helpers.Admob;
import com.sangcomz.fishbun.FishBun;
import com.sangcomz.fishbun.adapter.image.impl.GlideAdapter;
import com.sangcomz.fishbun.define.Define;
import com.devname.appname.R;
import com.devname.appname.backgroundRemover.CutOut;
import com.devname.appname.helpers.Constants;
import com.devname.appname.utils.FileUtils;
import com.devname.appname.utils.StickerPacksManager;
import java.io.File;
import java.util.ArrayList;
public class CreateFragment extends Fragment {
ImagesGridAdapter imagesGridAdapter;
View view;
public CreateFragment() {
// Required empty public constructor
}
public static ArrayList<Uri> loadStickersCreated() {
String directoryPath = Constants.STICKERS_CREATED_DIRECTORY_PATH;
File directory = new File(directoryPath);
ArrayList<Uri> images = new ArrayList<>();
if (directory.exists()) {
File[] stickersImages = directory.listFiles();
for (File f : stickersImages) {
if (f.isFile() && (f.getName().contains(".png") || f.getName().contains(".PNG"))) {
images.add(Uri.fromFile((f)));
}
}
} else {
directory.mkdir();
}
// verifyStickersCount();
return images;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
view = inflater.inflate(R.layout.fragment_create, container, false);
Admob.createLoadBanner(getContext(), view);
view.findViewById(R.id.create_sticker).setOnClickListener(v -> FishBun.with(getActivity())
.setImageAdapter(new GlideAdapter())
.setMaxCount(1)
.exceptGif(true)
.setMinCount(1)
.setActionBarColor(getResources().getColor(R.color.colorPrimaryDark), getResources().getColor(R.color.colorPrimary), false)
.setActionBarTitleColor(Color.parseColor("#ffffff"))
.startAlbum());
RecyclerView gridview = view.findViewById(R.id.stickers_created_grid);
GridLayoutManager gridLayoutManager = new GridLayoutManager(view.getContext(), 3);
gridview.setLayoutManager(gridLayoutManager);
imagesGridAdapter = new ImagesGridAdapter(view.getContext(), loadStickersCreated());
gridview.setAdapter(imagesGridAdapter);
verifyStickersCount();
return view;
}
public void verifyStickersCount() {
View linearLayout = view.findViewById(R.id.no_stickers_icon);
if (imagesGridAdapter == null || imagesGridAdapter.getItemCount() == 0) {
linearLayout.setVisibility(View.VISIBLE);
} else {
linearLayout.setVisibility(View.GONE);
}
}
public static void addImageToGallery(final String filePath, final Context context) {
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis());
values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
values.put(MediaStore.MediaColumns.DATA, filePath);
context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d("TESTTTTTT",requestCode+"");
if (requestCode == CutOut.CUTOUT_ACTIVITY_REQUEST_CODE) {
Log.d("TESTTTTTT :::::",requestCode+"");
switch (resultCode) {
case Activity.RESULT_OK:
String imagePath_intent = data.getStringExtra("imagePath");
Uri imageUri = Uri.fromFile(new File(imagePath_intent));
Log.d("TESTTTTTT ::::: He",imageUri+"");
String stickerName = FileUtils.generateRandomIdentifier();
Uri imagePath = Uri.parse(Constants.STICKERS_CREATED_DIRECTORY_PATH + stickerName + ".PNG");
StickerPacksManager.createStickerImageFile(imageUri, imagePath, getActivity(), Bitmap.CompressFormat.PNG);
addImageToGallery(imagePath.getPath(), getActivity());
imagesGridAdapter.uries = loadStickersCreated();
imagesGridAdapter.notifyDataSetChanged();
Toast.makeText(getActivity(), "Sticker created", Toast.LENGTH_LONG).show();
verifyStickersCount();
break;
case CutOut.CUTOUT_ACTIVITY_RESULT_ERROR_CODE:
Exception ex = CutOut.getError(data);
Log.d("TESTTTTTT :::::",ex+"::DDD");
break;
default:
System.out.print("User cancelled the CutOut screen");
}
} else if (requestCode == Define.ALBUM_REQUEST_CODE) {
ArrayList<Uri> uries;
if (resultCode == Activity.RESULT_OK) {
uries = data.getParcelableArrayListExtra(Define.INTENT_PATH);
CutOut.activity().src(uries.get(0)).intro().start(getActivity());
}
}
}
public class ImagesGridAdapter extends RecyclerView.Adapter<ImageViewHolder> {
public ArrayList<Uri> uries = new ArrayList<>();
Context context;
public ImagesGridAdapter(Context context, ArrayList<Uri> uries) {
this.uries = uries;
this.context = context;
}
@NonNull
@Override
public ImageViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
final Context context = viewGroup.getContext();
final LayoutInflater layoutInflater = LayoutInflater.from(context);
final View view = layoutInflater.inflate(R.layout.sticker_created_item, viewGroup, false);
return new ImageViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull ImageViewHolder imageAdapter, int index) {
imageAdapter.imageView.setImageURI(uries.get(index));
imageAdapter.imageView.setPadding(8, 8, 8, 8);
imageAdapter.imageView.setOnLongClickListener(v -> {
PopupMenu popupMenu = new PopupMenu(context, imageAdapter.imageView);
popupMenu.inflate(R.menu.sticker_menu);
popupMenu.setOnMenuItemClickListener(item -> {
switch (item.getItemId()) {
/* case R.id.add_to_exist_stickerpack:
addToStickerPack(index);
break;*/
case R.id.delete_sticker:
this.deleteSticker(index);
break;
default:
break;
}
return false;
});
popupMenu.show();
return false;
});
}
void deleteSticker(int index) {
new AlertDialog.Builder(context)
.setTitle("Deleting")
.setMessage("Are you sure you want to delete this sticker?")
.setPositiveButton("Yes", (dialog, which) -> {
Uri uri = uries.get(index);
FileUtils.deleteFile(uri.getPath(),context);
uries.remove(index);
notifyItemRemoved(index);
notifyDataSetChanged();
Toast.makeText(context, "Deleted", Toast.LENGTH_SHORT).show();
verifyStickersCount();
})
.setNegativeButton("No", null)
.show();
}
void addToStickerPack(int index) {
Intent intent = new Intent(context, AddToStickerPackActivity.class);
intent.setData(uries.get(index));
startActivity(intent);
}
@Override
public int getItemCount() {
return uries.size();
}
}
class ImageViewHolder extends RecyclerView.ViewHolder {
SimpleDraweeView imageView;
public ImageViewHolder(@NonNull View itemView) {
super(itemView);
this.imageView = itemView.findViewById(R.id.sticker_created_image);
}
}
}