I`ve followed this steps to add the AWS Mobile SDK to my app. When I reach step 4 of the "Connect your backend" section and try to compile my app I get the following error:
Error:(20, 9) error: cannot find symbol variable AWSMobileClient
I've looked up the documentation here and found that the AWSMobileClient
class should be inside the com.amazonaws.mobile.client.AWSMobileClient
package, but when I try to manually import the mentioned package, I get the following error:
Error:(9, 28) error: package com.amazonaws.mobile does not exist
My current project files look like these:
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.+'
}
Using AndroidStudio 3.0.1 So, any ideas?
You need to import the appropriate dependencies in build.gradle
dependencies {
implementation ('com.amazonaws:aws-android-sdk-mobile-client:2.16.+@aar') { transitive = true; }
}
Perform a gradle sync and you should be able to import the class and package.
EDIT: Replace 2.16.+
with the latest version of the AWS SDK for Android. The latest version can be found either in GitHub or Maven Repository.
More information about AWSMobileClient
can be found in the Documentation and APIReference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With