小编Md.*_*man的帖子

应用程序启动时突然出现 Firebase java.lang.IllegalAccessError

安装后应用程序初始启动时突然发生崩溃!但只是第一次......第二次打开应用程序后,它可以正常工作。

我没有更改 firebase 代码,但可能是依赖项……但是到了最新版本……所以通常它应该是稳定的!

它似乎有一些与 firebase 相关的问题:

java.lang.IllegalAccessError:非法类访问:“com.google.firebase.messaging.zze”试图访问“com.google.firebase.iid.zzat”(出现“com.google.firebase.messaging.zze”声明在 base.apk 中)

我的配置:

Build.gradle(项目)

buildscript {
    ext.kotlin_version = '1.3.61'
    repositories {
        google()
        jcenter()
        maven { url 'https://plugins.gradle.org/m2/' } //for OneSignal
        maven { url 'https://maven.fabric.io/public' } //for CrashLytics
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'io.fabric.tools:gradle:1.31.0'  // Crashlytics plugin

        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.5' //for OneSignal

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter() …
Run Code Online (Sandbox Code Playgroud)

dependencies android build gradle firebase

7
推荐指数
1
解决办法
1930
查看次数

在 Flutter 中按下后退按钮时关闭导航抽屉

我的第一个 flutter 应用程序中有一个材质设计的导航抽屉。这项工作很好,但我没有找到任何方法来关闭后退按钮按下时的导航抽屉,如果它在使用时打开WillPopScope以显示AlertDialog. AlertDialog当回按时,应用程序只是显示而不是关闭抽屉。如果已经打开,我希望抽屉应该关闭,AlertDialog否则显示。

@override
Widget build(BuildContext context) {
  return WillPopScope(
    onWillPop: onBackPressed,
    child: Scaffold(
      appBar: AppBar(
        title: Text("Home"),
      ),
      drawer: Drawer(
      ),
      body: Center(
        child: Text("Home"),
      ),
    ),
  );
}
Run Code Online (Sandbox Code Playgroud)

onBackPressed显示关闭应用程序的对话框。

Future<bool> onBackPressed() {
  return showDialog(
      barrierDismissible: false,
      context: context,
      builder: (context) => AlertDialog(
            title: Text("Do you want to exit?"),
            actions: <Widget>[
              FlatButton(
                  onPressed: () => Navigator.pop(context, false),
                  child: Text("No")),
              FlatButton(
                  onPressed: () => Navigator.pop(context, true),
                  child: Text("Yes"))
            ],
          ));
} …
Run Code Online (Sandbox Code Playgroud)

android dart material-design flutter

7
推荐指数
1
解决办法
3739
查看次数

java.text.parseException:无法解析的日期:2020-02-06T08:00:00

当我将特定格式应用于日期时出现解析异常。

SimpleDateFormat df = new SimpleDateFormat("hh:mm a");
try {
    String s=timeSlotsArrayList.get(position).getScheduledStartTime();
    Date d = df.parse(s);
    times.setText(df.format(d));
}
catch (ParseException e) {
    e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

AM 正在获取而不是 PM 问题图像

AM 正在获取而不是 PM 问题图像

format time android simpledateformat parseexception

6
推荐指数
1
解决办法
3034
查看次数

androidx.gridlayout.widget.GridLayout 不能转换为 android.widget.GridLayout

我收到错误

"Caused by: java.lang.ClassCastException: androidx.gridlayout.widget.GridLayout cannot be cast to android.widget.GridLayout", in mainActivity.java

 GridLayout mygridLayout = findViewById(R.id.gridLayout);

 for(int i=0; i<mygridLayout.getChildCount(); i++)
 {
     ((ImageView) mygridLayout.getChildAt(i)).setImageResource(0);
 }
Run Code Online (Sandbox Code Playgroud)

java android android-activity androidx

4
推荐指数
3
解决办法
4108
查看次数

AAPT:错误:在 &lt;manifest&gt; 中找到意外元素 &lt;adaptive-icon&gt;

我正在尝试在 React Native Android 中使用自适应图标,但它产生以下错误。

AAPT:错误:在以下位置找到意外元素

这是我的 manifes.xml

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.anar">

  <uses-permission android:name="android.permission.INTERNET" />   <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />   <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />   <uses-permission android:name="android.permission.VIBRATE" />



  <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="false" android:theme="@style/AppTheme">
    <activity android:screenOrientation="portrait" android:launchMode="singleTop" android:name=".MainActivity" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:windowSoftInputMode="adjustResize">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
    <meta-data android:name="com.google.android.geo.API_KEY" android:value="MY_API_KEY_IS_HIDDEN"/>
    <service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
      <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
      </intent-filter>
    </service>

    <service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" />

  </application>

  <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <background android:drawable="@color/ic_launcher_background" />
    <foreground android:drawable="@mipmap/ic_launcher_foreground" />   </adaptive-icon>



</manifest>
Run Code Online (Sandbox Code Playgroud)

android react-native adaptive-icon

4
推荐指数
1
解决办法
2710
查看次数

从 Fragment 中的按钮单击打开导航抽屉 (Kotlin)

在 Fragment 中创建了一个自定义按钮我试图单击它时在 Activity 中打开导航抽屉。

当您滑动时,导航抽屉仍然可以正常打开,但是当我单击按钮时应用程序崩溃了。

我想这是因为我试图从 Fragment 访问,但我不知所措..

分段

override fun onCreateView(
    inflater: LayoutInflater, container: ViewGroup?,
    savedInstanceState: Bundle?): View? {
    // Inflate the layout for this fragment
    val binding: SiteFragmentBinding = DataBindingUtil.inflate(
        inflater, R.layout.site_fragment, container, false
    )

    binding.apply {
        siteOverflowOptionsMenuButton.setOnClickListener{
            showPopUp(it)
        }

        siteDrawerMenuButton.setOnClickListener{
            drawer_layout.openDrawer(nav_view)  // this crashes (also crashes with Gravity.LEFT or similar)
        }

    }

    return binding.root
}
Run Code Online (Sandbox Code Playgroud)

活动.xml

?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:fitsSystemWindows="true"
    tools:openDrawer="start"> …
Run Code Online (Sandbox Code Playgroud)

android fragment kotlin navigation-drawer

4
推荐指数
1
解决办法
3506
查看次数

当我返回到 Fragment 时,立即调用观察者

我有一个观察者,而不是当它被称为更改片段时。

问题是当我返回时,立即调用观察者,并且我的应用程序崩溃了

java.lang.IllegalArgumentException:导航目标 com.superapps.ricardo.tablepro:id/action_searchFragment_to_yourGameList2 对于此 NavController 来说是未知的。

我不明白为什么会这样称呼它。

这是更改列表的唯一方法

override fun onSuccess(gamePair: Pair<Int, List<BggGame>>) {
        CoroutineScope(Main).launch{
            //goToList(gamePair.second, binding.input.text.toString())
            viewModel.setGameList(gamePair.second)
        }
    }
Run Code Online (Sandbox Code Playgroud)

这是视图模型创建和更改片段代码

override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        viewModel = ViewModelProviders.of(this).get(SearchViewModel::class.java)
        viewModel.gameList.observe(viewLifecycleOwner, Observer {
            goToList(it, binding.input.text.toString())
        })
    }


    private fun goToList(games: List<BggGame>, user: String) {
        val action = SearchFragmentDirections.actionSearchFragmentToYourGameList2(user)
        val gameList = GameList()
        gameList.gameList = games
        action.gameList = gameList

        try {
            Navigation.findNavController(view!!).navigate(action)
            viewModel.gameList.removeObservers(viewLifecycleOwner)
        } catch (e: Exception){
            Log.e("a0,","a..", e)
        }
        progressDialog.dismiss()

    }
Run Code Online (Sandbox Code Playgroud)

android observers kotlin

3
推荐指数
1
解决办法
1644
查看次数

对于多个项目,.notifyItemInserted() 的替代方案是什么?

我正在使用 RecyclerView,并且.notifyItemInserted仅将一项插入到 RecyclerView 中。对于多个项目,我该怎么做?我想避免使用.notifyDataSetChanged().

假设我有25 items,我想插入another 20,我会调用什么方法?

android android-recyclerview

3
推荐指数
1
解决办法
222
查看次数

如何同时使用 AppBarConfiguration 和 setNavigationItemSelectedListener

我的导航菜单中有 8 个项目。我为其中 5 个设置了片段,我想为最后 3 个设置吐司。当我不设置案例 2 时,案例 1 运行良好。但是当我设置案例 2 时,案例 1 不起作用。

情况1 :

DrawerLayout drawer = findViewById(R.id.drawer_layout);
NavigationView navigationView = findViewById(R.id.nav_view);
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.

//define in mobile_navigation.xml
mAppBarConfiguration = new AppBarConfiguration.Builder(
    R.id.nav_home, R.id.nav_update_data, R.id.nav_notifications,
    R.id.nav_stop, R.id.nav_change_pass)
    .setDrawerLayout(drawer)
    .build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
NavigationUI.setupWithNavController(navigationView, navController);
Run Code Online (Sandbox Code Playgroud)

案例2:

navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
    @Override
    public boolean onNavigationItemSelected(@NonNull MenuItem item) …
Run Code Online (Sandbox Code Playgroud)

java android navigation-drawer

2
推荐指数
1
解决办法
1394
查看次数

将折线添加到地图错误解决失败:Ljava/time/ZonedDateTime

我正在尝试将折线添加到当前位置和动态添加到地图的标记之间的地图。它应该工作的方式是,当InfoWindow按下标记时,会打开一个对话框,询问您是否要前往该点,当按下“是”选项时,它应该将折线添加到该点。

\n\n

单击信息窗口时:

\n\n
public void onInfoWindowClick(final Marker marker1) {\n    final AlertDialog.Builder builder = new AlertDialog.Builder(this);\n    builder.setMessage("Dori\xc8\x9bi s\xc4\x83 merge\xc8\x9bi la aceast\xc4\x83 alert\xc4\x83?")\n            .setCancelable(true)\n            .setPositiveButton("Da", new DialogInterface.OnClickListener() {\n                public void onClick(@SuppressWarnings("unused") final DialogInterface dialog, @SuppressWarnings("unused") final int id) {\n                    ScoateMarkerRute();\n                    markerSelectat=marker1;\n                    layout_confirmare.setVisibility(GONE);\n                    layout_validare.setVisibility(GONE);\n                    calculateDirections(marker1);\n                    dialog.dismiss();\n                }\n            })\n            .setNegativeButton("Nu", new DialogInterface.OnClickListener() {\n                public void onClick(final DialogInterface dialog, @SuppressWarnings("unused") final int id) {\n                    dialog.cancel();\n                }\n            });\n    final AlertDialog alert = builder.create();\n    alert.show();\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

计算方向();:

\n\n
private void calculateDirections(Marker marker){\n    Log.d(TAG, "calculateDirections: …
Run Code Online (Sandbox Code Playgroud)

java android google-maps

2
推荐指数
1
解决办法
2216
查看次数

如何获取应用程序类的实例?

我正在使用一个类哪个extends Application类。我在这个类中有一个方法。我需要在实例的帮助下调用这个方法。每当我使用实例调用此方法时,它都会抛出异常NullPointerException,因为实例始终为空。我正在使用单例模式来获取实例。

应用程序设置.java

public class AppSetting extends Application {
    private static AppSetting instance;

    @Override
    public void onCreate() {
        super.onCreate();

        instance = new AppSetting();
        ....
    }

    public static synchronized AppSetting getInstance() {
        if (instance == null) {
            instance = new AppSetting();
            return instance;
        }
        return instance;
    }

    public somemethod() {
        return...
    }
}
Run Code Online (Sandbox Code Playgroud)

活动

我正在使用这段代码来调用该方法AppSetting.getInstance().somemethod()

我总是发现该实例为空。如何正确获取实例?我在创建实例时做错了什么吗?

singleton android

1
推荐指数
1
解决办法
2222
查看次数

如何去除底部导航阴影

正如我在下图中所示,我想删除底部导航的阴影。 在此输入图像描述

我尝试下面的解决方案并发现它们的名词很有用:

Android:删除底部导航的阴影

这是我的 xml 文件:

<com.google.android.material.bottomnavigation.BottomNavigationView
    android:id="@+id/main_navigation"
    android:layout_width="match_parent"
    android:layout_height="56dp"
    android:background="#ffffff"
    android:theme="@style/Widget.BottomNavigationView"
    app:menu="@menu/botton_navigation_menu"
    android:layout_above="@+id/phone_frame"
    android:elevation="0dp"/>
Run Code Online (Sandbox Code Playgroud)

android bottomnavigationview

1
推荐指数
1
解决办法
1311
查看次数

选择项目时 onNavigationItemSelected 不调用

我正在使用以下代码在导航抽屉中添加页脚视图 -

<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <com.google.android.material.navigation.NavigationView
        android:id="@+id/nv_top"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="top|start">

        <androidx.core.widget.NestedScrollView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="vertical">
                <include layout="@layout/nav_header_main"/>

                <com.google.android.material.navigation.NavigationView
                    android:id="@+id/drawer_menu_body"
                    app:elevation="0dp"
                    android:layout_height="0dp"
                    android:layout_width="wrap_content"
                    android:layout_weight="1"
                    app:menu="@menu/activity_main_drawer">

                </com.google.android.material.navigation.NavigationView>

                <include layout="@layout/navigation_drawer_bottom_view"/>
            </LinearLayout>

        </androidx.core.widget.NestedScrollView>
    </com.google.android.material.navigation.NavigationView>


</androidx.drawerlayout.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

但是现在 onNavigationItemSelected() 没有调用导航抽屉也保持打开状态,直到我们手动滑动它。我正在使用导航组件和导航图。

带有页脚视图的侧边菜单

这是我的活动代码 -

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
    val toolbar: Toolbar = findViewById(R.id.toolbar)
    setSupportActionBar(toolbar)

    val navController = findNavController(R.id.nav_host_fragment)
    drawer_menu_body.setNavigationItemSelectedListener(this)
    nv_top.setNavigationItemSelectedListener(this)

    appBarConfiguration = AppBarConfiguration(
        setOf(
            R.id.nav_home,
            R.id.nav_gallery,
            R.id.nav_slideshow,
            R.id.nav_tools,
            R.id.nav_share, …
Run Code Online (Sandbox Code Playgroud)

navigation android menu navigation-drawer

-2
推荐指数
1
解决办法
1333
查看次数