小编Ash*_*ish的帖子

请务必先在Android中调用FirebaseApp.initializeApp(上下文)

我正面临这个问题,并在这个网站上看到了一些答案,但没有得到任何适当的解决方案.
我已经使用以前的版本中Firebase,工作正常,但是当我尝试使用升级升级换代和更新FirebaseDatabaseReference它显示错误,无法正常工作.
我将整个代码添加到我的清单文件中,所以请帮我解决这个问题.
这是我的manifest

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

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:name=".Activity.SimpleBlog"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".Activity.RegisterActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

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

Module app在下面给出.

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "firebasechat.com.firebasechat"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        multiDexEnabled  true

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles …
Run Code Online (Sandbox Code Playgroud)

android firebase

40
推荐指数
7
解决办法
6万
查看次数

Kotlin文件更改导致重新声明错误

对kotlin文件的每次更改都会在构建时导致重新声明错误。解决它的唯一方法是清理项目,然后重新构建。项目中没有其他文件与我正在编辑的文件同名。

我试过了:

  • 重命名我一直在研究的课程
  • 在Android Studio中升级和降级Kotlin,Gradle和Kotlin插件的版本
  • 使用Beta Android Studio
  • 重新排序我的gradle文件中的插件

当前版本正在使用:

org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21
com.android.tools.build:gradle:3.2.0
Run Code Online (Sandbox Code Playgroud)

导致错误的示例代码。如果我没有构建addedThisLine它,它将作为它的第一个构建。然后,无论如何我编辑文件都会导致以下错误。

package beagle.com

class ErrorFragment {

    val hello = "Hello"

    init {
        var goodbye = "goodbye"
        var addedThisLine = "When this line is added I get error"
    }
}
Run Code Online (Sandbox Code Playgroud)

错误我得到

重新声明错误

这发生在我项目中的每个kotlin文件中,我上面发布的代码是最基本的文件。如您所见,它指向错误的类的名称。

android kotlin

13
推荐指数
3
解决办法
1476
查看次数

Firebase 应用内消息显示在 SplashActivity 中。如何在 MainActivity 中显示它?

我已为我的 android 应用启用 Firebase 应用内消息传递。当我测试应用内消息时,它显示在应用的 SplashActivity 中。

活动流程如下:SplashActivity>LoginActivity>MainActivity

注意:SplashActivity 刚刚可以运行以获得 3 秒的延迟。LoginActivity 有一些函数来检查共享首选项是否为空。

我试图在 onCreate() 下面的代码行中添加: FirebaseInAppMessaging.getInstance().setMessagesSuppressed(true)

FirebaseInAppMessaging.getInstance().setMessagesSuppressed(false)在的onDestroy()

我希望此消息显示在 MainActivity 中。

android kotlin firebase firebase-in-app-messaging

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

添加Firebase核心版本17.0.0后,清单合并失败

我向项目添加了Firebase crashlytics依赖关系,此后该项目无法生成。

https://firebase.google.com/docs/crashlytics/get-started?authuser=0&platform=android#android

您能否建议我可能做错了什么。

谢谢R

在这些行上构建失败

implementation "com.google.android.gms:play-services-base:17.0.0"
implementation 'com.google.firebase:firebase-core:17.0.0'
Run Code Online (Sandbox Code Playgroud)

这是错误日志

Task :app:processDebugManifest FAILED
C:\Development\xxx\xxx-app\android\app\src\main\AndroidManifest.xml:22:18-91 Error:
    Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
    is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
    Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:7:5-35:19 to override.

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
    is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 …
Run Code Online (Sandbox Code Playgroud)

android firebase crashlytics android-gradle-plugin react-native

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

弹出窗口有问题

我试图设置类似于旧的Facebook评论部分的弹出窗口.

圆角对话框,但我现在面临一个问题,size of dialog boxshowatlocation对话框.

当我在不同的手机上尝试此代码时:

        val display = windowManager.defaultDisplay
        val size = Point()
        display.getSize(size)
        val popupWindow = PopupWindow(customView, size.x-30, size.y-300, true)
        popupWindow.showAtLocation(linearLayout1, Gravity.CENTER, -3, 100)
        popupWindow.setAnimationStyle(R.style.PopupAnimation)
Run Code Online (Sandbox Code Playgroud)

Xml文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/dialog_bg"
    android:gravity="center"
    android:orientation="vertical"
    android:padding="10px">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:orientation="horizontal">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/popup_rcv"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

        <EditText
            android:id="@+id/new_comment_et"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:hint="Please enter Comment" />

        <Button
            android:id="@+id/comment_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Submit" />
    </LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

