Browsed by
Tag: android

Error:Execution failed for task ‘:app:processDebugGoogleServices’. > Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 11.4.2.

Error:Execution failed for task ‘:app:processDebugGoogleServices’. > Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 11.4.2.

Solution : Check all google version is same. If google play service is different then others then there may create conflict. Firebase and others google services should be in same version. Example :

How to split apk in android studio

How to split apk in android studio

Go to build.gradle(app) and paste the highlighted code . that’s all. apply plugin: ‘com.android.application’ android { compileSdkVersion 27 defaultConfig { applicationId “your Application ID” minSdkVersion 21 targetSdkVersion 27 versionCode 1 versionName “1.0” testInstrumentationRunner “android.support.test.runner.AndroidJUnitRunner” } splits { abi { enable true reset() include “x86_64″,”x86″,”armeabi”,”armeabi-v7a”,”arm64-v8a”,”mips” universalApk false } } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’ } } lintOptions { checkReleaseBuilds false } } ext.densityCodes = [‘armeabi’:1, ‘armeabi-v7a’:2, ‘arm64-v8a’:3,’mips’:4,’x86′:5,’x86_64′:6] import com.android.build.OutputFile android.applicationVariants.all { variant -> variant.outputs.each { output ->…

Read More Read More

Error:java.lang.OutOfMemoryError: Java heap space .

Error:java.lang.OutOfMemoryError: Java heap space .

Problem: Error:java.lang.OutOfMemoryError: Java heap space . Please assign more memory to Gradle in the project’s gradle.properties file. For example, the following line, in the gradle.properties file, sets the maximum Java heap size to 1,024 MB: org.gradle.jvmargs=-Xmx1024m Read Gradle’s configuration guide Read about Java’s heap size   Solution:   Open gradle.properties file from your project tree add this line at the memory allocation line or or or or or Depending on the Memory of your computer. Then Invalidate Caches/Restart project from…

Read More Read More

Android how to remove new line and spaces and all html tags from String

Android how to remove new line and spaces and all html tags from String

Step 1:¬† compile ‘org.jsoup:jsoup:1.11.3’ add jsonup gradle and sync. Step 2 : create a method public static String html2text(String html) { return Jsoup.parse(html).text(); } Step 3 : implement this String descriptionRawText = “raw text”; String descriptionFinalText = descriptionRawText.replace(“\n”, “”).replaceAll(“\\<[^>]*>”,””).replace(“\r”, “”); String htmlConvertedText = html2text(descriptionFinalText); productDesc.setText(Html.fromHtml(String.valueOf(Html.fromHtml(htmlConvertedText)))); Done ūüôā

Android Google map clustering – how to show actual marker in cluster

Android Google map clustering – how to show actual marker in cluster

1 . Create Custom Cluster renderer package com.findbitcoinatm.android.utils; import android.content.Context; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.OvalShape; import android.util.SparseArray; import android.view.ViewGroup; import com.findbitcoinatm.android.models.cluster.ATMClusterItems; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.model.BitmapDescriptor; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.android.gms.maps.model.MarkerOptions; import com.google.maps.android.clustering.Cluster; import com.google.maps.android.clustering.ClusterManager; import com.google.maps.android.clustering.view.DefaultClusterRenderer; import com.google.maps.android.ui.IconGenerator; import com.google.maps.android.ui.SquareTextView; public class MyClusterItemRenderer extends DefaultClusterRenderer<ATMClusterItems> { private final IconGenerator mIconGenerator; private final ShapeDrawable mColoredCircleBackground; private final float mDensity; private SparseArray<BitmapDescriptor> mIcons = new SparseArray(); public MyClusterItemRenderer(Context context, GoogleMap map, ClusterManager<ATMClusterItems> clusterManager) { super(context, map, clusterManager); mIconGenerator…

Read More Read More

Error:Execution failed for task ‘:app:preDebugAndroidTestBuild’. > Conflict with dependency ‘com.android.support:support-annotations’ in project ‘:app’. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.

Error:Execution failed for task ‘:app:preDebugAndroidTestBuild’. > Conflict with dependency ‘com.android.support:support-annotations’ in project ‘:app’. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.

Solution : compile ‘com.android.support:support-annotations:27.1.1’ to gradle(app) and sync . Solved ūüôā Example : apply plugin: ‘com.android.application’ android { compileSdkVersion 26 defaultConfig { applicationId “com.arifhasnat.islamicbooks” 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 { implementation fileTree(dir: ‘libs’, include: [‘*.jar’]) implementation ‘com.android.support:appcompat-v7:26.1.0’ implementation ‘com.android.support.constraint:constraint-layout:1.1.0’ implementation ‘com.android.support:design:26.1.0’ 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’ compile ‘com.android.support:support-annotations:27.1.1’ compile ‘com.github.barteksc:android-pdf-viewer:2.8.2’ }

Android navigation/ toolbar back

Android navigation/ toolbar back

Step one : put these in oncreate method getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true);     @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_details); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); } Step two : Give action to go specific page or actions @Override public boolean onOptionsItemSelected(MenuItem item) { Intent intent = new Intent(fromActivity.this, toActivity.class); startActivity(intent); return super.onOptionsItemSelected(item); } @Override public void onBackPressed() { super.onBackPressed(); Intent intent = new Intent(fromActivity.this, toActivity.class); startActivity(intent); }

EOFException: End of input at line 1 column 1 path $ 

EOFException: End of input at line 1 column 1 path $ 

EOFException: End of input at line 1 column 1 path $¬†¬†or¬†Retofit2 error java.io.EOFException: End of input at line 1 column 1 Reasons: This error message indicates a completely empty response, not the one you have indicated. If it’s an error you should be using¬†errorBody()¬†to get access to the data. If this is a normal response then you should yell at your server for returning no content when content was expected. But if you cannot change the server, consider using a…

Read More Read More

Error:Execution failed for task ‘:app:transformClassesWithDexForDebug’. > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

Error:Execution failed for task ‘:app:transformClassesWithDexForDebug’. > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

Sometimes application may be big in execution or heavy that time multidex should be enabled . Here is the full process to enable multidex in android   Enable Multidesk

Android create border radius for Button , Views , EditText and others

Android create border radius for Button , Views , EditText and others

Step – 1: Create xml layout in drawable folder <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android” > <item android:state_pressed=”true” > <shape android:shape=”rectangle” > <corners android:radius=”3dip” /> <stroke android:width=”1dip” android:color=”#5e7974″ /> <gradient android:angle=”-90″ android:startColor=”#345953″ android:endColor=”#689a92″ /> </shape> </item> <item android:state_focused=”true”> <shape android:shape=”rectangle” > <corners android:radius=”3dip” /> <stroke android:width=”1dip” android:color=”#5e7974″ /> <solid android:color=”#58857e”/> </shape> </item> <item > <shape android:shape=”rectangle” > <corners android:radius=”3dip” /> <stroke android:width=”1dip” android:color=”#5e7974″ /> <gradient android:angle=”-90″ android:startColor=”#8dbab3″ android:endColor=”#58857e” /> </shape> </item> </selector> Step 2 : Implement on anywhere like button and…

Read More Read More

Android Fragment basic code structure

Android Fragment basic code structure

public class BasicFragment extends Fragment { @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.basic_fragment_layout, container, false); return view; } }

