Android Studio - Cannot find symbol class - android-studio

When I run my app, Android Studio notifies me some error in Gradle Build.
Could you help me understand how to fix this problem?
MapsActivity
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
DatabaseHelper myDb;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
addMarkers();
}
#Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
LatLng ruvo = new LatLng(-45, 123);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.addMarker(new MarkerOptions().position(ruvo).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(ruvo));
}
public void onSearch(View view) {
EditText textCity = (EditText) findViewById(R.id.textCity);
String location = textCity.getText().toString();
List<android.location.Address> addressList = null;
if (location != null) {
Geocoder geocoder = new Geocoder(this);
try {
addressList = geocoder.getFromLocationName(location, 1);
} catch (IOException e) {
e.printStackTrace();
}
android.location.Address address = addressList.get(0);
LatLng latLng = new LatLng(address.getLatitude(), address.getLongitude());
mMap.addMarker(new MarkerOptions().position(latLng).title("Marker pointed"));
mMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
} else {
textCity.setHint("Enter a valid city");
//textCity.setTextColor();
}
}
public void addMarkers() {
ArrayList<OverlayItem> items = new ArrayList<OverlayItem>();
Cursor database = myDb.display();
if (database.getCount()== 0) {
Toast.makeText(this, "Nothing to found", Toast.LENGTH_LONG).show();
return;
}
database.moveToFirst();
do {
int latitude = (int) (database.getDouble(database.getColumnIndex("LAT")) * 1E6);
int longitude = (int) (database.getDouble(database.getColumnIndex("LONG")) * 1E6);
items.add(new OverlayItem(new GeoPoint(latitude, longitude)));
} while (database.moveToNext());
}
}
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.android.sqlite"
minSdkVersion 16
targetSdkVersion 23
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:23.3.0'
compile 'com.google.android.gms:play-services:9.2.0'
}
Error messages:
Error:(82, 19) error: cannot find symbol class OverlayItem
Error:(82, 54) error: cannot find symbol class OverlayItem
Error:(92, 31) error: cannot find symbol class OverlayItem
Error:(92, 47) error: cannot find symbol class GeoPoint
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.`

Related

Cannot resolve symbol 'onCompleteListener'

I followed this tutorial https://morioh.com/p/10dc2d87bb2f but despite doing everything the same i get the following error:
error: cannot find symbol
mAuth.signInWithCredential(authCredential).addOnCompleteListener( MainActivity.his,new onCompleteListener() {
^
symbol: variable his
location: class MainActivity
I tried changing the cersions of play-services and firebase-auth/core but nothing changed.
My MainActivity.java:
package com.imoroney.easylearn;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.google.android.gms.auth.api.signin.GoogleSignIn;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInClient;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.common.api.ApiException;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthCredential;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.auth.GoogleAuthProvider;
import com.google.android.gms.tasks.OnCompleteListener;
public class MainActivity extends AppCompatActivity {
private SignInButton signInButton;
private GoogleSignInClient mGoodleSignInClient;
private String TAG = "MainActivity";
private FirebaseAuth mAuth;
private Button btnSignOut;
private int RC_SIGN_IN = 1;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
signInButton = findViewById(R.id.sign_in_button);
mAuth = FirebaseAuth.getInstance();
btnSignOut = findViewById(R.id.sign_out_button);
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestIdToken(getString(R.string.default_web_client_id)).requestEmail().build();
mGoodleSignInClient = GoogleSignIn.getClient(this,gso);
signInButton.setOnClickListener(new View.OnClickListener(){
#Override
public void onClick(View view){
signIn();
}
});
btnSignOut.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mGoodleSignInClient.signOut();
Toast.makeText(MainActivity.this,"You Are Signed Out", Toast.LENGTH_SHORT).show();
btnSignOut.setVisibility(View.INVISIBLE);
}
});
}
private void signIn(){
Intent signInIntent = mGoodleSignInClient.getSignInIntent();
startActivityForResult(signInIntent,RC_SIGN_IN);
}
#Override
protected void onActivityResult(int requestCode, int resultCode, #Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == RC_SIGN_IN) {
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
handleSignInResult(task);
}
}
private void handleSignInResult(Task<GoogleSignInAccount> completedTask){
try {
GoogleSignInAccount acc = completedTask.getResult(ApiException.class);
Toast.makeText(MainActivity.this,"Signed In Successfully", Toast.LENGTH_SHORT).show();
FirebaseGoogleAuth(acc);
}
catch (ApiException e){
Toast.makeText(MainActivity.this,"Sign In Failed", Toast.LENGTH_SHORT).show();
FirebaseGoogleAuth(null);
}
}
private void FirebaseGoogleAuth(GoogleSignInAccount acct){
AuthCredential authCredential = GoogleAuthProvider.getCredential(acct.getIdToken(),null);
mAuth.signInWithCredential(authCredential).addOnCompleteListener( MainActivity.his,new onCompleteListener<AuthResult>() {
#Override
public void onComplete(#NonNull Task<AuthResult> task){
if(task.isSuccessful()){
Toast.makeText(MainActivity.this,"Successful", Toast.LENGTH_SHORT).show();
FirebaseUser user = mAuth.getCurrentUser();
updateUI(user);
}
else{
Toast.makeText(MainActivity.this,"Failed", Toast.LENGTH_SHORT).show();
updateUI(null);
}
}
});
}
private void updateUI(FirebaseUser fUser){
btnSignOut.setVisibility(View.VISIBLE);
GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(getApplicationContext());
if(account != null){
String personName = account.getDisplayName();
String personGivenName = account.getGivenName();
String personFamilyName = account.getFamilyName();
String personEmail = account.getEmail();
String personId = account.getId();
Uri personPhoto = account.getPhotoUrl();
Toast.makeText(MainActivity.this, personName + personEmail, Toast.LENGTH_SHORT).show();
}
}
}
My build gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.imoroney.easylearn"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.firebase:firebase-auth:19.3.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.firebase:firebase-core:17.5.0'
implementation 'com.google.android.gms:play-services-auth:18.1.0'
implementation 'com.google.firebase:firebase-messaging:20.2.4'
}

couldn't find "libsapjco3.so"

I have a problem when connecting to SAP when using sapjco.
Here is the error message :
java.lang.ExceptionInInitializerError: JCo initialization failed with
java.lang.UnsatisfiedLinkError:
dalvik.system.PathClassLoader[DexPathList[[zip file
"/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/base.apk",
zip file
"/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_dependencies_apk.apk",
zip file
"/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_resources_apk.apk",
zip file
"/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_slice_0_apk.apk",
zip file
"/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_slice_1_apk.apk",
zip file
"/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_slice_2_apk.apk",
zip file
"/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_slice_3_apk.apk",
zip file
"/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_slice_4_apk.apk",
zip file
"/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_slice_5_apk.apk",
zip file
"/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_slice_6_apk.apk",
zip file
"/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_slice_7_apk.apk",
zip file
"/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_slice_8_apk.apk",
zip file
"/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.ecowb.ecowb-IFzEAhc8t47wbNTPHHT6kw==/lib/arm64,
/system/lib64, /system/vendor/lib64]]] couldn't find "libsapjco3.so"
and this is my Project:
MainActivity.Java
package com.example.ecowb.ecowb;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.sap.conn.jco.AbapException;
import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoDestinationManager;
import com.sap.conn.jco.JCoException;
import com.sap.conn.jco.JCoFunction;
import com.sap.conn.jco.JCoTable;
import net.sf.json.JSON;
import net.sf.json.xml.XMLSerializer;
public class MainActivity extends AppCompatActivity {
static String ABAP_AS = "ABAP_AS_WITHOUT_POOL";
public static String ABAP_AS_POOLED = "ABAP_AS_WITH_POOL";
static String ABAP_MS = "ABAP_MS_WITHOUT_POOL";
static boolean alreadyRegister;
private android.content.Context context;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (this.alreadyRegister == true) {
return;
}
CustomDestinationDataProvider.MyDestinationDataProvider myProvider = new CustomDestinationDataProvider.MyDestinationDataProvider();
try {
com.sap.conn.jco.ext.Environment.registerDestinationDataProvider(myProvider);
alreadyRegister = true;
} catch (IllegalStateException providerAlreadyRegisteredException) {
throw new Error(providerAlreadyRegisteredException);
}
// CustomDestinationDataProvider test = new
// CustomDestinationDataProvider();
myProvider.changeProperties(ABAP_AS_POOLED, CustomDestinationDataProvider.getDestinationPropertiesFromUI());
JCoDestination destination = null;
try {
destination = JCoDestinationManager.getDestination(ABAP_AS_POOLED);
} catch (JCoException e) {
e.printStackTrace();
}
System.out.println("Attributes:");
try {
System.out.println(destination.getAttributes());
} catch (JCoException e) {
e.printStackTrace();
}
System.out.println();
}
And this is my Gradle:
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.ecowb.ecowb"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
moduleName "libsapjco3"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
splits {
abi {
enable true
reset()
include 'x86', 'armeabi'
universalApk true
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation fileTree(include: 'native-libs.jar', dir: '$buildDir/native-libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
implementation 'com.android.support:design:27.1.1'
implementation files('libs/json-lib-2.4-jdk15.jar')
implementation files('libs/sapjco3.09.jar')
}
An SAP Java Connector version for Android or the ARM processor architecture does not exist.

Prevent Android Studio Inspection from Flagging Java Stream chain as containing possible NullPointerException

I'm writing a utility method to extract an array of wrapped unparcelable objects:
public interface UnparcelableHolder<U> {
#Nullable U getUnparcelable();
}
public final class FragmentUtil {
#Nullable
public static <U> List<U> getUnparcelableHolderListArgument(
#Nonnull Fragment fragment,
#Nonnull Class<UnparcelableHolder<U>> unparcelableHolderClass,
#Nonnull String key
) {
#Nullable final Bundle arguments = fragment.getArguments();
if (arguments == null) {
return null;
} else {
#Nullable final Parcelable[] parcelableArray = arguments.getParcelableArray(key);
if (parcelableArray == null) {
return null;
} else {
return Arrays
.stream(parcelableArray)
.filter(unparcelableHolderClass::isInstance)
.map(unparcelableHolderClass::cast)
.filter(Objects::nonNull)
.map(UnparcelableHolder::getUnparcelable)
.filter(Objects::nonNull)
.collect(Collectors.toList());
}
if (unparcelableHolderClass.isInstance(parcelable)) {
#Nonnull final UnparcelableHolder<U> unparcelableHolder =
Objects.requireNonNull(unparcelableHolderClass.cast(parcelable));
return unparcelableHolder.getUnparcelable();
} else {
return null;
}
}
}
}
Android Studio is warning me that my .map(UnparcelableHolder::getUnparcelable) call might cause a NullPointerException. This shouldn't be possible because of my preceding filter(Objects::nonNull) call. How do I tell Android Studio's inspector that my code is clean?
This is an MCVE is available on github built with Android Studio 3.4 beta 2:
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.github.hborders.streamsnonnulljsr305"
minSdkVersion 28
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.code.findbugs:jsr305:3.0.2'
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'
}
MainActivity.java:
package com.github.hborders.streamsnonnulljsr305;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class MainActivity extends AppCompatActivity {
class Foo {
#Nonnull
private final String string;
Foo(#Nonnull String string) {
this.string = string;
}
#Nonnull
String getString() {
return string;
}
}
class Bar {
#Nullable
private final Foo foo;
Bar(#Nullable Foo foo) {
this.foo = foo;
}
#Nullable
Foo getFoo() {
return foo;
}
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Bar bar1 = new Bar(new Foo("foo"));
final Bar bar2 = new Bar(null);
final Bar[] bars = new Bar[]{
null,
bar1,
bar2,
};
final List<String> strings = Arrays
.stream(bars)
.map(Bar::getFoo)
.filter(Objects::nonNull)
.map(Foo::getString)
.collect(Collectors.toList());
System.out.println("strings: " + strings);
}
}
The same problem occurs on the .map(Foo::getString) call. Ironically, Android studio doesn't complain about my .map(Bar::getFoo) call despite that definitely throwing a NullPointerException.
It's an Android Studios bug as none of Android Studios suggestions work here.
No warning:
Apply suggestion and get the warning:
It also suggests to insert .filter(Objects::nonNull) step when it is already there.
So it's a definite AS bug.
This is a true MCVE for this issue:
import android.support.annotation.Nullable; // or any nullable you care to use
import java.util.Arrays;
import java.util.Objects;
public class MCVE {
class Foo {
}
class Bar {
#Nullable
private final Foo foo;
Bar(#Nullable Foo foo) {
this.foo = foo;
}
#Nullable
Foo getFoo() {
return foo;
}
}
public void mcve() {
final Bar[] bars = new Bar[]{
new Bar(new Foo()),
};
Arrays.stream(bars)
.map(Bar::getFoo)
.filter(Objects::nonNull)
.map(Foo::toString);
}
}

App is crashing while running AVD in Android Studio. I am running on virtual device pixel 5x with API 27

When I try to create and instance of FusedLocationApi it doesn't get recognized some How. it is in red. It is not importing any classes. seems to me that there might be some problem in Gradle Build App. Please Check it out.
This is My MapActivity.java File
package com.matt.mapapp;
import android.Manifest;
import android.content.pm.PackageManager;
import android.location.Location;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class MapsActivity extends FragmentActivity implements
OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener, LocationListener {
private GoogleMap mMap;
private LocationRequest locationRequest;
private GoogleApiClient client;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
#Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
String[] permissions,
buildGoogleApiClient();
mMap.setMyLocationEnabled(true);
}
}
private synchronized void buildGoogleApiClient(){
client = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
client.connect();
}
#Override
public void onLocationChanged(Location location) {
locationRequest = new LocationRequest();
locationRequest.setInterval(1000);
locationRequest.setFastestInterval(1000);
locationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
if(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED){
LocationRequest.FusedLocationApi.requestlocationUpdates(client, locationRequest, this);
}
}
#Override
public void onConnected(#Nullable Bundle bundle) {
}
#Override
public void onConnectionSuspended(int i) {
}
#Override
public void onConnectionFailed(#NonNull ConnectionResult connectionResult) {
}
}
This is my build gradle (Module app) File. There seemed to be some problem in compiling as there is no such command as compile
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.matt.mapapp"
minSdkVersion 22
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 {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
implementation 'com.google.android.gms:play-services-maps:11.0.4'
implementation 'com.google.android.gms:play-services-location:11.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation'com.android.support.test.espresso:espresso-core:2.2.2'
}
please Check it out and tell me the reason behind. I was following a video tutorial on how to create a map based app and suddenly when I reached at a point to use Fused Location Api I got stuck. The Build Gradle code in the tutorial was different than mine so I thing that this can be the reason for the FusedLocationApi to not work properly.
While creating a app based on the Google map never use virtual device as it gives error most of the times rather you should connect to an android phones with usb debugging on. For that you would have to go to about section of the phone's setting and click on build version or build number for 7 or the number of times it say you require in order to become a developer than go back to main settings and click on developer option from there you would have to turn on USB debugging. Now your phone would ask a connection verification to PC click accept and tick remember my choice. Now you would be able to see your phone above all the listed virtual devices and you would be able to install the app in your phone. Thnaks.
Let me know if that helped you...

How can i fix this type of problems in android studio?

I am getting the following error after creating new project
Error:Failed to resolve: com.android.support:design:23.+
Install Repository and sync project
Show in Project Structure dialog
Error:Failed to resolve: com.android.support:appcompat-v7:23.4.0
Install Repository and sync project
Show in Project Structure dialog
Here is the screenshot
I found some information about this problem. After that I searched for updates of the Android support repository and Google repository. I found an update for the Google repository and updated it. Now my all SDK and studio is updated.
How do I deal with this error now?
public class test1 extends AppCompatActivity {
private int conte = 100;
private String b;
String i="CONFIRM";
EditText vared;
int level=1;
private TextView end,leevel;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test1);
getSupportActionBar().hide();
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
Toast.makeText(test1.this,"زما شما به اتمام رسید !!!", Toast.LENGTH_LONG).show();
Intent i = new Intent(test1.this, test2.class);
startActivity(i);
finish();
}
},100000);
end=(TextView)findViewById(R.id.textView4);
new Thread(){
#Override
public void run() {
while (conte>=0){
runOnUiThread(new Runnable() {
#Override
public void run() {
end.setText(conte+"");
conte--;
}
});
try {
sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}.start();
leevel=(TextView)findViewById(R.id.textView8);
vared=(EditText)findViewById(R.id.vared) ;
Button b2 = (Button) findViewById(R.id.button2);
b2.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String b = vared.getText().toString();
Toast.makeText(test1.this,"ذخیره شد حالا میتونی امتحان کنی !", Toast.LENGTH_LONG).show();
}
});
if( i==b) {
Button b1 = (Button) findViewById(R.id.button);
b1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
level++;
leevel.setText(level + "");
}
});
}else {
Toast.makeText(test1.this,"اسم وارد شده صخیخ نمیباشد !", Toast.LENGTH_LONG).show();
}
}
}

Resources