//来自Source的动画

Oneplus 6T输出: 一加

在一个加号我的动画也禁用当我将.showAtLocation更改为其他数字

联想K8输出注:

K8注意

在K8中,如果我更改为另一个值,则弹出窗口的位置会发生变化.

先感谢您.

android popupwindow kotlin

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

PopupWindow输入退出动画不在Marshmallow上工作(23)

我已进入/退出动画风格为PopupWindow这样的

 mPopupWindow.setAnimationStyle(R.style.PopupAnimation);
Run Code Online (Sandbox Code Playgroud)

和风格一样

<style name="PopupAnimation" parent="Widget.AppCompat.PopupWindow">
    <item name="android:windowEnterAnimation">@anim/popup_show</item>
    <item name="android:windowExitAnimation">@anim/popup_hide</item>
</style>
Run Code Online (Sandbox Code Playgroud)

因此,当PopupWindow显示/隐藏时,它具有适用于Lollipop以及所有以前的Android版本的动画.但随着Marshmallow动画时间间隔后弹出窗口显示并且没有动画效果.

动画/弹出窗口show.xml

<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0.0"
    android:toAlpha="1.0"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:duration="1000"/>
</set>
Run Code Online (Sandbox Code Playgroud)

动画/弹出窗口hide.xml

<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="1.0"
    android:toAlpha="0"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:duration="1000"/>
</set>
Run Code Online (Sandbox Code Playgroud)

android android-animation android-popupwindow android-6.0-marshmallow

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

如何获得毕加索的最新版本代码

我想在我的项目中实施毕加索,但是当我尝试在我的项目中实施毕加索时。我访问了他们的网站以获得依赖。但是他们删除了最新的版本号,所以我找不到Picasso 的最新版本号。

如果有人评论该版本,我会很高兴

网站链接(点击这里

提前致谢

android picasso

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

textView.setText(string) 和 textView.text = $string 有什么区别

嗨,我正在用Kotlin制作一个应用程序,我发现我可以同时使用

textView.setText(str)
Run Code Online (Sandbox Code Playgroud)

textView.text = $str
Run Code Online (Sandbox Code Playgroud)

我想知道我应该使用什么以及它们之间的区别。谢谢你。

android kotlin

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

通过短信自动读取OTP

我正在尝试通过使用这种方法来读取短信。但是我的应用程序未读取Message。

我尝试过的代码。

权限:

<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
Run Code Online (Sandbox Code Playgroud)

活动(主要代码):

class OtpActivity : AppCompatActivity(), View.OnClickListener {
    private var smsVerifyCatcher: SmsVerifyCatcher? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_otp)
        smsVerifyCatcher = SmsVerifyCatcher(this, OnSmsCatchListener { message ->
            val code = parseCode(message)//Parse verification code
            Log.e("Code", code)
            //then you can send verification code to server
        })
        smsVerifyCatcher!!.setPhoneNumberFilter("0902249") // I passed 10 digit number here
        smsVerifyCatcher!!.setFilter("Ashish") // For extra i added Filter for name
    }
    private fun parseCode(message: String): …
Run Code Online (Sandbox Code Playgroud)

sms android one-time-password kotlin

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

在laravel中注册用户时,如何在userrole表中保存用户ID和角色ID?

我有一个角色表,用户表和users_role表。我要在注册用户时存储user_id和role_id。注册用户时,角色应为1。我怎样才能做到这一点?

角色表

public function up()
{
    Schema::create('roles', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->timestamps();
    });
}
Run Code Online (Sandbox Code Playgroud)

用户表

public function up()
{
    Schema::create('users', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string('email')->unique();
        $table->string('password');
        $table->string('image')->nullable();
        $table->boolean('status')->default(0);
        $table->rememberToken();             
        $table->timestamp('email_verified_at')->nullable();           
        $table->softDeletes();
        $table->timestamps();
    });
}
Run Code Online (Sandbox Code Playgroud)

UserRoles表

public function up()
{
    Schema::create('users_role', function (Blueprint $table) {
        $table->increments('id');
        $table->unsignedInteger('user_id');
        $table->foreign('user_id')->references('id')->on('users')- 
        >onDelete('cascade');
        $table->unsignedInteger('role_id');
        $table->foreign('role_id')->references('id')->on('roles')- 
        >onDelete('cascade');
        $table->timestamps();
    });
}
Run Code Online (Sandbox Code Playgroud)

laravel

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