I have recently cloned an already running code in android studio. I am stuck in this error for couple of days now, I am using a class AbstractMapAcivity which extends MapActivity class from "com.google.android.maps". Android studio gives the below error:
error: package com.google.android.maps does not exist
please help android/android studio experts, I am new to android development. Have a look at the supporting classes and project settings
build. gradle : app
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion "Google Inc.:Google APIs:23"
buildToolsVersion '23.0.3'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.nccatalog"
minSdkVersion 14
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/DEPENDENCIES'
}
}
dependencies {
compile "com.android.support:support-v4:${supportLibVersion}"
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:mediarouter-v7:${supportLibVersion}"
compile "com.google.android.gms:play-services-gcm:${gcmLibVersion}"
compile "com.google.code.gson:gson:${gsonLibVersion}"
compile files('libs/FlurryAnalytics-4.2.0.jar')
compile files('libs/gcm.jar')
compile files('libs/com.radaee.view.jar')
compile files('libs/httpcore-4.3.jar')
compile files('libs/org.apache.commons.io.jar')
compile files('libs/universal-image-loader-1.9.3-SNAPSHOT.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
}
build.gradle : project
buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'io.fabric.tools:gradle:1.30.0'
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
ext {
supportLibVersion = '23.4.0'
gcmLibVersion = '8.3.0'
gsonLibVersion = '2.7'
}
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
AbstractMapActivity.java
package com.utils.ui;
import android.app.Activity;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import com.google.android.maps.MapActivity;
import com.utils.application.ApplicationController;
public class AbstractMapAcivity extends MapActivity implements ActivityHelper {
private ActivityHelper ah = new ActivityHelperImpl(this);
#Override
protected void onCreate(Bundle savedInstanceState) {
ApplicationController.activityStack.add(this);
super.onCreate(savedInstanceState);
}
#Override
protected void onDestroy() {
ApplicationController.activityStack.remove(this);
super.onDestroy();
}
#Override
public void hideKeyboard(View view) {
ah.hideKeyboard(view);
}
#Override
public Typeface createTypeFace(String fontName) {
return ah.createTypeFace(fontName);
}
#Override
public Drawable createRepeatableDrawable(int imageId) {
return ah.createRepeatableDrawable(imageId);
}
#Override
public boolean isNetworkAvailable(Activity activity) {
return ah.isNetworkAvailable(activity);
}
#Override
protected boolean isRouteDisplayed() {
return false;
}
#Override
public void switchToActivity(Activity current,
Class<? extends Activity> otherActivityClass, Bundle extras) {
ah.switchToActivity(current, otherActivityClass, extras);
}
#Override
public void goToActivity(Activity current,
Class<? extends Activity> otherActivityClass, Bundle extras) {
ah.goToActivity(current, otherActivityClass, extras);
}
#Override
public void initUI() {
}
}
In your build.gradle (app)
dependencies {
//Your other compile dependencies (replace compile with implementation on them)
implementation 'com.google.android.gms:play-services-maps:17.0.1'
}
Seems like you are at least missing this line which should import maps, maybe other things are also missing that I can't see right now.
Take a look at this guide if you haven't already:
https://developers.google.com/maps/documentation/android-sdk/start
There is also a guide for existing projects (I assume you need information from both of them)
https://developers.google.com/maps/documentation/android-sdk/config
Open the Gradle you see in the picture.
Once it is open you will find the next image-like page, in dependencies add your dependency. And sync your file as well.
Related
I am getting these errors while compiling my project
For resolving the dex archives errors , I tried deleting the .gradle folder from my project directory but still the problem is not resolved.
This is my project gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
maven{
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is my app gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.spars.myapplication"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.razorpay:checkout:1.4.5'
implementation 'com.google.firebase:firebase-database:16.0.6'
implementation 'com.firebaseui:firebase-ui:3.0.0'
testImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
//added part xxx
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '27.1.1'
}
}
}
}
This is the Java file for my project:
package com.example.xxx.myapplication;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.firebase.ui.database.FirebaseListAdapter;
import com.firebase.ui.database.FirebaseListOptions;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;
public class MainActivity extends AppCompatActivity {
ListView lv;
FirebaseListAdapter adapter;
FirebaseDatabase database;
DatabaseReference ref;
TextView t;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
t.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this,Payment.class);
startActivity(i);
}
});
database = FirebaseDatabase.getInstance();
ref = database.getReference();
lv=(ListView)findViewById(R.id.listView);
Query query = FirebaseDatabase.getInstance().getReference().child("martyrs");
FirebaseListOptions<martyrs> options = new FirebaseListOptions.Builder<martyrs>()
.setLayout(R.layout.martyrs)
.setLifecycleOwner(MainActivity.this)
.setQuery(query,martyrs.class)
.build();
adapter = new FirebaseListAdapter(options) {
#Override
protected void populateView(View v, Object model, int position) {
//ImageView img = v.findViewById(R.id.);
TextView name = v.findViewById(R.id.name);
TextView age = v.findViewById(R.id.age);
martyrs mt = (martyrs) model;
name.setText(mt.getName().toUpperCase());
age.setText(mt.getAge().toUpperCase());
}
};
lv.setAdapter(adapter);
}
#Override
protected void onStart() {
super.onStart();
adapter.startListening();
}
#Override
protected void onStop() {
super.onStop();
adapter.stopListening();
}
}
And finally I'm getting the following errors :
Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: android.arch.lifecycle.LiveData$1
Can anybody help please?
Change
implementation 'com.firebaseui:firebase-ui:3.0.0'
To
implementation 'com.firebaseui:firebase-ui:3.3.1'
implementation 'android.arch.lifecycle:extensions:1.1.1
This solved it for me:
clean
rebuild
Please try it and give the feedback.
UPDATE 1:
Try adding the following line of code in your app.gradle
implementation "android.arch.lifecycle:extensions:1.0.0"
// Multidex
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.google.firebase:firebase-analytics:15.0.0'
I'm getting this error: package MyApi does not exist message when I run MainActivity. There is similar post here in StackOverFlow, but the solution doesn't work for me.
There is not a logcat stacktrace. What happens is that myApi which is the name of the API inside a class in Google Cloud Module backend is not being recognized and I really don't know why.
Class where my Api is located (module backend)
import com.google.api.server.spi.config.Api;
import com.google.api.server.spi.config.ApiMethod;
import com.google.api.server.spi.config.ApiNamespace;
import com.joketellingapp.lacourt.jokesource.JokeSource;
import javax.inject.Named;
/** An endpoint class we are exposing */
#Api(
name = "myApi",
version = "v1",
namespace = #ApiNamespace(
ownerDomain = "backend.builditbigger.gradle.udacity.com",
ownerName = "backend.builditbigger.gradle.udacity.com",
packagePath = ""
)
)
public class MyEndpoint {
#ApiMethod(name = "sayHi")
public MyBean sayHi() {
MyBean response = new MyBean();
response.setData(new JokeSource().getJoke());
return response;
}
}
Class from which i'm trying to access the API (module app)
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.support.v4.util.Pair;
import com.google.api.client.extensions.android.http.AndroidHttp;
import com.google.api.client.extensions.android.json.AndroidJsonFactory;
import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer;
import com.joketellingapp.lacourt.displayjoke.DisplayJoke;
import com.udacity.gradle.builditbigger.backend.myApi.MyApi;
import java.io.IOException;
class EndpointsAsyncTask extends AsyncTask<Pair<Context, String>, Void, String> {
private static MyApi myApiService = null;
private Context context;
#Override
protected String doInBackground(Pair<Context, String>... params) {
if(myApiService == null) { // Only do this once
MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(),
new AndroidJsonFactory(), null)
// options for running against local devappserver
// - 10.0.2.2 is localhost's IP address in Android emulator
// - turn off compression when running against local devappserver
.setRootUrl("http://10.0.2.2:8888/_ah/api/")
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
#Override
public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
abstractGoogleClientRequest.setDisableGZipContent(true);
}
});
// end options for devappserver
myApiService = builder.build();
}
context = params[0].first;
// String name = params[0].second;
try {
return myApiService.sayHi().execute().getData();
} catch (IOException e) {
return e.getMessage();
}
}
#Override
protected void onPostExecute(String result) {
// Toast.makeText(context, result, Toast.LENGTH_LONG).show();
Intent intent = new Intent(context, DisplayJoke.class);
intent.putExtra(DisplayJoke.JOKE_KEY, result);
context.startActivity(intent);
}
}
Build.gradle file (Module App)
apply plugin: 'com.android.application'
apply plugin: 'com.google.cloud.tools.endpoints-framework-client'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'
}
}
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.joketellingapp.lacourt.jokeapp"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// implementation project(path: ':backend', configuration: 'endpoints')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.google.android.gms:play-services-ads:11.8.0'
implementation 'com.google.api-client:google-api-client:1.23.0'
implementation 'com.google.http-client:google-http-client-android:1.23.0'
implementation 'com.google.code.findbugs:jsr305:3.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
api project(':jokeSource')
api project(':displayjoke')
api project(path: ':backend', configuration: 'endpoints')
// api project(path: ':backend')
}
Build.gradle file (Module Backend)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.3'
}
}
repositories {
jcenter()
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'com.google.cloud.tools.appengine'
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
appengine.run.port = 8888
dependencies {
implementation 'com.google.endpoints:endpoints-framework:2.0.9'
implementation 'javax.inject:javax.inject:1'
implementation 'javax.servlet:servlet-api:2.5'
implementation 'com.google.api-client:google-api-client:1.23.0'
implementation 'com.google.http-client:google-http-client-android:1.23.0'
compile project(path: ':jokeSource')
}
Top level Build.gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.guava:guava:22.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir;
}
According to the new plugin docs, it should be endpointsServer project(path: ":server", configuration: "endpoints").
I received it in my vritual device before...but after I uninstall and reinstalled my app from my AVD then I didnt get any messages but in firebase console its showing completed status..plz some one help me
This is Main Activity
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageButton budbtn=(ImageButton)findViewById(R.id.buddies);
budbtn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent intent= new Intent(MainActivity.this,BuddiesAct.class);
startActivity(intent);
}
});
ImageButton prim=(ImageButton)findViewById(R.id.primary);
ImageButton senior=(ImageButton)findViewById(R.id.senior);
ImageButton suprsen=(ImageButton)findViewById(R.id.supersenior);
}
}
Project level built gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.zion.kidskount"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
apply plugin: 'com.google.gms.google-services'
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'gr.pantrif:easy-android-splash-screen:0.0.1'
compile 'com.google.firebase:firebase-messaging:9.0.0'
testCompile 'junit:junit:4.12'
}
Everytime you reinstall or clear data of your application, your token is generated again.
Log your token everytime onTokenRefresh() is called as described here.
So, get your token and use it to send your push notification :D
I'm a new MPAndroidChart user.
The examples I have found on-line and the Wiki here all give the setDescription() prototype as:
setDescription(String desc)`
However, mChart.setDescription(""); does not compile for me and AndroidStudio->Go To Declaration tells me the declaration for setDescription defined in Chart.java is :
public void setDescription(Description desc) {
this.mDescription = desc;
}
And the Description constructor in Description.java does not take a String.
How do I set the description (or at least turn it off)? Am I pointing to the wrong libraries?
Here is my app's gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And, the module gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.android.nbmc_hbmc"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
compile 'com.google.android.gms:play-services-auth:10.0.1'
compile 'pub.devrel:easypermissions:0.2.1'
testCompile 'junit:junit:4.12'
}
And this is my chart code. It compiles and shows the chart but it has the Description Label "Description Label" that I can't change or turn off.
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.Description;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
import java.util.ArrayList;
import java.util.List;
import static com.example.android.nbmc_hbmc.R.id.chart;
public class NbmcEcgGraphActivity extends Activity {
private RelativeLayout mainLayout;
private LineChart mChart;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ecggraph);
mainLayout = (RelativeLayout) findViewById(R.id.activity_ecggraph);
// Create new line chart
LineChart mChart = (LineChart) findViewById(chart);
mChart.setDescription(new Description());
mChart.setNoDataText("No Data Yet");
It looks like the wiki is out of date!
The correct syntax in MPAndroidChart 3.0.1 is
mChart.getDescription().setText("Description of my chart");
Reference: javadoc
I keep getting a "unresolved reference: FacebookCallback" error when I am trying to implement the code attached in the picture.
I am trying to set up facebook login as instructed in this link: https://developers.facebook.com/docs/facebook-login/android#addbutton
I am new to Kotlin but I can't see what I'm doing wrong here.
EDIT:
Here are my gradle files:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "yetti.yetti"
minSdkVersion 23
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
androidTest.java.srcDirs += 'src/androidTest/kotlin'
}
dexOptions {
javaMaxHeapSize "2048M"
}
compileOptions.incremental = false
}
kapt {
generateStubs = true
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha4'
compile 'com.jakewharton:butterknife:8.2.1'
compile 'com.facebook.android:facebook-android-sdk:4.14.0'
compile 'com.google.firebase:firebase-core:9.2.1'
compile 'com.google.firebase:firebase-database:9.2.1'
compile 'com.google.firebase:firebase-auth:9.2.1'
testCompile 'junit:junit:4.12'
kapt 'com.jakewharton:butterknife-compiler:8.2.1'
}
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'
and:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.0.3'
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-alpha6'
classpath 'com.google.gms:google-services:3.0.0'
// the latest version of the android-apt plugin
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
futhermore, here is the equivalent code I am trying to execute but written in plain Java (which works just fine):
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.login.LoginResult;
public class Actv extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_actv);
FacebookCallback<LoginResult> facebookCallback = new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
}
#Override
public void onCancel() {
}
#Override
public void onError(FacebookException error) {
}
};
}
}
A proper way to anonymously implement FacebookCallback in Kotlin is as follows:
val facebookCallback = object : FacebookCallback<LoginResult> {
override fun onSuccess(loginResult: LoginResult) {
}
override fun onCancel() {
}
override fun onError(error: FacebookException) {
}
}
Object Expressions and Declarations documentation provides all necesary details.