@Shadrindmitry

Почему не работает databinding c VKSdk?

Ошибка во время компиляции: [databinding] {"msg":"cannot find method login(android.content.Context, java.lang.Object) in class com.vk.sdk.VKSdk"

layout xmlns:android="http://schemas.android.com/apk/res/android">

    <data>
        <import type="com.vk.sdk.VKSdk"/>
    </data>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context=".ui.AuthorizationActivity">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="@{() -> VKSdk.login(context, null)}"

        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>


public class AuthorizationActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ActivityAuthorizationBinding binding =
                DataBindingUtil.setContentView(this, R.layout.activity_authorization);
        
    }
}


apply plugin: 'com.android.application'

project.ext {
    appcompatVersion = "1.0.2"
    materialVersion = "1.0.0"
    constraintlayoutVersion = "1.1.3"
    vectordrawableVersion = "1.0.1"
    navigationfragmentVersion = "2.0.0"
    navigationuiVersion = "2.0.0"
    lifecycleVersion = "2.0.0"
    appcompatVersion = "1.0.2"
    constraintlayoutVersion = "1.1.3"
    vksdkVersion = "1.6.7"
}

android {
    compileSdkVersion 28
    buildToolsVersion "29.0.1"
    defaultConfig {
        applicationId "com.example.dps"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    dataBinding {
        enabled = true
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation "androidx.appcompat:appcompat:$project.appcompatVersion"
    implementation "com.google.android.material:material:$project.materialVersion"
    implementation "androidx.constraintlayout:constraintlayout:$project.constraintlayoutVersion"
    implementation "androidx.vectordrawable:vectordrawable:$project.vectordrawableVersion"
    implementation "androidx.navigation:navigation-fragment:$project.navigationfragmentVersion"
    implementation "androidx.navigation:navigation-ui:$project.navigationuiVersion"
    implementation "androidx.lifecycle:lifecycle-extensions:$project.lifecycleVersion"
    implementation "androidx.appcompat:appcompat:$project.appcompatVersion"
    implementation "androidx.constraintlayout:constraintlayout:$project.constraintlayoutVersion"

    // VK SDK
    implementation "com.vk:androidsdk:$project.vksdkVersion"

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
  • Вопрос задан
  • 41 просмотр
Решения вопроса 1
zagayevskiy
@zagayevskiy Куратор тега Android
Android developer at Yandex
Если посмотреть в исходники, там действительно нет такого метода. Есть метод, который принимает активити и varargs строк.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
Frogogo Москва
от 120 000 руб.
Immoviewer Ярославль
от 1 500 до 2 500 usd.
RentaTeam Москва
от 120 000 до 170 000 руб.