找不到AWSMobileClient

时间:2018-02-10 18:22:08

标签: java android amazon-web-services amazon-mobile-hub

我已按照this步骤将AWS Mobile SDK添加到我的应用中。 当我到达"连接你的后端"的第4步时部分并尝试编译我的应用程序我收到以下错误:

Error:(20, 9) error: cannot find symbol variable AWSMobileClient

我查找了文档here,发现AWSMobileClient类应该在com.amazonaws.mobile.client.AWSMobileClient包中,但是当我尝试手动导入提到的包时,我得到以下错误:

Error:(9, 28) error: package com.amazonaws.mobile does not exist

我当前的项目文件如下所示:

MainActivity.java

package point.cursoandroid.com.medpoint;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {

    private Button botaoLogin;

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

        AWSMobileClient.getInstance().initialize(this).execute();
        botaoLogin = (Button) findViewById(R.id.botaoLoginId);

        botaoLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MainActivity.this, LoginActivity.class));
            }
        });
    }
}

app / build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"

    defaultConfig {
        applicationId "point.cursoandroid.com.medpoint"
        minSdkVersion 25
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:27.+'
    compile 'com.android.support:support-v4:27.+'
    compile 'com.android.support:design:27.+'
    compile 'com.amazonaws:aws-android-sdk-core:2.6.+'
    compile 'com.amazonaws:aws-android-sdk-s3:2.6.+'
    compile 'com.amazonaws:aws-android-sdk-ddb:2.6.+'
}

使用AndroidStudio 3.0.1 那么,有什么想法吗?

1 个答案:

答案 0 :(得分:9)

您需要在build.gradle中导入相应的依赖项

dependencies {
    compile ('com.amazonaws:aws-android-sdk-mobile-client:2.6.+@aar') { transitive = true; }
}

执行gradle同步,您应该能够导入类和包。