Android custom date picker

Android custom date picker

Step -1 : Create a custom fragment import android.annotation.SuppressLint; import android.app.DatePickerDialog; import android.app.Dialog; import android.os.Bundle; import android.support.v4.app.DialogFragment; import android.view.View; import android.widget.DatePicker; import android.widget.EditText; import java.text.SimpleDateFormat; import java.util.Calendar; @SuppressLint(“ValidFragment”) public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { public static final String DATE_FORMAT = “dd-MM-yyyy”; EditText mView; private DatePickerDialog datepic; public DatePickerFragment(View v) { mView = (EditText) v; } Calendar c; public DatePickerFragment() { } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the…

Read More Read More

Android Beautiful Spinner view without Custom adapter

Android Beautiful Spinner view without Custom adapter

To make this just bind spinner with cardview . and make it like the code bellow . now it will looks beautiful .   <android.support.v7.widget.CardView android:layout_width=”match_parent” android:layout_height=”@dimen/count_40dp” android:layout_marginLeft=”@dimen/count_5dp” android:layout_marginRight=”@dimen/count_5dp” android:layout_marginTop=”@dimen/count_10dp”> <Spinner android:id=”@+id/gender” android:layout_width=”match_parent” android:layout_height=”match_parent” /> </android.support.v7.widget.CardView>

Android Custom spinner .

Android Custom spinner .

Step -1 : Create new Adapter . public class CustomSpinnerAdapter extends BaseAdapter implements SpinnerAdapter { private final Context context; private ArrayList<String> asr; public CustomSpinnerAdapter(Context context1, ArrayList<String> asr) { this.context = context1; this.asr=asr; } public int getCount() { return asr.size(); } public Object getItem(int i) { return asr.get(i); } public long getItemId(int i) { return (long)i; } @Override public View getDropDownView(int position, View convertView, ViewGroup parent) { TextView txt = new TextView(context); txt.setPadding(16, 16, 16, 16); txt.setTextSize(18); txt.setGravity(Gravity.CENTER_VERTICAL); txt.setText(asr.get(position)); txt.setTextColor(Color.parseColor(“#000000”)); return…

Read More Read More

Firebase: A config file was found, but it indicates a project ID “priokotha-92c0e” that you dont appear to have access to. Request access or delete the file in order to proceed with the connection process.

Firebase: A config file was found, but it indicates a project ID “priokotha-92c0e” that you dont appear to have access to. Request access or delete the file in order to proceed with the connection process.

This error will occur if you are signed in to Android Studio and the Firebase Console with different accounts. In Android Studio, click on the small profile icon in the upper right corner to see your sign-in account. Do the same for the Firebase Console tab of your browser. If they are different, sign out and sign in to make them the same.    

ERROR:’keytool’ is not recognized as an internal or external command, operable program or batch file

ERROR:’keytool’ is not recognized as an internal or external command, operable program or batch file

Step 1 : Download JDK : http://www.oracle.com/technetwork/java/javase/downloads/index.html and install it . Step 2 : Set the path on environment path . To do this My Computer – > Properties -> System variable -> Edit Path , click new and past jre bin path location . Check that the directory the keytool executable is in is on your path. (For example, on my Windows 7 machine, it’s in C:\Program Files (x86)\Java\jre6\bin.)   keytool path may be different . find the keytool…

Read More Read More

Error:Execution failed for task ‘:app:transformDexArchiveWithExternalLibsDexMergerForDebug’. > java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

Error:Execution failed for task ‘:app:transformDexArchiveWithExternalLibsDexMergerForDebug’. > java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

It may causes for several reasons – I have found 2 reason and solution . ¬†Problem 1 : If you use firebase service and it’s gradle version are older version . Or google play service , gms service are not updated version that can create this problem . Solution : Update all gradle version updated and same version for firebase . Problem 2 :¬† If multidex not enabled Solution :¬† Android Multi-dex Enable  

Firebase for android – Insert value as a list data

Firebase for android – Insert value as a list data

Part : one – Go to firebase console and click database . If you want to insert database without authentication then go to database->rules tab and { “rules”: { “.read”: “auth == null”, “.write”: “auth == null” } } Part 2 : Create¬†Model . I used Notes Model /** * Created by ADN Digital on 12/24/2017. */ public class Notes { public String id; public String title; public String description; public String date; public String day; public String currentDate; public…

Read More Read More

Android beautiful dialog and alert libraries

Android beautiful dialog and alert libraries

1 . Lovely dialog¬†is a nice dialog third party android library . There has some good functionality that makes¬†it awesome .   2 . Sweet alert¬†¬† is also a nice dialog and alert library . It’s also have animation that makes it beautiful .   3 .android material dialog¬† is now default dialog for android . It’s also simple and nice .   ¬†4.¬†¬†Pretty dilog¬†¬†¬†¬†is good for it’s nice close button . 5. No Internet Dialog¬† ¬†is very good for…

Read More Read More

Firebase for android : Read list of data from database and show on recyclerview

Firebase for android : Read list of data from database and show on recyclerview

Part -1 : Take that we have some data field on child node named “user” . We will first retrieve all data and then we will show it on recyclerview. , public class UserListActivity extends AppCompatActivity { private DatabaseReference mDatabase; ArrayList<User> userArrayList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_user_list); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); mDatabase = FirebaseDatabase.getInstance().getReference(); mDatabase.child(“user”).addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot snapshot) { Toast.makeText(UserListActivity.this, snapshot.toString(), Toast.LENGTH_SHORT).show(); @Override public void onCancelled(DatabaseError databaseError) { System.out.print(databaseError.toString()); } });…

Read More Read More

Firebase for android : Part One – Project setup

Firebase for android : Part One – Project setup

First of all you can get total setup manual from here . https://firebase.google.com/docs/android/setup I am describing here step by step : Part 1 : First create an android project . If already have then no need . We need project package name . Part 2 :¬† Go to firebase console to create a project . You need a gmail account .¬†https://console.firebase.google.com/ . Add new project . Give project name and enter create project . I named test-project .   Part…

Read More Read More

Android Multi-dex Enable

Android Multi-dex Enable

aSometimes it needed to enable multidex in out add and its can throw error also . But memory limit 64 k problem may be a painful problem to solve for who faces this problem newly . But we can easily solve this problem . Just three steps – Step : 1 Add dependency at first and sync compile ‘com.android.support:multidex:+’ Step 2 : and add multidex enable inside defaultConfig multiDexEnabled true so whole build.gradle will looks like as   apply plugin:…

Read More Read More

Android Schedule Notifications at specific time

Android Schedule Notifications at specific time

A notification is a message you can display to the user outside of your application‚Äôs normal UI. When you tell the system to issue a notification, it first appears as an icon in the notification area. To see the details of the notification, the user opens the notification drawer. Both the notification area and the notification drawer are system-controlled areas that the user can view at any time.   I will discuss here about android schedule notification with big Image…

Read More Read More