1

我正在利用 Auth.UI 方法使用 AWS Mobile SDK 开发示例 Android 应用程序。

构建和运行应用程序时,它会崩溃并出现以下错误:

java.lang.NoSuchMethodError: No virtual method canCancel(Z)Lcom/amazonaws/mobile/auth/ui/AuthUIConfiguration$Builder;

我的应用程序和配置文件如下:

主要活动:

public class AuthenticatorActivity extends AppCompatActivity {

    private final String TAG = AuthenticatorActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_authenticator);

        AWSMobileClient.getInstance().initialize(getApplicationContext(), new Callback<UserStateDetails>() {

            //@Override
            public void onResult(UserStateDetails userStateDetails) {
                Log.i(TAG, userStateDetails.getUserState().toString());
                switch (userStateDetails.getUserState()){
                    case SIGNED_IN:
                        Intent i = new Intent(AuthenticatorActivity.this, MapsActivity.class);
                        startActivity(i);
                        break;
                    case SIGNED_OUT:
                        showSignIn();
                        break;
                    default:
                        AWSMobileClient.getInstance().signOut();
                        showSignIn();
                        break;
                }
            }

            //@Override
            public void onError(Exception e) {
                Log.e(TAG, e.toString());
            }
        });
    }

    private void showSignIn() {
        try {
            AWSMobileClient.getInstance().showSignIn(this,
                    SignInUIOptions.builder().nextActivity(MapsActivity.class).build());
        } catch (Exception e) {
            Log.e(TAG, e.toString());
        }
    }
}

摇篮文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"

    defaultConfig {
        applicationId "com.syumak.maps"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    def support_version = '27.1.1'
    def constraint_version = '1.1.2'
    def lifecycle_version = '1.1.1'
    def paging_version = '1.0.1'

    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    // Add AWS Mobile SDK
    implementation('com.amazonaws:aws-android-sdk-mobile-client:2.8.+@aar') { transitive = true }
    implementation 'com.amazonaws:aws-android-sdk-core:2.6.0'
    implementation 'com.amazonaws:aws-android-sdk-pinpoint:2.6.0'
    implementation 'com.amazonaws:aws-android-sdk-auth-ui:2.6.0@aar'
    implementation 'com.amazonaws:aws-android-sdk-auth-core:2.6.0@aar'
    implementation 'com.amazonaws:aws-android-sdk-auth-userpools:2.6.0@aar'
    implementation 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.6.0'

    // Android Architecture Components
    implementation "android.arch.lifecycle:extensions:$lifecycle_version"
    implementation "android.arch.paging:runtime:$paging_version"

}

LogCat 日志:

java.lang.NoSuchMethodError: No virtual method canCancel(Z)Lcom/amazonaws/mobile/auth/ui/AuthUIConfiguration$Builder; in class Lcom/amazonaws/mobile/auth/ui/AuthUIConfiguration$Builder; or its super classes (declaration of 'com.amazonaws.mobile.auth.ui.AuthUIConfiguration$Builder' appears in /data/app/com.syumak.maps-tjxXncPiAxnrYhKy61VcbQ==/base.apk)
    at com.amazonaws.mobile.client.AWSMobileClient$19.run(AWSMobileClient.java:1975)
    at com.amazonaws.mobile.client.internal.InternalCallback.await(InternalCallback.java:115)
    at com.amazonaws.mobile.client.AWSMobileClient.showSignIn(AWSMobileClient.java:1957)
    at com.syumak.maps.AuthenticatorActivity.showSignIn(AuthenticatorActivity.java:58)
    at com.syumak.maps.AuthenticatorActivity.access$100(AuthenticatorActivity.java:20)
    at com.syumak.maps.AuthenticatorActivity$1.onResult(AuthenticatorActivity.java:40)
    at com.syumak.maps.AuthenticatorActivity$1.onResult(AuthenticatorActivity.java:29)
    at com.amazonaws.mobile.client.internal.InternalCallback.call(InternalCallback.java:75)
    at com.amazonaws.mobile.client.internal.InternalCallback.onResult(InternalCallback.java:62)
    at com.amazonaws.mobile.client.AWSMobileClient$2.run(AWSMobileClient.java:424)
    at com.amazonaws.mobile.client.internal.InternalCallback$1.run(InternalCallback.java:101)
    at java.lang.Thread.run(Thread.java:764)
4

0 回答 0