我的android项目有个问题。每当我将minifyEnabled设置为true时,应用程序就会崩溃。应用程序正在firebase后端上运行。
下面是我在android studio中运行的日志
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.helium4.aplo, PID: 23927
u5.d: No properties to serialize found on class e8.g
at d6.a$a.<init>(:548)
at d6.a.r(:330)
at d6.a.c(:431)
at d6.a.l(:232)
at d6.a.i(:80)
at u5.b.i(:203)
at m1.b.b(:29)
at m1.b.a(:15)
at l1.a.a(:36)
at l1.c.get(:52)
at com.firebase.ui.database.FirebaseRecyclerAdapter.I(:109)
at com.firebase.ui.database.FirebaseRecyclerAdapter.x(:149)
at androidx.recyclerview.widget.RecyclerView$g.y(:7065)
at androidx.recyclerview.widget.RecyclerView$g.k(:7107)
at androidx.recyclerview.widget.RecyclerView$u.F(:6012)
at androidx.recyclerview.widget.RecyclerView$u.G(:6279)
at androidx.recyclerview.widget.RecyclerView$u.p(:6118)
at androidx.recyclerview.widget.RecyclerView$u.o(:6114)
at androidx.recyclerview.widget.LinearLayoutManager$c.d(:2303)
at androidx.recyclerview.widget.LinearLayoutManager.r2(:1627)
at androidx.recyclerview.widget.LinearLayoutManager.U1(:1587)
at androidx.recyclerview.widget.LinearLayoutManager.X0(:665)
at androidx.recyclerview.widget.RecyclerView.D(:4134)
at androidx.recyclerview.widget.RecyclerView.B(:3851)
at androidx.recyclerview.widget.RecyclerView.u(:1897)
at androidx.recyclerview.widget.RecyclerView$a.run(:414)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1010)
at android.view.Choreographer.doCallbacks(Choreographer.java:809)
at android.view.Choreographer.doFrame(Choreographer.java:740)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:995)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8595)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
下面是我的身材
//noinspection DuplicatePlatformClasses
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
id 'com.google.firebase.firebase-perf'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.helium4.aplo"
minSdk 21
targetSdk 31
versionCode 6
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug{
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
consumerProguardFiles 'proguard-rules.pro'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
这是我的主要活动
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.helium4.aplo.databinding.ActivityMainBinding;
import java.util.Objects;
public class MainActivity extends AppCompatActivity {
private ActivityMainBinding binding;
private FirebaseAuth mAuth;
private DatabaseReference UsersRef,subscriberRef,RentDueRef,DeviceRef,DeviceDetRef;
String currentUserID,currentUserMail,m_androidId;
Utils utils;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
utils = new Utils();
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
BottomNavigationView navView = findViewById(R.id.nav_view);
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_settings)
.build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_main);
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
NavigationUI.setupWithNavController(binding.navView, navController);
getSupportActionBar()
.hide();
mAuth = FirebaseAuth.getInstance();
currentUserID = Objects.requireNonNull(mAuth.getCurrentUser()).getUid();
m_androidId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
UsersRef = FirebaseDatabase.getInstance().getReference().child("Users").child(currentUserID);
DeviceDetRef = FirebaseDatabase.getInstance().getReference().child("UserDeviceLog").child(currentUserID);
DeviceRef = FirebaseDatabase.getInstance().getReference().child("UserDevice").child(currentUserID);
UsersRef.child("logStatus").setValue("active");
DeviceDetRef.child(m_androidId).child("logStatus").setValue("active");
DeviceDetRef.child(m_androidId).child("logIp").setValue(String.valueOf(utils.getIp(true)));
UsersRef.child("logStatus").onDisconnect().setValue("inactive");
UsersRef.child("logStatusTime").onDisconnect().setValue(System.currentTimeMillis());
DeviceDetRef.child(m_androidId).child("logStatus").onDisconnect().setValue("inactive");
DeviceDetRef.child(m_androidId).child("logStatusTime").onDisconnect().setValue(System.currentTimeMillis());
DeviceDetRef.child(m_androidId).child("logIp").onDisconnect().setValue(String.valueOf(utils.getIp(true)));
DeviceRef.orderByChild("deviceId").equalTo(m_androidId).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
if (snapshot.exists()){
if (snapshot.hasChild("deviceStatus")){
String status = snapshot.child("deviceStatus").getValue().toString();
if (status.equals("logout")){
mAuth.signOut();
Intent mainIntent = new Intent(MainActivity.this, LoginRegisterActivity. class);
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(mainIntent);
}
}
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
}
下面是我的家庭片段
import static android.content.Context.CLIPBOARD_SERVICE;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.firebase.ui.database.FirebaseRecyclerOptions;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;
import com.google.firebase.database.ValueEventListener;
import com.helium4.aplo.HelpActivity;
import com.helium4.aplo.MainActivity;
import com.helium4.aplo.Utils;
import com.helium4.aplo.customer.CustomerActivity;
import com.helium4.aplo.LoginRegisterActivity;
import com.helium4.aplo.model.Subscribers;
import com.helium4.aplo.add.AddCustomerActivity;
import com.helium4.aplo.add.AddPlanActivity;
import com.helium4.aplo.add.AddZoneActivity;
import com.helium4.aplo.R;
import com.helium4.aplo.databinding.FragmentHomeBinding;
import com.squareup.picasso.Picasso;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Locale;
import java.util.Objects;
import java.util.UUID;
import de.hdodenhof.circleimageview.CircleImageView;
public class HomeFragment extends Fragment {
private HomeViewModel homeViewModel;
private FragmentHomeBinding binding;
private FirebaseAuth mAuth;
private DatabaseReference UsersRef,subscriberRef,RentDueRef,AppValidity,DeviceDetRef,AppLevel;
String currentUserID,currentUserMail;
RecyclerView list;
ImageView menuBtn,searchBtn,filter;
EditText searchText;
private static final int CALL_PERMISSION_CODE = 102;
TextView subCont;
private ClipboardManager myClipboard;
private ClipData myClip;
int filt = 0,lock =0;
String dayss ="";
Utils utils;
String m_androidId, privacy;
MainActivity mainActivity;
@SuppressLint("HardwareIds")
public View onCreateView(@NonNull LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_home,container,false);
mAuth = FirebaseAuth.getInstance();
utils = new Utils();
mainActivity = (MainActivity) getActivity();
currentUserID = Objects.requireNonNull(mAuth.getCurrentUser()).getUid();
if (currentUserID== null){
mAuth.signOut();
Intent mainIntent = new Intent(getActivity(), LoginRegisterActivity. class);
mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(mainIntent);
getActivity().finish();
}
myClipboard = (ClipboardManager)getActivity().getSystemService(CLIPBOARD_SERVICE);
currentUserMail =mAuth.getCurrentUser().getEmail();
UsersRef = FirebaseDatabase.getInstance().getReference().child("Users");
AppValidity= FirebaseDatabase.getInstance().getReference().child("AppPlanValidity");
subscriberRef = FirebaseDatabase.getInstance().getReference().child("Subscribers");
DeviceDetRef = FirebaseDatabase.getInstance().getReference().child("UserDevices").child(currentUserID);
AppLevel = FirebaseDatabase.getInstance().getReference().child("AppLevel").child(currentUserID);
UsersRef.keepSynced(true);
AppValidity.keepSynced(true);
subscriberRef.keepSynced(true);
RentDueRef.keepSynced(true);
DeviceDetRef.keepSynced(true);
list = rootView.findViewById(R.id.customerRecycler);
list.setHasFixedSize(true);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
linearLayoutManager.setReverseLayout(false);
linearLayoutManager.setStackFromEnd(false);
list.setLayoutManager(linearLayoutManager);
loadData();
return rootView;
}
private void loadData() {
Query Order = subscriberRef.child(currentUserID).orderByChild("subName");
FirebaseRecyclerOptions<Subscribers> options = new FirebaseRecyclerOptions.Builder<Subscribers>()
.setQuery(Order, Subscribers.class)
.build();
FirebaseRecyclerAdapter<Subscribers,HomeFragment.DataViewHolder> firebaseRecyclerAdapter =new FirebaseRecyclerAdapter<Subscribers, DataViewHolder>(options) {
@NonNull
@Override
public DataViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.list_subscribers, parent, false);
HomeFragment.DataViewHolder viewHolder =new HomeFragment.DataViewHolder(view);
return viewHolder;
}
@Override
protected void onBindViewHolder(@NonNull DataViewHolder holder, int position, @NonNull Subscribers model) {
final String pos = getRef(position).getKey();
holder.sName.setText(model.getSubName());
holder.sId.setText(model.getSubID());
holder.sId.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
myClip = ClipData.newPlainText("text", model.getSubID());
myClipboard.setPrimaryClip(myClip);
Toast.makeText(getActivity(), "Subscriber ID Copied",
Toast.LENGTH_SHORT).show();
}
});
holder.call.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!(model.getSubPhone() == ""))
{
checkCallingPermission(Manifest.permission.CALL_PHONE, CALL_PERMISSION_CODE,model.getSubPhone());
}else {
Toast.makeText(getActivity(),"Something went wrong",Toast.LENGTH_SHORT).show();
}
}
});
holder.mView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent mainIntent = new Intent(getActivity(), CustomerActivity. class);
mainIntent.putExtra("pos",pos);
startActivity(mainIntent);
getActivity().finish();
}
});
}
};
list.setAdapter(firebaseRecyclerAdapter);
firebaseRecyclerAdapter.startListening();
}
@Override
public void onDestroyView() {
super.onDestroyView();
binding = null;
}
public class DataViewHolder extends RecyclerView.ViewHolder {
TextView sName, sId, lpAmount,lpDate, rent,due;
ImageView call;
LinearLayout mView;
public DataViewHolder(@NonNull View itemView) {
super(itemView);
sName = itemView.findViewById(R.id.subName);
call = itemView.findViewById(R.id.subCall);
sId = itemView.findViewById(R.id.subID);
lpAmount = itemView.findViewById(R.id.lpAmount);
lpDate = itemView.findViewById(R.id.lpDate);
rent = itemView.findViewById(R.id.lRent);
due = itemView.findViewById(R.id.lDue);
mView = itemView.findViewById(R.id.baseLayout);
}
}
有人能帮我解决这个问题吗,为什么会出现这个错误。提前感谢!!还有新年快乐
附言:我是个新手
在类e8. g上发现的错误No属性序列化表示pojo模型的属性已被混淆,Firebase无法识别。向${your_project}/${your_module}/proguard-rules.pro添加规则:
keepclassmembers class com.helium4.aplo.model. ** {
*;
}
此规则将禁用com中模型的模糊处理。helium4。阿波罗。型号。*包裹
proGuard规则留档可以在这里查看https://www.guardsquare.com/manual/configuration/usage#keepclassmembernames
我正在创建我的第一个Firebase应用程序。它的要求之一是在网络不可用时运行。Firebase指南指出: 启用磁盘持久性允许我们的应用程序即使在重新启动应用程序后也保持其所有状态。我们只需一行代码就可以实现磁盘持久性。FirebaseDatabase。getInstance()。setPersistenceEnabled(true);启用磁盘持久性后,我们的同步数据和写入将在应用程序重新启动时持
mydateutils.java:
当我运行应用程序并转到用户的活动时,应用程序崩溃,显示mUsersList。setHasFixedSize(真);正在使应用程序崩溃。 这是消息“由以下原因引起:java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法'void androidx.recyclerview.widget.recyclerview.setHasFixedSize(布尔)'”
每当我单击登录页面中的“注册”按钮时,应用程序就会崩溃,无法移动到下一个活动。我已经在这个问题上纠缠了一天,似乎在任何地方都找不到解决办法。 下面是我为注册按钮方法编写的代码。(和是文本输入布局) Logcat在第7行显示错误,即ref.child(…行)。我尝试了第7行的替代方法,如:
我尝试了太多东西,但每次按下“计算”(hesapla)按钮后,应用程序都会崩溃。 例如: 我应该写什么/做什么? 有一只原木猫; 通用域名格式。ertugrulguleryuzgmail。sdunothesaplama E/AndroidRuntime:致命异常:主java。lang.NumberFormatException:无效的int:“”在java上。整型。java上的invalidit(
以下是logcat中显示的错误。